akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,a=-1,b=-1,c=-1,as=0,bs=0,cs=0;
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		if(a==-1)a=x;
		if(a!=x&&b==-1)b=x;
		if(a!=x&&b!=x&&c==-1)c=x;
		if(a!=x&&b!=x&&c!=x){
			printf("No\n");
			return 0;
		}
		if(a==x)as++;
		if(b==x)bs++;
		if(c==x)cs++;
	}
	if(n%3!=0&&as==n&&a==0)printf("Yes\n");
	else if(n%3==0&&a!=-1&&b!=-1&&c!=-1&&as==n/3&&bs==n/3&&cs==n/3&&((a^b)==c))printf("Yes\n");
	else if(n%3==0&&a!=-1&&b!=-1&&c==-1&&((as==n/3&&a==0)||(bs==n/3&&b==0)))printf("Yes\n");
	else if(n%3==0&&a!=-1&&b==-1&&c==-1&&a==0)printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args) throws Exception{
		PrintWriter pw=new PrintWriter(System.out);
		MScanner sc = new MScanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[]in=sc.intArr(n);
		long sum=0;
		for(int i=0;i<n;i++) {
			sum+=in[i];
			in[i]*=4*m;
		}
		int cnt=0;
		for(int i=0;i<n;i++) {
			if(in[i]>=sum) {
				cnt++;
			}
		}
		pw.println(cnt>=m?"Yes":"No");
		
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int n, R[200000 + 5];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> R[i];
  }
  int ans = R[1] - R[0];
  int minv = min(R[0], R[1]);
  for (int i = 2; i < n; i++) {
    ans = max(ans, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3864
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	string t;
	for (auto i : s) {
		if (i != 'x') {
			t += i;
		}
	}
	if (t.empty()) {
		cout << "0\n";
		return 0;
	}
	string u = t;
	reverse(u.begin(), u.end());
	if (t != u) {
		cout << "-1\n";
		return 0;
	}
	vector<int>box;
	int bag = 0;
	for (auto i : s) {
		if (i == 'x') {
			bag++;
		}
		else {
			box.push_back(bag);
			bag = 0;
		}
	}
	box.push_back(bag);

	N = box.size();

	for (int i = 0; i < N / 2; i++) {
		M += abs(box[i] - box[N - i - 1]);
	}
	cout << M << endl;
	return 0;
}


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

const int MAXN = 200005;
const int offset = 1 << 18;

struct node {
	int mn, pos;
};

int N;
int p[MAXN];
int a[2][MAXN];

struct segment {
	int lo, hi, pos;
	bool operator <(const segment &rhs) const {
		return p[pos] < p[rhs.pos];
	}
};

set <segment> S;

struct tournament {
	node t[2 * offset];	
	node merge(node l, node r) {
		return {min(l.mn, r.mn), l.mn < r.mn ? l.pos : r.pos};
	}
	void init(int *arr) {
		for (int i = 0; i < N; i++)
			t[i + offset] = {arr[i], i};
		for (int i = offset - 1; i >= 0; i--)
			t[i] = merge(t[2 * i], t[2 * i + 1]);
	}
	node query(int x, int lo, int hi, int from, int to) {
		if (lo >= to || hi <= from)
			return {N + 1, 0};
		if (lo >= from && hi <= to)
			return t[x];
		int mid = (lo + hi) / 2;
		return merge(query(2 * x, lo, mid, from, to), query(2 * x + 1, mid, hi, from, to));
	}
	int query(int from, int to) {
		return query(1, 0, offset, from, to).pos;
	}
};

tournament T[2];

void load() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", p + i);
}

int get(int l, int r, int parity) {
	return T[(l + parity) % 2].query(l, r);
}

void add(int l, int r) {	
	if (l < r)
		S.insert({l, r, get(l, r, 0)});
}

void solve() {
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < N; j++)
			a[i][j] = j % 2 == i ? p[j] : N + 1;
		T[i].init(a[i]);
	}
	
	add(0, N);
	for (int i = 0; i < N / 2; i++) {
		segment tmp = *S.begin();
		S.erase(tmp);
		int curr = get(tmp.pos, tmp.hi, 1);
		printf("%d %d ", p[tmp.pos], p[curr]);
		add(tmp.lo, tmp.pos);
		add(tmp.pos + 1, curr);
		add(curr + 1, tmp.hi);
	}
	puts("");
}

int main() {
	load();
	solve();
	return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

const int B = 800;

struct Query {
    int l, r, no;
    Query(int l, int r, int no) : l(l), r(r), no(no) {}
    Query() : l(0), r(0), no(0) {}
    bool operator<(const Query &a) const {
        int ablock = this->l / B, bblock = a.l / B;
        if(ablock != bblock) return ablock < bblock;
        if(ablock & 1) return this->r < a.r;
        else return this->r > a.r;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for (auto &&i : c) scanf("%d", &i);
    vector<int> cnt(500001);
    vector<Query> Q(q);
    for (int i = 0; i < q; ++i) {
        int l, r;
        scanf("%d %d", &l, &r);
        Q[i] = {l-1, r, i};
    }
    sort(Q.begin(),Q.end());
    int l = 0, r = 0;
    int ans = 0;
    vector<int> anss(q);
    for (int i = 0; i < q; ++i) {
        while(Q[i].l < l){
            l--;
            if(!(cnt[c[l]]++)) ans++;
        }
        while(r < Q[i].r){
            if(!(cnt[c[r]]++)) ans++;
            r++;
        }
        while(l < Q[i].l){
            if(!(--cnt[c[l]])) ans--;
            l++;
        }
        while(Q[i].r < r){
            r--;
            if(!(--cnt[c[r]])) ans--;
        }
        anss[Q[i].no] = ans;
    }
    for (int i = 0; i < q; ++i) {
        printf("%d\n", anss[i]);
    }
    return 0;
}

Measured memory_bytes: 15460
import math

A, B, H, M = map(int, input().split())

TWO_PI = 2 * math.pi

dm = M / 60 * TWO_PI
dh = (H + M / 60) / 12 * TWO_PI

ax = A * math.cos(dh)
ay = A * math.sin(dh)
bx = B * math.cos(dm)
by = B * math.sin(dm)

ans = math.sqrt((ax - bx) ** 2 + (ay - by) ** 2)

print(ans)


Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[30][30];
//ll m,n;
int main()
{
    int m,n;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        cin>>a[i][j];
        int couts=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {  double sum=0;
            for(int k=1;k<=m;k++)
            sum+=abs(a[i][k]-a[j][k])*abs(a[i][k]-a[j][k]);
            sum=sqrt(sum);
            ll ans=ll(sum);
            if(ans==sum)
                couts++;


        }
    }
    cout<<couts<<endl;
  /*cin>>m>>n;


  m%=2019;
  n%=2019;
  if(m>n)
  n+=2019;
  if(m==0||n==0)
    cout<<0<<endl;
else
  {

       ll mins=1e9;
      for(int i=m;i<=n;i++)
      {
          for(int j=i+1;j<=n;j++)
          {
             ll  sum=(ll)i*j%2019;
              mins=min(mins,sum);

          }

      }
      cout<<mins<<endl;
  }
*/

    return 0;
}


Measured memory_bytes: 256
import java.io._

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))

  val Array(n,cp) = in.readLine.split(" ").map(_.toInt)

  val ans = {
    val dp = Array.ofDim[Int](n+1, cp+1)

    Iterator.continually(in.readLine)
    .take(n)
    .map(_.split(" "))
    .foldLeft(0)((i,e) => {
      val v = e(0).toInt
      val w = e(1).toInt
      for(j <- 1 to cp) {
        dp(i+1)(j) =
          if (w <= j) math.max(dp(i)(j), dp(i)(j-w) + v)
          else dp(i)(j)
      }
      i + 1
    })

    dp(n)(cp)
  }

  println(ans)
}


Measured memory_bytes: 48572
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

class UnionFind{
    vector<ll> par; vector<ll> r_size;
    public:
        UnionFind(ll N) : par(N),r_size(N){
            for(int i=0; i<N; ++i){ par[i] = i; r_size[i] = 1;}
        }

        void init(ll N){
            par.resize(N); r_size.resize(N);
            for(int i=0; i<N; ++i){ par[i] = i; r_size[i] = 1;}
        }

        ll find(ll x){
            if(par[x] == x)return x;
            return par[x]=find(par[x]);
        }

        void unite(ll x,ll y){
            ll rx = find(x); ll ry = find(y);
            if(rx == ry) return;
            if(r_size[rx]<r_size[ry]) swap(rx,ry);
            r_size[rx] += r_size[ry];
            par[ry] = rx;
        }

        bool same(ll x, ll y){
            ll ry = find(x); ll rx = find(y);
            return rx == ry;
        }

        ll el_size(ll x){
            return r_size[find(x)];
        }
};

int main(){
	ll N, M, a, b;
	cin >> N >> M;
	UnionFind uf(N);
	vector<P> path(M);
	vector<ll> ans(M+1);
	ans[M] = N*(N-1)/2;
	rep(i,M){
		cin >> a >> b;
		--a; --b;
		path[i] = make_pair(a,b);
	}
	for(int i = M-1; i >= 0; --i){
		ll res = ans[i+1];
		if(!uf.same(path[i].first, path[i].second)){
			res -= uf.el_size(path[i].first) * uf.el_size(path[i].second);
			uf.unite(path[i].first, path[i].second);
		}
		ans[i] = res;
	}
	REP(i,M)cout << ans[i] << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
int main() {
    ll x;
    cin >> x;
    ll ans = x / 11 * 2;
    ans += (x % 11 < 7) ? 1 : 2;
    if (x % 11 == 0) ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include<stdlib.h>
int main(void){
    int x,days;
    scanf("%d",&x);
    if(x>=9){
        days=(x-9+1)%7;
        if(days==1){
            printf("sat\n");
        }
        if(days==2){
            printf("sun\n");
        }
        if(days==3){
            printf("mon\n");
        }
        if(days==4){
            printf("tue\n");
        }
        if(days==5){
            printf("wed\n");
        }
        if(days==6){
            printf("thu\n");
        }
        if(days==0){
            printf("fri\n");
        }
        
        
        
    }
    if(x<9){
        days=(9-x)%7;
        
        if(days==0){
            printf("sat\n");
        }
        if(days==6){
            printf("sun\n");
        }
        if(days==5){
            printf("mon\n");
        }
        if(days==4){
            printf("tue\n");
        }
        if(days==3){
            printf("wed\n");
        }
        if(days==2){
            printf("thu\n");
        }
        if(days==1){
            printf("fri\n");
        }
        
        
        
        
    }
    
}


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

int D,G;
vector<int> p,c;

int func(int n){
		int suml=0;
		int cnt=0;
		REP(i,D){
			if(n&(1<<i)){
				cnt += p[i];
				suml += ((i+1)*100*p[i] + c[i]);
			}
		}
		if(suml < G){
			for(int i=D-1;i>=0;--i){
				if(!(n&(1<<i))){
					int diff = G-suml;
					int plus = (int)ceil((double)diff / ((i+1)*100));
					if(plus < p[i]){
						suml += plus*((i+1)*100);
						cnt += plus;
						break;
					}
					//cout << "\t" << diff << " " << plus << endl;
				}
			}
		}
		if(suml < G) cnt = INF;
	//cout << n << " " << cnt << " " << suml << endl;
	if(n&(1<<(D-1)))return cnt;
	if(n==0)return min(cnt,func(1));
	return min(min(cnt,func(n*2)),func(n*2+1));
}

// abc075
int main(){
	cin>>D>>G;
	p.resize(D);c.resize(D);
	REP(i,D){
		cin>>p[i]>>c[i];
	}
	
	int ans = INF;

	cout << func(0) << endl;

	return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char num[1000];
	int sum, i;
	
	while(1) 
        {
		sum=0;
		scanf("%s", num);
		if(num[0]=='0') 
		break;
          for(i=0; num[i]!='\0'; i++) 
                {
			sum+=num[i]-'0';
		}
	printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin>>N>>M;
  vector<int> A(N);
  int S=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    S +=A.at(i);
  }
  int x=0;
  if(S % (M*4)==0){
    for(int i=0;i<N;i++){
      if(A.at(i)>=S/(4*M)){
        x+=1;
      }
    }
  }
  else{
    for(int i=0;i<N;i++){
    if(A.at(i)>=S/(4*M)+1){
        x+=1;
    }
    }
  }
  if(x>=M){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int N, M, Q;
  scanf("%d%d%d", &N, &M, &Q);

  //boost::multi_array<int, 2> mat(boost::extents[N + 1][N + 1]);
  int mat[501][501] = {};

  FOR(i, M) {
    int L, R;
    scanf("%d%d", &L, &R);
    mat[L][R]++;
  }

  FOR(i, N + 1) {
    FOR1(j, i, N) { mat[i][j + 1] += mat[i][j]; }
  }

  for (int i = N; i > 0; i--) {
    FOR1(j, i, N + 1) { mat[i - 1][j] += mat[i][j]; }
  }

  while (Q--) {
    int p, q;
    scanf("%d%d", &p, &q);
    printf("%d\n", mat[p][q]);
  }

  return 0;
}


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

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

  switch (s[0]) {
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o':
      cout << "vowel" << endl;
      break;
    default:
      cout << "consonant" << endl;
      break;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main ( )
{
 ll x,a,b;
 cin>>x>>a>>b;
 if(-a+b<=0)cout<<"delicious"<<endl;
 else if(-a+b<=x) cout<<"safe"<<endl;
 else cout<<"dangerous"<<endl;
}


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

int main()
{
  long long int x,ans;
  cin>>x;
  if(x%11==0)
  {
    cout<<(x/11) * 2;
  }
  else if(x%11 > 6)
    cout<<((x/11)*2) + 2;
  else
    cout<<((x/11)*2) + 1;
  
  return 0;
}


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

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

ll a[100100], n;
ll ans = 1;

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

int main() {

	cin >> n;

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

	ans = a[1];
	for(int i = 2; i <= n; i++) {
		ans = lcm(ans, a[i]);
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  bool ans = false;
  for (int i = 1; i <= B; ++i) {
    if (A * i % B == C) {
      ans = true;
      break;
    }
  }
  cout << (ans ? "YES" : "NO") << endl;
}


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

using namespace std;

typedef long long ll;
//const ll MOD = 1000000007;
ll X[501][501], S[501][501];

int main() {
  ll N,M,Q;
  cin>>N>>M>>Q;
  for (ll i = 0; i < M; i++) {
    ll l,r;
    cin>>l>>r;
    X[l][r]++;
  }
  for (ll i = 1; i <= N; i++) {
    for (ll j = 1; j <= N; j++) {
      S[i][j] += S[i][j - 1] + X[i][j];
    }
  }
  for (ll i = 0; i < Q; i++) {
    ll p,q;
    cin>>p>>q;
    ll sum = 0;
    for (ll j = p; j <= q; j++) sum += S[j][q] - S[j][p - 1];
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false),cin.tie(0);
#define F first
#define S second
using namespace std;
typedef long long ll;
ll a,b,c,d;
const ll maxn=200005;
const ll mod=1e9+7;
typedef pair<ll,ll> pii;
ll num[100005];
ll n,k,x,y;
string s;
int main()
{
    //IOS
    while(cin>>s)
    {
        sort(s.begin(),s.end());
        if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2])
        {
            cout<<"Yes\n";
        }
        else cout<<"No\n";
    }


}


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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a,b,ans=0;
  cin >> a >> b;
  cout << (3*a+b)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
l=[]

for i in range(N):
    l.append(int(input()))

ans=0
      
for i in range(N-1):
    ans+=(l[i]-l[i]%2)/2
    l[i]=(l[i]%2)
    if l[i+1]!=0:
        ans+=l[i]
        l[i+1]-=l[i]
ans+=(l[-1]-l[-1]%2)/2
print(int(ans))
   

Measured memory_bytes: 49752
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream& operator<<(ostream& os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i]; return os;}
const bool debug = 0;

V<V<int>> ms;

void genMatch(V<int> &match, int m, bool hasCenter) {
    int i=0; while (i<m && match[i] != -1) i++;
    if (i == m) ms.pb(match);
    else {
        FR(j,i,m) if (match[j] == -1 && (i!=j || (!hasCenter && m%2 == 1))) {
            match[i] = j;
            match[j] = i;
            genMatch(match, m, hasCenter || i==j);
            match[i] = match[j] = -1;
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m; cin>>n>>m;
    V<string> ss(n);
    F(i,n) cin>>ss[i];
    V<int> curMatch(m,-1);
    genMatch(curMatch, m, false);
    H(S(ms))
    bool ok = false;
    for (V<int> match : ms) {
        H(match)
        V<int> pos(m, -1);
        V<bool> seen(m, false);
        int cnt = 0;
        F(i,m) if (!seen[i]) {
            if (match[i] == i) {
                pos[i] = m/2;
                seen[i] = true;
            } else {
                pos[i] = cnt;
                pos[match[i]] = m-1-cnt;
                seen[i] = seen[match[i]] = true;
                cnt++;
            }
        }
        H(pos)
        assert(cnt == m/2);
        set<string> revs;
        for (string &s : ss) {
            string t(m,' ');
            F(i,m) t[pos[i]] = s[i];
            if (revs.count(t)) {
                revs.erase(revs.find(t));
            } else {
                reverse(ALL(t));
                revs.insert(t);
            }
        }
        if (S(revs) == n%2)
            ok = true;
    }
    if (ok) cout<<"YES\n";
    else cout<<"NO\n";
}

Measured memory_bytes: 1596
#include<bits/stdc++.h>
#define N 100009
using namespace std;

int n,a[N],b[N],c[2][N],p[N][3],t1[2],t2[2];
void add(int *c,int x){
	for (; x<=n; x+=x&-x) c[x]^=1;
}
int getsum(int *c,int x){
	int y=0; for (; x; x^=x&-x) y^=c[x]; return y;
}
void gg(){ puts("No"); exit(0); }
int main(){
	scanf("%d",&n);
	int i,j;
	for (i=0; i<3; i++)
		for (j=1; j<=n; j++) scanf("%d",&p[j][i]);
	for (i=1; i<=n; i++){
		if (abs(p[i][0]-p[i][1])!=1) gg();
		if (abs(p[i][2]-p[i][1])!=1) gg();
		if (p[i][0]<p[i][2]){
			a[i]=p[i][2]/3; b[i]=0;
		} else{
			a[i]=p[i][0]/3; b[i]=1;
		}
		if ((a[i]^i)&1) gg();
	}
	if (n==3){
		if (a[1]==1 && !b[1] && !b[2] && !b[3]) puts("Yes"); else
		if (a[1]==3 && b[1] && b[2] && b[3]) puts("Yes"); else puts("No");
		return 0;
	}
	for (i=n; i; i--){
		j=i&1;
		t1[j]^=b[i]; t2[j]^=getsum(c[j],a[i]);
		add(c[j],a[i]);
	}
	puts(t1[0]==t2[1] && t1[1]==t2[0]?"Yes":"No");
	return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	char s[32];
	cin >> s;

	int len = strlen(s);
	for (int i = 0; i < len-1; i++) {
		for (int j = i+1; j < len; j++) {
			if (s[i] == s[j]) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var q = new Queue<string>();
            var seed = new string[]{ "7","5","3"};
            foreach (var s in seed) q.Enqueue(s);
            var cnt = 0L;
            while (q.Any())
            {
                var cdt = q.Dequeue();
                if (N < long.Parse(cdt)) continue;
                if (cdt.Contains('7') && cdt.Contains('5') && cdt.Contains('3')) ++cnt;
                foreach (var s in seed) q.Enqueue(cdt + s);
            }
            WriteLine(cnt);
        }

        static long Mod = (long)1e9 + 7;
        private static int pl;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 36356
n = int(input())
D = []
for i in range(n):
    d = int(input())
    D.append(d)
D.sort(reverse=True)
for j in range(n):
    if j == 0:
        x = D[j]
        ans = 1
    else:
        if D[j] < x:
            x = D[j]
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 1010


int main(void){
int a[10001];
int b[100000];
int n,m,x;

int ans;
scanf("%d",&n);
f(i,10001)a[i]=0;
f(i,100000)b[i]=0;
m=0;
f(i,n){
scanf("%d",&b[i]);
if(m<b[i])m=b[i];
}
x=m;
f(i,m){
if(m%(m-i)==0)x=m-i;
a[m-i]=x+i-m;
}
ans=0;
f(i,n)ans+=a[b[i]];
printf("%d\n",ans);




return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
 
#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}
 
 
int main() {
    IN(ll, a);
    IN(ll, b);
    IN(ll, n);
    ll aja = min(n,b-1);
    COUT(aja*a/b);
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int size = 1e6 + 10;

vector<string> s;
string blank;
int main()
{	
	ios_base::sync_with_stdio(0);
	ll n,m,x,y;
	cin >> n >>m;
	ll ans=0;
	while(n<=m)
	{
		n*=2;
		ans++;	
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

template<typename T>
void sort_u(T& v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(),v.end()), v.end());
}

std::vector<int64_t> calc(int a, int b) {
  if(a == b) return std::vector<int64_t>(1,0);
  //if(b >= (a+1)/2) return std::vector<int64_t>();
  std::vector<int64_t> res;
  for(int k = b+1; k <= a; ++k) {
    int na = a%k;
    if(na == b) res.push_back((int64_t)1<<k);
    //if(b >= na/2) continue;
    auto tmp = calc(na, b);
    for(int64_t v: tmp) res.push_back(v+((int64_t)1<<k));
  }
  return res;
}

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> a(N), b(N);
  std::vector<std::vector<int64_t>> v;
  for(int i = 0; i < N; ++i) std::cin >> a[i];
  for(int i = 0; i < N; ++i) std::cin >> b[i];
  for(int i = 0; i < N; ++i) if(a[i] != b[i]) {
    auto t = calc(a[i], b[i]);
    if(t.size() == 0) fin(-1);
    if(t.size() == 1 && t[0] == 0) continue;
    std::sort(t.begin(), t.end());
    v.push_back(t);
  }
  int64_t ans = 0;
  for(int k = 50; k > 0; --k) {
    int64_t s = (ans | ((int64_t)1<<k)-1);
    for(auto const& vv: v) {
      bool ok = false;
      for(int64_t x: vv) if((x&s)==x) { ok = true; break; }
      if(!ok) ans |= ((int64_t)1<<k);
    }
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll a;
  double b;
  cin >> a >> b;
  cout << (a * ll(round(b*100.0)))/100  << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	ansYES(a <= x && a + b >= x);
}


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

struct Node{
  int key;
  Node *p,*l,*r;
};

Node *root,*NIL;

void insert(int k){
  Node *b=NIL;
  Node *a=root;
  Node *c;

  c=(Node *)malloc(sizeof(Node));
  c->key=k;
  c->l=NIL;
  c->r=NIL;

  while(a!=NIL){
    b=a;
    if(c->key < a->key){
      a=a->l;
    }else{
      a=a->r;
    }
  }
  c->p=b;
  if(b==NIL){
    root=c;
  }else{
    if(c->key < b->key){
      b->l=c;;
    }else{
      b->r=c;;
    }
  }
}
  
void In(Node *x){
  if(x==NIL)return;
  In(x->l);
  cout<<" "<<x->key;
  In(x->r);
}

void Pre(Node *x){
  if(x==NIL)return;
  cout<<" "<<x->key;
  Pre(x->l);
  Pre(x->r);
}

int main(){
  int m,k,i;
  string order;

  cin>>m;
  for(i=0;i<m;i++){
    cin>>order;
    if(order== "insert"){
      cin>>k;
      insert(k);
  }
    if(order=="print"){
      In(root);
      cout<<endl;
      Pre(root);
      cout<<endl;
    }
  }
  return 0;
}



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

int main(){
    long long X; 
    cin >> X;
    int N=log10(X)+1;
    int M=pow(2,N-1);
    long long S=0;
    for (int i=0;i<M;i++){
        long long A=X;
        long long SUM=0;
        int L=0;
        int j=i;
        for (int i2=0;i2<N-1;i2++){
            L=L+1;
            if (j%2==1){
                SUM=SUM+A%(long long)pow(10,L);
                A=A/(long long)pow(10,L);
                L=0;
            }
            j=j/2;
        }
        SUM=SUM+A;
        S=S+SUM;
    }
    cout << S << endl;
}


Measured memory_bytes: 3952
#include <iostream>
#include <vector>
#include <string>
#define INF -2000000000
using namespace std;
vector <int> s;
int check(int x){
  for(int i=1;i<s.size()-1;i++){
    int ima = s[i],nx = s[i+1],mae = s[i-1];
    if(ima == INF) ima = x;
    if(nx == INF) nx = x;
    if(mae == INF) mae = x;
    
    if(i%2 == 0 && (ima >= mae || ima>= nx)) 
      if(s[i] == INF)return -1;
      else return 1;

    else if(i%2==1 &&(mae >= ima||nx >= ima)) 
      if(s[i] == INF)  return 1;
      else return -1;
  }

  if(s.size() == 2) {
    int ima = s[0],nx = s[1];
    if(s[0] == INF) ima = x;
    if(s[1] == INF) nx  = x;
    if(ima >= nx) 
      if(s[0] == INF) return -1;
      else return 1;
  }
  return 0;
}

int main() {
  while(1){
    int n;
    cin >> n;
    if(n == 0) break;
    s.clear();
    for(int i=0;i<n;i++) {
      string str;
      cin >> str;
      if(str == "x") s.push_back(INF);
      else s.push_back(stoi(str));
    }
  
    int R = 1000000010,L=-1000000011,M,ans = INF,cnt = 0;
    while(L < R) {
      cnt ++;
      int t = M;
      M = (L+R)/2;
      if(M == t) L--,R++,M=(L+R)/2;
      if(cnt > 35) break;
      int res = check(M);
      if(res == -1) R = M;
      else if(res == 1) L=M+1;
      else if(res == 0) {
	ans = M;
	break;
      }
    }

    if(ans == INF) cout << "none"<<endl;
    else if(check(ans+1) == 0 || check(ans-1) == 0) cout << "ambiguous"<<endl;
    else cout << ans <<endl;
  }
  return 0;

}

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

/*

a) A stack should be non-decreasing by s+w
    If s[i]+w[i] > s[j]+w[j] , i<j then we can swap i,j 
        and the stack is still vaild

    A pile from top to down w[0] - w[n-1]
    sum[i] = \sum_{i=0}^{i} w[i]

    If a pair of i, j s[i]+w[i] > s[j] + w[j] , i<j
    We need proof after swap i,j sum[i-1]'<=s[j] sum[j-1]'<=s[i]

    We know sum[i] < sum[j], sum[i]<=s[i]+w[i], sum[j]<=s[j]+w[j]
    sum[i-1]<sum[j-1], sum[i-1]<=s[i], sum[j-1]<=s[j]

    If we swap i,j 
    sum[j]' = sum[j] <= s[j]+w[j] < s[i]+w[i]
    sum[j-1]' = sum[j] - w[i] < s[i] + w[i] - w[i] < s[i]
    sum[i-1]'=sum[i-1] < sum[j-1] <= s[j] valid

b) s[i]+w[i] == s[j]+w[j], s[i] should be non-decreasing
	If s[i] > s[j], i<j then we can swap i,j 
        and the stack is still vaild

    we need proof after swap i,j sum[i-1]'<=s[j], sum[j-1]'<=s[i]

    we know sum[i] < sum[j], sum[i]<=s[i]+w[i], sum[j]<=s[j]+w[j]
    sum[i-1]<sum[j-1], sum[i-1]<=s[i], sum[j-1]<=s[j]

    sum[j]'=sum[j] <= s[j] + w[j] = s[i] + w[i]
    sum[j-1]' = sum[j]' - w[i] <= s[i] + w[i] - w[i] = s[i] vaild
    sum[i-1]' = sum[i-1] < sum[j-1] <= s[j] < s[i] vaild

dp[i][j] after i block if sum is j

dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]) (s[i]>=j-w[i])

*/

typedef long long LL;
const int MN=1005;
const int MW=10005;

struct Block
{
	int w,s,v;
	void read()
	{
		scanf("%d%d%d",&w,&s,&v);
	}
	bool operator<(const Block &B) const
	{
		int a=s+w,b=B.s+B.w;
		return a==b?s<B.s:a<b;
	}
}block[MN];

LL dp[MW*2];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		block[i].read();
	sort(block,block+n);
	memset(dp,0x8f,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		int s=block[i].s,w=block[i].w,v=block[i].v;
		for(int j=s+w;j>=w;j--)
			dp[j]=max(dp[j],dp[j-w]+v);
	}
	LL ans=0;
	for(int i=0;i<MW*2;i++)
		ans=max(ans,dp[i]);
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;i<10000;i++)
    {
        int x=i*0.08;
        int y=i*0.1;
        if(x==a && y==b)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char str[2048];
	int i, j, f = 0;
	
	fgets(str, 2048, stdin);
	
	i = 0;
	while (str[i] != '\0'){
		if (str[i] != ' ' && str[i] != '.' && str[i] != ','){
			j = i + 1;
			while (str[j] != ' ' && str[j] != '.' && str[j] != ','){
				j++;
			}
			if (j - i >= 3 && j - i <= 6){
				if (f != 0){
					printf(" ");
				}
				f = 1;
				for (; i < j; i++){
					printf("%c", str[i]);
				}
			}
			
			i = j;
		}
		while (str[i + 1] == ' ' || str[i + 1] == '.' || str[i + 1] == ','){
			i++;
		}
		i++;
	}
	puts("");
	
	return (0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll d[n][n],d2[n][n],dori[n][n];
	FOR(i,0,n)FOR(j,0,n){
			cin >> d[i][j];
			dori[i][j] = d[i][j];
	}

	FOR(k,0,n)FOR(i,0,n)FOR(j,0,n){
		if(i==k||j==k)continue;
		if(d[i][j] >= d[i][k]+d[k][j]){
			d2[i][j] = d[i][j];
			d[i][j] = d[i][k]+d[k][j];
		}
	}
	ll ans = 0;
	FOR(i,0,n){
		FOR(j,0,n){
			if(d[i][j]!=dori[i][j]){
				cout << -1 << endl;
				return 0;
			}
			if(d[i][j]!=d2[i][j]){
				ans += d[i][j];
			}
		}
	}
	cout << ans/2 <<endl;
}

Measured memory_bytes: 2432
#include <stdio.h>
int main (void)
{
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        int e=b-a;
        int f=c-b;
        if(e==f){
             printf("YES");}
             else {
             printf("NO");
                     }
        
   return 0;
     
        }

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

/**********************************/

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

    int a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2;
}


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

int main(){
    double ans = 0;
    int n; cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    rep(i,n) cin >> x[i] >> u[i];

    rep(i,n){
        ans += (u[i] == "JPY" ? x[i] : x[i] * 380000);
    }

    put(ans);
}

Measured memory_bytes: 256
import qualified Data.Set as S                                                                                             
main :: IO ()                                                                                                              
main = do                                                                                                                  
  n <- readLn                                                                                                              
  getLine >>= print . maximum .  map (S.size . uncurry S.intersection . dmap S.fromList) . f n                             
                                                                                                                           
f :: Int -> [a] -> [([a],[a])]                                                                                             
f 0 _ = []                                                                                                                 
f n xs = splitAt n xs : f (n-1) xs                                                                                         
                                                                                                                           
pair (g,h) x = (g x, h x)                                                                                                  
cross (g,h) = pair (g.fst, h.snd)                                                                                          
dmap g = cross (g,g)

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

int main()
{
  int N;
  string S;
  cin >> N;
  cin >> S;
  int te = 0;
  int tw = 0;
  int sum_e[N],sum_w[N];
  for(int i = 0;i < N;i++){
    if(S[i] == 'E') te++;
    sum_e[i] = te;
    if(S[i] == 'W') tw++;
    sum_w[i] = tw;
  }

  int left,right,min1;
  min1 = 10000000;
  for(int i = 0;i < N;i++){
    left = 0;
    right = 0;
    if(S[i] == 'E'){
      right = sum_e[N-1] - sum_e[i];
      left = sum_w[i];
    } else if(S[i] == 'W'){
      right = sum_e[N-1] - sum_e[i];
      left = sum_w[i] - 1;
    }
    min1 = min(min1,(left + right));
  }
  cout << min1 << endl;
  return 0;
}


Measured memory_bytes: 3076
S = list(input())

s_list = []

s_pre = S[0]
cnt = 1
ans = []

for s in S[1:]:
    if s != s_pre:
        s_list.append(cnt)
        cnt = 1
        s_pre = s
    else:cnt += 1
s_list.append(cnt)

for i in range(0,len(s_list), 2):
    [ans.append(0) for _ in range(s_list[i]-1)]
    rr = (s_list[i]+1)//2 + s_list[i+1]//2
    ans.append(rr)
    ll = s_list[i]//2 + (s_list[i+1]+1)//2
    ans.append(ll)
    [ans.append(0) for _ in range(s_list[i+1]-1)]

print(*ans)

Measured memory_bytes: 7828
#!usr/bin/env python3

import sys


def generate_buidlings(building, floor, room):
    empty_buildings = {
            key: [[0 for col in range(room)] for row in range(floor)]
            for key in range(1, building+1)
    }
    return empty_buildings


def occupy_buildings(empty_buildings):
    occupied_buildings = generate_buidlings(4, 3, 10)
    n = int(sys.stdin.readline())

    for i in range(n):
        lst = [int(num) for num in sys.stdin.readline().split()]
        occupied_buildings[lst[0]][lst[1]-1][lst[2]-1] += lst[3]

    return occupied_buildings


def print_buildings():
    separator = '####################'
    occupied_buildings = occupy_buildings(generate_buidlings(4, 3, 10))

    for idx, (key, value) in enumerate(occupied_buildings.items()):
        for floor in value:
            print(' %s %s %s %s %s %s %s %s %s %s' % tuple(floor))
        if idx < 3:
            print(separator)


def main():
    print_buildings()


if __name__ == '__main__':
    main()

Measured memory_bytes: 7784
N = int(input())
A_ls=list(map(int, input().split()))

a=(sum(A_ls))**2
b=0
for i in A_ls:
	b+=(i**2)

c=int((a-b)//2)
print(c%(10**9+7))
#print(b)

# 2darray [[0] * 4 for i in range(3)]
# import itertools



Measured memory_bytes: 31428
N,M,K=map(int,input().split())
flag=False

for i in range(N+1):
    for j in range(M+1):
        black= (N-i)*j + (M-j)*i
        if K==black:
            flag=True
            break
    if flag:
        break
       
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N, X, Y = map(int, input().split())

X -= 1
Y -= 1

output = [0]*N

for i in range(N-1):
  for j in range(i+1, N):
    output[min((j-i), abs(i-X)+1+abs(j-Y))] += 1
    
for i in range(1, N):
  print(output[i])

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

using namespace std;

int main(){
  int K;
  string S;
  cin >> K;
  cin >> S;
  if(K < S.length()){
    for(int i=0; i<K; i++) cout << S[i];
    cout << "..." << endl;
  }
  else cout << S << endl;
  return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

ll dp[100010];

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  vector<ll> list;
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list.emplace_back(v);
  }

  fill_n(dp, 100005, INF);
  dp[0] = 0;

  for (ll n = 0; n < N - 1; n++) {
    ll n1 = n + 1;
    ll s1 = abs(list[n] - list[n1]);
    dp[n1] = min(dp[n1], dp[n] + s1);

    // cout << "dp[n1]:" << (dp[n1]) << endl;

    ll n2 = n + 2;
    if (n2 < N) {
      ll s2 = abs(list[n] - list[n2]);
      dp[n2] = min(dp[n2], dp[n] + s2);
    }
  }

  cout << (dp[N - 1]) << endl;
}


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

int main() {
  int N, all;
  cin >> N;
  vector<int> value(N);
  vector<int> cost(N);
  for (int i = 0; i < N; i++) {
    cin >> value.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> cost.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (value.at(i) > cost.at(i)) {
      all += value.at(i) - cost.at(i);
    }
  }
  cout << all << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main(){
  string str;
  
  while(1){
    getline(cin, str);

    if(str[0] == '0'){
      break;
    }
    
    int sum = 0;
    for(int i=0; i<str.size(); i++){
      sum += str[i] - '0';
    }
    
    cout << sum << endl;
    
  }
  

  return(0);

}

Measured memory_bytes: 1176