akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int d = sc.nextInt();
    int[][] x = new int[n][d];
    
    for(int i=0; i<n; i++){
      for(int j=0; j<d; j++){
        x[i][j] = sc.nextInt();
      }
    }
    
    int cnt = 0;
    for(int m=0; m<n; m++){
      for(int l=m+1; l<n; l++){
        double k = 0;
     	 for(int j = 0; j<d; j++){
      	  k += Math.pow((x[m][j]-x[l][j]), 2);
      	}
        double y = Math.sqrt(k);
        int z = (int)Math.sqrt(k);
        if(y-z == 0){
          cnt++;
        }
      }
    }
    System.out.println(cnt);
  }
}

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

int main() {

    string b, ret;
    cin >> b;

    if (b == "T") {
        ret = "A";
    }
    else if (b == "A") {
        ret = "T";
    }
    else if (b == "G"){
        ret = "C";
    }
    else if (b == "C") {
        ret = "G";
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)print("Left"); else if (a + b < c + d)print("Right"); else print("Balanced");




	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int a[n];
  int i;
  
  for(i=0;i<n;i++)
    cin>>a[i];
  long long int stools= 0;
 long int diff;
  int maxi=0;
 for(i=0;i<n;i++)
 {
   maxi = max(maxi,a[i]);
     diff = (maxi-a[i]); 
    stools+=diff;

 }
  cout<<stools;
  
  
  
 return 0; 
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  i64 a, b;
  cin >> a >> b;

  if (0 < a && a <= b) cout << "Positive" << "\n";

  else if (b < 0 && a <= b) {
    if ((abs(b - a) + 1) % 2 != 0) cout << "Negative" << "\n";
    else if ((abs(b - a) + 1) % 2 == 0) cout << "Positive" << "\n";
  }

  else if (a <= 0 && b >= 0) cout << "Zero" << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;
typedef long long LL;

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

const int N = 51;

struct data {
	int x,y;
} a[N],b[N*N];
bool cmp(const data &a,const data &b) {
	if (a.x==b.x) return a.y<b.y; else return a.x<b.x;
}

int n,ans;
bool used[N];

int main() {

	n=read(); rep(i,1,n) a[i].x=read(),a[i].y=read();
	sort(a+1,a+n+1,cmp); ans=n;
	int tot=0;
	rep(i,1,n) rep(j,i+1,n) if (a[i].x!=a[j].x||a[i].y!=a[j].y) b[++tot].x=a[j].x-a[i].x,b[tot].y=a[j].y-a[i].y;
	rep(i,1,tot) {
		rep(j,1,n) used[j]=0;
		int now=0;
		rep(j,1,n) {
			if (used[j]) continue;
			int ptr=j+1,last=j; used[j]=1; ++now;
			while (ptr<=n) {
				if (a[ptr].x-a[last].x==b[i].x&&a[ptr].y-a[last].y==b[i].y) {
					used[ptr]=1; last=ptr;
				}
				ptr++;
			}
		}
		ans=min(ans,now);
	}
	printf("%d\n",ans);

	return 0;
	
}


Measured memory_bytes: 256
dishes = Array.new
5.times { dishes << gets.chomp.to_i }
dishes = dishes.sort_by { |i| (i - 1) % 10 }
new_dishes = dishes.map do |dish|
  if dish % 10 == 0
    dish
  else
    dish = dish + (10 - (dish % 10))
  end
end
p dishes[0] + new_dishes[1..4].inject(:+)


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        for(int i=1;i<s.length();i++) {
            if(s.charAt(i) == s.charAt(i-1)) {
                System.out.print("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
}

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

using namespace std;

map<int,int> frequency; 
bool divisibleSieve[(int)1e6+1];

int f() {
    memset(divisibleSieve, true, sizeof(divisibleSieve));
    auto last = frequency.rbegin();
    for(auto& x:frequency){
        if(!divisibleSieve[x.first]) continue;
        for(int i = 2*x.first; i <= last->first; i += x.first){
            divisibleSieve[i] = false;
        }
    }
    int ans = 0;
    for(auto& x:frequency){
        if(divisibleSieve[x.first] && x.second == 1){
            ans++;
        }
    }
    return ans;
}

int main(){
    int n; cin >> n;
    int aux;
    for(int i = 0; i < n; ++i){
        cin >> aux;
        frequency[aux]++;
    } 
    cout << f();
    return 0;
}

Measured memory_bytes: 13896
#include<stdio.h>
#include<math.h>
struct point {double x,y;};

void koch(int n,point p1,point p2)
{
    if ( n == 0 ) return;

    point s,t,u;
    double th = M_PI * 60.0 / 180.0;
    s.x = (2 * p1.x + p2.x )/3.0;
    s.y = (2 * p1.y + p2.y )/3.0;
    t.x = (2 * p2.x + p1.x )/3.0;
    t.y = (2 * p2.y + p1.y )/3.0;

    u.x = (t.x - s.x) * cos(th) - ( t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + ( t.y - s.y) * cos(th) + s.y;


    koch(n-1,p1,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,p2);
}


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

  point a,b;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);
  return 0;
}



Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S,T;
    cin >>S>>T;
    int ans=0;
    for(int i=0;i<3;i++){
        if(S.at(i)==T.at(i)){
            ans++;
        }
    }
    cout <<ans<<endl;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int k;
  cin>>k;
  queue<int64_t> que;
  for(int i=1;i<10;++i)que.emplace(i);
  k--;
  while(k--){
    int64_t x = que.front();
    que.pop();
    if(x%10==0){
      que.emplace(x*10);
      que.emplace(x*10+1);
    }
    else if(x%10==9){
      que.emplace(x*10+8);
      que.emplace(x*10+9);
    }
    else{
      que.emplace(x*10+x%10-1);
      que.emplace(x*10+x%10);
      que.emplace(x*10+x%10+1);
    }
  }
  cout<< que.front() <<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    int n; cin >> n;
    vector<pair<int, int>> red(n), blue(n);
    rep(i, n) cin >> red[i].first >> red[i].second;
    rep(i, n) cin >> blue[i].first >> blue[i].second;

    sort(all(red), [](pair<int, int> a, pair<int, int> b) { // y座標降順
        return a.second > b.second;
    });
    sort(all(blue)); // x座標昇順

    int ans = 0;
    rep(i, n) { // blueをx座標昇順に見ていく
        int s = red.size();
        rep(j, s) { // redをy座標降順に見ていく
            if(red[j].first < blue[i].first && red[j].second < blue[i].second) { // ペアが見つかったら
                ans++;
                red.erase(red.begin() + j); // ペアになったredを削除。blueは元々1回ずつしか見ない
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
 
int main(void){
  int n,x;
  int m;
  int i;
  int min=1000;
  
  scanf("%d %d",&n,&x);
  
  for( i=0; i<n; i++){
    scanf("%d",&m);
    x -= m;
    if( m < min ) min = m;
  }
  
  printf("%d\n",n + x/min);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define de(x) cout << #x << "=" << x << ", "
#define dd cout << '\n';
#define Eriri ios::sync_with_stdio(0), cin.tie(0);
#define F first
#define S second
#define int long long
using namespace std;
typedef pair<int,int> Pii;
const int N = 2e5+10;
/*
dp[i] = max(dp[j] + w[i], a[j] < a[i], 1<=j<i)
*/
int st[N<<1], n, h[N], w[N], res, dp;
int query(int l, int r)
{
    int res = 0;
    for (l+=n,r+=n; l<r; l>>=1,r>>=1)
    {
        if (l&1) res = max(res, st[l++]);
        if (r&1) res = max(res, st[--r]);
    }
    return res;
}
void modify(int p, int x)
{
    p--;
    for (st[p+=n]=x; p>1; p>>=1)
        st[p>>1] = max(st[p],st[p^1]);
}

signed main()
{
    Eriri
    cin >> n;
    for (int i=1; i<=n; i++)
        cin >> h[i];
    for (int i=1; i<=n; i++)
        cin >> w[i];
    for (int i=1; i<=n; i++)
    {
        dp = query(0,h[i]) + w[i];
        res = max(res, dp);
        modify(h[i],dp);
    }
    cout << res << '\n';
}

Measured memory_bytes: 9896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split(' ').Select(y => long.Parse(y)).ToArray();

            var n = l[0];
            var x1 = (n - l[1] > l[1]) ? n - l[1] : l[1];
            var x2 = (n - l[1] <= l[1]) ? n - l[1] : l[1];
            var sum = n;
            long a = 0;
            while (true)
            {
                a = x1 % x2;
                sum += (x1 - a) * 2;
                if (a == 0)
                {
                    sum -= x2;
                    break;
                }
                x1 = x2;
                x2 = a;
            }
            Console.Write(sum);
            
        }
    }
}


Measured memory_bytes: 13396
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void){
	int i,cnt,len;
	char s[101];
	cin>>s;
	len=strlen(s);
	cout<<s[0]<<len-2<<s[len-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, t; cin >> x >> t;
    if(x-t>0) cout << x-t;
    else cout << 0;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+5;
const int mod=1e9+7;
#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> vi;
ll qpow(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)ans=ans*a%mod;a=a*a%mod;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}

int a[maxn];
int b[maxn],n;
int check(int x){
	b[1]=x;
	for(int i=2;i<=n;i++){
		b[i]=a[i-1]-b[i-1];
	}
	if(a[n]-b[n]==b[1]) return 0;
	else if(a[n]-b[n]>b[1]) return 1;
	else return -1;
}
int main(){
	cin>>n;
	int l=0,r=0;
	for(int i=1;i<=n;i++)cin>>a[i],r=max(r,a[i]);
	while(l<=r){
		int mid=l+r>>1;
		int temp=check(mid);
		if(temp==0)break;
		else if(temp<0) r=mid-1;
		else l=mid+1;
	}
	for(int i=1;i<=n;i++){
		cout<<2*b[i]<<" \n"[i==n];
	}
	return 0;
}



Measured memory_bytes: 2048
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
#include <stack>
using namespace std; 

// #define int long long // debug
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef map<int, int> Mii;
typedef vector<int> Vi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int x[51];
ll dp[51][5001];
 
int main()
{
	int n, a;
	cin >> n >> a;
	rep(i,0,n) {
		cin >> x[i];
		x[i] -= a;
	}

	dp[0][n*a] = 1;
	// dp[i][j] := i枚目まで見て、平均からの距離がjの組合せ (j == n*a の時、平均とする)
	rep(i,0,n) rep(j,0,2*n*a) {
		dp[i+1][j] += dp[i][j];
		dp[i+1][j+x[i]] += dp[i][j];
	}

	cout << dp[n][n*a]-1 << endl;
 
	return 0;
}

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

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

	int a, b; cin >> a >> b;
	int d = b - a;
	int t = (d*(d-1))/2;
	printf("%d\n", t - a);
	return 0;
}

Measured memory_bytes: 3708
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.1415926535897932384626433832795
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct chash {int operator()(int x) const { return x ^ RANDOM; }};
string toString(long long x){stringstream ss;ss << x;string str = ss.str();return str;}
long long fastpow(long long x,long long k){if(!k)return 1;if(k & 1)return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
long long ans = fastpow(x,k/2);ans %= MOD;ans *= ans;ans %= MOD;return ans;}
long long sumF(long long x){int s = 0;while(x)s += x%10,x /= 10;return s;}
bool isS(char c){return (c >= 'a' && c <= 'z');}
bool isB(char c){return (c >= 'A' && c <= 'Z');}
bool isD(char c){return (c >= '0' && c <= '9');}
bool isSqrt(long long x){ long long f = sqrt((long double)x + 0.5); return f*f == x;}
long long lcm(long long a,long long b){return a * (b / __gcd(a,b));}
long long arr[300005];
vector<int> edgeList[300005];
vector<int> largest;
bool solve(int idx,int parent,long long maxPower,long long paths)
{
    if(maxPower < arr[idx] + min(2LL,paths))
        return false;
    bool C = true;
    for(int i = 0;i < edgeList[idx].size();i++)
    {
        if(parent == edgeList[idx][i])
            continue;
        C &= solve(edgeList[idx][i],idx,maxPower,paths + 1);
    }
    return C;
}
int main()
{
    IO;
    long long n;
    cin >> n;
    long long ans = 0;
    set<long long> mys;
    for(int i = 1;1LL*i*i <= n;i++)
    {
        if(n % i == 0)
        {
            mys.insert(n/i);
            mys.insert(i);
        }
    }
    for(set<long long>::iterator it = mys.begin();it != mys.end();it++)
    {
        long long ff = (*it) - 1;
        if(ff == 0)
            continue;
        if(n % ff == n / ff)
            ans += ff;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8704
#include<stdio.h>
int main()
{
    long int n, a[100005], i, b[100005], j;
    scanf("%ld", &n);
    for(i=0; i<n; i++)
    {
        scanf("%ld", &a[i]);
    }
    for(i=0; i<n; i++)
    {
        j=a[i]-1;
        b[j]=i+1;
    }
    for(j=0; j<n; j++)
    {
        printf("%ld ", b[j]);
    }
    return 0;
}

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

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

    int d[n][n];
    for(int i=0; i<n; i++){
        cin >> d[i][0] >> d[i][1];
    }
    
    int ctr = 0;
    bool ans = false;
    for(int i=0; i<n-1; i++){
        if(d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1]){
            ctr++;
            if(ctr >= 2){
                ans = true;
                break;
            }
        }
        else {
            ctr = 0;
        }
    }

    if(ans){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
	
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+9;
vector<int>g[N];
int n,m;
priority_queue<int>q;
int ans=0;
int main(){
    cin>>n>>m;
    for(int i=1,a,b;i<=n;i++)cin>>a>>b,g[a].push_back(b);
    for(int i=1;i<=m;i++){
        for(auto j:g[i])q.push(j);
        if(!q.empty())ans+=q.top(),q.pop();
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

int main() {
std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vi x(n), y(n);
  for (int i = 0; i < m; ++i) {
    int a,b;
    cin >> a >> b;
    --a; --b;
    if (a > b) swap(a, b);
    if (a == 0) x[b] = 1;
    if (b == n-1) y[a] = 1;
  }
  for (int i = 0; i < n; ++i) if (x[i] && y[i]) {
    cout << "POSSIBLE\n";
    return 0;
  }
  cout << "IMPOSSIBLE\n";
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

bool is_hershad(int x)
{
    int tmp = x;
    int res = 0;
    while (tmp)
    {
        res += tmp % 10;
        tmp /= 10;
    }
    return (x % res == 0);
}

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

    cout << (is_hershad(n) ? "Yes" : "No") << endl;

    return 0;
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

struct modint{
    using i64=int_fast64_t;
    i64 a;
    static constexpr i64 MOD=1000000007;
    modint(){a=0;}
    modint(i64 a_){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        i64 n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y;
        y.a=a+x.a;
        if(y.a>MOD) y.a-=MOD;
        return y;
    }
    modint operator-(const modint& x){
        modint y;
        y.a=a-x.a;
        if(y.a<0) y.a+=MOD;
        return y;
    }
    modint operator*(const modint& x){
        modint y;
        y.a=(a*x.a)%MOD;
        return y;
    }
    modint operator/(const modint& x){
        modint y;
        y.a=(a*x.inv().a)%MOD;
        return y;
    }
    modint& operator+=(const modint& x){
        a+=x.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    modint& operator-=(const modint& x){
        a-=x.a;
        if(a<0) a+=MOD;
        return *this;
    }
    modint& operator*=(const modint& x){
        (a*=x.a)%=MOD;
        return *this;
    }
    modint& operator/=(const modint& x){
        (a*=x.inv().a)%=MOD;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    int_fast64_t a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(int_fast64_t a,int_fast64_t b){
    modint _;
    int_fast64_t n=1,A=a;
    while(b){
        if(b&1) (n*=A)%=modint::MOD;
        (A*=A)%=modint::MOD;
        b>>=1;
    }
    _.a=n;
    return _;
}

typedef pair<ll, ll> P;
map<ll, ll> mp;
vector<int> a(100001);

int main(){
    int n;
    cin >> n;
    modint ans = 1;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        a[tmp]++;
    }

    if(n%2==0){
        REP(i, n) if(a[i]!=2 && a[i] != 0){
            cout << "0" << endl;
            return 0; 
        }
    } else {
        if(a[0]!=1) {
            cout << "0" << endl;
            return 0;
        }
        REPN(i, 1, n) if(a[i] != 2 && a[i] != 0) {
            cout << "0" << endl;
            return 0;
        }
    }

    REP(i, n/2){
        ans *= 2;
    }

            cout << ans << endl;

    return 0;
}


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

int dp[500010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	string s;
	int N;
	cin >> N >> s;
	int last = 0;
	for(int i = 2; i < N; i++){
		dp[i] = dp[i - 1];
		if(s[i - 2] == '1' && s[i - 1] == '0' && s[i] == '1'){
			last = i;
			for(int j = i - 2; j >= 0; j--){
				if(s[j] == '0') break;
				dp[i] = max(dp[i], dp[j - 1] + i - j - 1);
			}
		}
		else if(s[i] == '0'){
			last = 0;
		}
		if(last){
			dp[i] = max(dp[i], dp[last - 3] + i - last + 1);
		}
	}
	cout << dp[N - 1] << endl;
}


Measured memory_bytes: 2844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String str = br.readLine();
            long sum = 0;
            for (int i = 0; i < str.length(); i++) {
                long temp = Long.parseLong(str.substring(i, i + 1));
                sum += temp;
            }
            if (Long.parseLong(str) % sum == 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 23124
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${rgL2iRE5WFMthrP7HjT3>?N)<}_ku(Re4Xo<ei7_PoeeIYAr>Re7X4svbbz}4a*thMpS|2M@Nhu^SJRG&La5R-_MVd5TB(Y}e-g4A8z7>{rm7z|E$~I}jxM)CX)$ZPMcZxmm33R;sO=Sd>Zc&zL0`A<XngW9@<N-c+C<PRg$e-GgQ@4!FFgA|a!0USnwGq|V%=l^yUZBWf=`<^+38WErFbde@Yt+c0;ym*%kY3GP?o9?a2%9aa$P(Y-9+q3UM0Wf)!ZWNe$^!b~5X%2Ed=UH{9pMA=s8{a``-X9^)!Zu@td9a$J_H{+h0}a>Q(6iGg)vReXuCU8jW(_-s%iI`B4voj#aPf#g8VN%k;t+A?KeZiBQ!ojZl$)I9#pn?lKfLG=rzKTxHbCAKq9@6y$BYEU~zQh52KB`-v")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 12960
#include<cstdio>
#include<cstdlib>
#define ll long long

char s[100010],t[100010];
ll m,n;

ll gcd(ll x,ll y)
{
	if(y==0) return x;
	return gcd(y,x%y);
}

int main()
{
	scanf("%lld %lld",&n,&m);
	scanf("%s",s);
	scanf("%s",t);
	if(s[0]!=t[0]) {printf("-1");return 0;}
	ll gd=gcd(n,m),l=n*m/gd;
	if(gd==1) {printf("%lld",l);return 0;}
	ll tt=l/n,ts=l/m,i=ts,j=tt;
	while(i<n && j<m)
	{
		if(s[i]!=t[j]) {printf("-1");return 0;}
		i+=ts;j+=tt;
	}
	printf("%lld",l);
}

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

const int uma[8] = {4, 1, 4, 1, 2, 1, 2, 1};
const int INF = 1e9;

int main() {
  vector<int> p(8);
  while (cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]) {
    int m;
    string ans;
    for (int i = 0; i < 8; ++i) {
      int s = 0;
      string c;
      for (int j = 0; j < 8; ++j) {
        c += '0' + uma[(i + j) % 8];
        s += max(0, p[j] - uma[(i + j) % 8]);
      }
      if (i == 0) {
        ans = c;
        m = s;
      } else if (s <= m) {
        ans = ( (s == m && stoi(ans) < stoi(c)) ? ans : c );
        m = min(m, s);
      }
    }
    for (int i = 0; i < 8; ++i) cout << ( (i) ? " " : "" ) << ans[i];
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int x = int.Parse(str[2]);

            double upper = Math.PI/2;
            double lower = 0;
            decimal cap = 0;
            double mid = 0;
            for(int i = 0; i<10000; i++)
            {
                mid = (upper + lower) / 2;

                double xx = Math.Tan(Math.PI / 2 - mid);
                double yy = Math.Tan(mid);
                if (b * xx <= a)
                {
                    cap = (decimal)(a * b * b * xx /2 );
                }
                else
                {
                    cap = (decimal)(a * a * b - a * a * a * yy /2);
                }

                if (cap < x)
                {
                    upper = mid;
                }
                else
                {
                    lower = mid;
                }
            }

            double theta = mid;
            double angle = theta * (180 / Math.PI);

            Console.Write(angle);

        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int count(int a,int b)
{
  int tmp=0;
  while(pow(2,tmp)*a<b){
    tmp=tmp+1;
  }
return tmp;
}

int main(){
  int N;cin>>N;
  int K;cin>>K;
  double p=0;
  int sum=0;
  if(K>N){
    for(int i=1;i<=N;i++){
      p=p+(double)1/(N*pow(2,count(i,K)));
    }
    cout<<setprecision(15)<<p<<endl;
  }
  else{
    p=(double)((double)(N-K+1)/N);
    for(int i=1;i<=K-1;i++){
      p=p+(double)1/(N*pow(2,count(i,K)));
    }
    cout<<setprecision(15)<<p<<endl;
  }

}

Measured memory_bytes: 256
a=input().split()
A=int(a[0])
B=int(a[1])
K=int(a[2])
if K>=A:
    K-=A
    A=0
    if K>=B:
        B=0
        print("0 0")
    else:
        B-=K
        print(str(A)+" "+str(B))
else:
    A-=K
    print(str(A)+" "+str(B))


Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
sum=0
c=0
for i in range(n):
  if a[i]<0:
    a[i]=a[i]*-1
    c=c+1
  sum=sum+a[i]
if c%2==0:
  print(sum)
else:
  print(sum-min(a)*2)

Measured memory_bytes: 14228
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

vector<vector<int>> graph(100010, vector<int>());
vector<bool> vis(100010);
vector<int> t(100010, -1);

void dfs(int n, int c, bool &ok) {
	t[n] = c;
	vis[n] = true;
	for (int i : graph[n]) {
		if (vis[i]) {
			if (t[i] == t[n]) {
				ok = false;
			}
			continue;
		}
		dfs(i, c ^ 1, ok);
	}
}


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

	int n, m;
	cin >> n >> m;
	vector<bool> check(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].pb(b);
		graph[b].pb(a);
		check[a] = true;
		check[b] = true;
	}
	int ans = n * n;
	int cnt = n;
	rep(i, n) {
		if (!check[i]) {
			cnt--;
			vis[i] = true;
		}
	}
	ans -= cnt * cnt;
	int x = 0, y = 0;
	rep(i, n) {
		bool oks = true;
		if (!vis[i]) {
			dfs(i, 0, oks);
			if (oks) x++;
			else y++;
		}
	}
	ans += 2 * x + y + 2 * x*(x - 1) + 2 * x*y + y * (y - 1);
	cout << ans << endl;
}

Measured memory_bytes: 12416
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, a, b, c, d;
int dp[2000];
//i人目までを入れて、今までの総和はj
int f[2000];
int g[2000];
int nCk(int n, int k) {
	return f[n] * g[k] % Mod * g[n - k] % Mod;
}
signed main() {
	cin >> n >> a >> b >> c >> d;
	dp[0] = 1;
	f[0] = 1;
	g[0] = 1;
	for (int i = 1; i < 2000; i++) {
		f[i] = f[i - 1] * i%Mod;
		g[i] = mod_pow(f[i], Mod - 2, Mod);
	}
	for (int i = a - 1; i < b; i++) {
		int t = i + 1;
		for (int j = n - 1; j >= 0; j--) {
			int k = c;
			for (int z = j + c * t; z <= n && z <= j + d * t; z += t) {
				int res = dp[j] * nCk(n - j, z - j) % Mod;
				res = res * f[z - j] % Mod;
				res = res * mod_pow(g[t], k, Mod) % Mod;
				res = res * g[k] % Mod;
				dp[z] += res;
				dp[z] %= Mod;
				k++;
			}
		}
	}
	cout << dp[n] << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

using taplis=tuple<int,int,int>;
struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int N,Q;

signed main(){
    cin>>N>>Q;

    priority_queue<taplis,vector<taplis>,greater<taplis>>que;
    rep(i,Q){
        int a,b,c;
        cin>>a>>b>>c;
        que.push(make_tuple(c,a,b));
    }

    UnionFindTree uf(N);
    int ans=0;
    while(que.size()){
        int c,a,b;
        tie(c,a,b)=que.top();
        que.pop();
        if(b==-1){
            if(uf.areSame(a,(a+1)%N));
            else{
                uf.unite(a,(a+1)%N);
                ans+=c;
                que.push(make_tuple(c+2,(a+1)%N,-1));
            }
        }
        else{
            if(!uf.areSame(a,b)){
                uf.unite(a,b);
                ans+=c;
            }
            que.push(make_tuple(c+1,a,-1));
            que.push(make_tuple(c+2,b,-1));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 17516
//  Bug Party.cpp
//  2013/01/17.

#if 1

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct Bug
{	ll a, b; Bug(ll a=0, ll b=0) : a(a), b(b) {} }; // a=放出量 b=許容量

bool cmpb(const Bug& l, const Bug& r)
{	return l.b > r.b; }

bool check(const vector<Bug>& bugs, ll n)
{
	ll foo = 0;
	priority_queue<ll> que;
	
	rep(i, n)
	{
		foo += bugs[i].a;
		que.push(bugs[i].a);
	}
	
	if((foo <= bugs[n-1].b * n) || (foo <= bugs[bugs.size()-1].b * n)) return true;
	
	REP(i, n, bugs.size())
	{
		if(que.top() > bugs[i].a)
		{
			foo -= que.top() - bugs[i].a;
			que.pop();
			que.push(bugs[i].a);
		}
		
		if(foo <= bugs[i].b * n) return true;
	}

	return false;
}

int main()
{
	int N;
	cin >> N;
	
	vector<Bug> bugs(N);
	rep(i, N) cin >> bugs[i].a >> bugs[i].b;
	
	sort(ALL(bugs), cmpb);

	ll ok = 0;
	for(ll ub = N+1; ub - ok > 1; )
	{
		ll mid = (ok + ub) / 2;
		
		if(check(bugs, mid)) ok = mid;
		else ub = mid;
	}
	
	cout << ok << endl;
}

#endif

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




int main()
{
    int a[5];
    int ans=0;
    for(int i=0;i<5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            ans = ++i;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a,p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
}


Measured memory_bytes: 256
N=int(input())

prime_factorization={}
for i in range(1,N+1):
	d=2
	orig=i
	while d< (int(orig**0.5)+1):
		while i%d==0:
			i=i//d
			if d in prime_factorization:
				prime_factorization[d]+=1
			else:
				prime_factorization[d]=1
		d+=1
	if i>1:
		if i in prime_factorization:
			prime_factorization[i]+=1
		else:
			prime_factorization[i]=1

greater2=0
greater4=0
greater14=0
greater24=0
greater74=0
for i in prime_factorization:
	if prime_factorization[i]>=2:
		greater2+=1
	if prime_factorization[i]>=4:
		greater4+=1
	if prime_factorization[i]>=14:
		greater14+=1
	if prime_factorization[i]>=24:
		greater24+=1
	if prime_factorization[i]>=74:
		greater74+=1
combi3=((greater4*(greater4-1))//2)*(greater2-2)
combi2=(greater14)*(greater4-1) + (greater24)*(greater2-1)
combi1=greater74
print(combi1+combi2+combi3)

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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long int
#define mod (long long)(1e9+7)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi (acos(-1))
#define F first
#define S second

ll fp(ll n , ll p )
{
    if(p==0)
        return 1;
    if(p==1)
        return n ;
    ll res = fp(n,p/2)%mod ;
    res=((res)*(res))%mod ;
    if(p%2)
        res=(res*n)%mod ;
    return res ;
}


bool com(pair<ll,ll> &a , pair<ll,ll> &b)
{
    return (a.S > b.S);
}
ll n , m , arr[100005] , ans = 0 , sum = 0;
pair<ll , ll > brr[100005] ;
int main()
{
    ENGZ;
    cin>>n >>m ;
    for(int i=0 ; i<n ; i++)
    {
        cin>>arr[i] ;
    }
    for(int i=0 ; i<m ; i++)
    {
        cin>>brr[i].S >> brr[i].F ;
    }
    sort(arr,arr+n);
    sort(brr,brr+m);
    reverse(brr,brr+m);
    ll i = 0 , cur = 0 ;

    while(i < n && cur < m)
    {
        if(brr[cur].S)
        {
            arr[i] = max(arr[i] , brr[cur].F);
            i++ ;
            brr[cur].S -- ;
            if(brr[cur].S == 0)cur++ ;
        }
    }
    for(int i=0 ; i<n ; i++)
        ans+= arr[i];
    cout<<ans <<endl ;
    return 0;
}


Measured memory_bytes: 5940
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int n;

int main(){
    cin >> n;
    string s;
    cin >> s;
    int l = n;
    vector<int> b(n,0);
    vector<int> w(n,0);
    vector<int> sb(n+1,0);
    vector<int> sw(n+1,0);
    vector<int> bp;
    REP(i,n){
        if(s[i]=='.'){
            w[i]=1;
        }else{
            bp.push_back(i);
            b[i]=1;
        }
    }
    REP(i,n){
        sw[i+1] = sw[i]+w[i];
        sb[i+1] = sb[i]+b[i];
        
    }
    /*REP(i,n){
        if(b[i]==1){
            int temp = sb[i]-sb[0] + sw[n]- sw[i];
            chmin(res,temp);
        }
    }*/
    int res = bp.size();
    REP(i,bp.size()){
        int temp = i + sw[n]-sw[bp[i]];
        chmin(res,temp);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N, std::vector<long long> A){
    ll sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += A[i];
    }
    ll tmp = 0;

    ll ans = 10000000000000000;
    for (int i = 0; i < N; i++)
    {
        tmp += A[i];

        ans = min(ans,abs(tmp-(sum-tmp)));
    }

    cout << ans << endl;
    
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

string revzzz(char c,int x){
	string ans="";
	for(;x>0;x--){
		ans+=c;
	}

	return ans;
}
int32_t main()
{
	c_p_c();

			string s;cin>>s;

			int j=0;

			int cnt=0;
			int ans=0;
			
			for(int i=0;i<s.length();i++){
					j = i;
				while(j<s.length() && s[j] == 'R'){
					j++;
				}

				ans = max(ans,j-i);
				i=j;
			}

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

Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
	int s[10];
	int sum,j,i,k;
	for(i=0;i<=9;i++){
		scanf("%d",&s[i]);
	}
	sum=0;
	for(j=0;j<=9-1;j++){
		for(k=j+1;k<=9;k++){
			if(s[j]<=s[k]){
				sum=s[j];
				s[j]=s[k];
				s[k]=sum;
			}
		}
	}
	
	printf("%d\n",s[0]);
	printf("%d\n",s[1]);
	printf("%d\n",s[2]);
	return 0;
}


Measured memory_bytes: 2108
from collections import deque

n, k = map(int,input().split())
r, s, p = map(int,input().split())
t = input()

d = {"s":r, "p":s, "r":p}
before = deque([])
ans = 0
for i in range(n):
    if i<k:
        before.append(t[i])
        ans += d[t[i]]
    else:
        b = before.popleft()
        if t[i]!=b:
            before.append(t[i])
            ans += d[t[i]]
        else:
            before.append("n")
print(ans)

Measured memory_bytes: 9944