akhauriyash/Code-Regression huggingface dataset:
n = int(input())
lst = [list(map(int, input().split())) for i in range(n)]

dp = [lst[0]] + [[0] * 3 for i in range(n - 1)]

for i in range(1, n):
    for j in range(3):
        for k in range(3):
            if j == k:
                pass
            else:
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + lst[i][j])

print(max(dp[n - 1]))


Measured memory_bytes: 47336
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DAtCoderExpress2 solver = new DAtCoderExpress2();
        solver.solve(1, in, out);
        out.close();
    }

    static class DAtCoderExpress2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int m = in.nextInt();
            int q = in.nextInt();
            int[][] dp = new int[n + 1][n + 1];
            int[][] sum = new int[n + 1][n + 1];
            for (int i = 0; i < m; i++) {
                dp[in.nextInt()][in.nextInt()]++;
            }

            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + dp[i][j];
                }
            }

            for (int i = 0; i < q; i++) {
                int l = in.nextInt();
                int r = in.nextInt();
                out.println(sum[r][r] - sum[l - 1][r] - sum[r][l - 1] + sum[l - 1][l - 1]);
            }


        }

    }
}



Measured memory_bytes: 156016
#include <iostream>
#include <map>
#define int long long
using namespace std;

int a[55];
map<int, map<int, int> > f;

signed main() {
#ifdef _DEBUG
	freopen("_in" , "r", stdin );
	//freopen("_out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n, x; cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] -= x;
	}
	f[0][0] = 1;
	for (int i = 1; i <= n; i++)
	for (int j = -250; j <= 250; j++) {
		f[i][j] += f[i - 1][j - a[i]] + f[i - 1][j];
	}
	cout << f[n][0] - 1 << '\n';
}


Measured memory_bytes: 2048
n,m = list(map(int,input().split()))
l = []
for i in range(m): l.append(list(map(int,input().split())))
p = list(map(int,input().split()))

res = 0
for bit in range(1 << n):
  flag = 0
  for i in range(m):
    count = 0
    for j in range(1, l[i][0]+1):
      if (1 << (l[i][j] - 1)) & bit:
        count += 1
      else:
        pass
    if count % 2 == p[i]:
      flag = 1
    else:
      flag = 0
      break
  if flag:
    res += 1
  else:
    pass

print(res)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        int ans = 0;
        int count = 1;
        for (int i = 0; i < n; i++) {
            if(a[i] == count) {
                count++;
            } else {
                ans++;
            }
        }
        if(ans == n) {
            System.out.println(-1);
        } else {
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 60428
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MD=int(1e9)+7;
void madd(int &x,int y) {
	x+=y;
	if (x>=MD) x-=MD;
}
void msub(int &x,int y) {
	x-=y;
	if (x<0) x+=MD;
}

int const MAXN=2200;
int S[MAXN],T[MAXN];
int f[MAXN][MAXN];
int N,M;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>N>>M;
	rep(i,0,N) cin>>S[i];
	rep(i,0,M) cin>>T[i];
	
	rep(i,0,N+1) f[i][0]=1;
	rep(j,0,M+1) f[0][j]=1;
	
	rep(i,0,N) rep(j,0,M) {
		madd(f[i+1][j+1],f[i][j+1]);
		madd(f[i+1][j+1],f[i+1][j]);
		if (S[i]!=T[j]) msub(f[i+1][j+1],f[i][j]);
	}
	cout<<f[N][M]<<"\n";
}


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e5 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

int n, we;
int dp[11111], w[111], v[111];

int main() {
    cin >> n >> we;
    for(int i = 1; i <= n; i ++)
        cin >> v[i] >> w[i];
    for(int i = 1; i <= n; i ++) {
        // cout << '\n';
        for(int j = we; j >= 1; j --) {
            // dp[j] = max(dp[j], dp[j + 1]);
            if(j - w[i] >= 0)
                dp[j] = max(dp[j],dp[j - w[i]] + v[i]);
            //cout << dp[j] << ' ';
        }
    }
    int res = 0;
    for(int j = we; j >= 1; j --)
        res = max(res, dp[j]);
    cout << res << '\n';
    return 0;
}



Measured memory_bytes: 3144
using System;

class Program
    {
      static void Main(string[] args)
      {
        var line = Console.ReadLine().Split();

        if (line[0] == line[1])
        {
            Console.WriteLine(line[2]);
        }
        else if (line[0] == line[2])
        {
            Console.WriteLine(line[1]);
        }
        else Console.WriteLine(line[0]);
       
         
      }
    }

Measured memory_bytes: 13140
MOD = 10**9 + 7
class mint:
    def __init__(self, i):
        self.i = i
    def __add__(self, m):
        t = self.i + (m.i if isinstance(m, mint) else m)
        if t > MOD:
            t -= MOD
        return mint(t)
    def __radd__(self, m):
        t = self.i + (m.i if isinstance(m, mint) else m)
        if t > MOD:
            t -= MOD
        return mint(t)
    def __mul__(self, m):
        return mint(self.i * (m.i if isinstance(m, mint) else m) % MOD)
    def __sub__(self, m):
        t = self.i - (m.i if isinstance(m, mint) else (m % MOD))
        if t < 0:
            t += MOD
        return mint(t)
    def __pow__(self, m):
        i = self.i
        return mint(pow(i, m, MOD))
    def __truediv__(self, m):
        return mint(self.i * pow(m, MOD - 2, MOD) % MOD)
    def __repr__(self):
        return repr(self.i)

fact_range = 10**6
facts = [1] * (fact_range + 1)
for i in range(0, fact_range):
    facts[i+1] = facts[i] * (i + 1) % MOD

ifacts = [1] * (fact_range + 1)
ifacts[fact_range] = pow(facts[fact_range], MOD - 2, MOD)
for i in range(fact_range, 0, -1):
    ifacts[i-1] = ifacts[i] * i % MOD

def comb(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return facts[n] * ifacts[n-k] % MOD * ifacts[k] % MOD

n, m = map(int, input().split())
d = []
p = 2
while p < 10 ** 5:
    cnt = 0
    while m % p == 0:
        m //= p
        cnt += 1
    if cnt > 0:
        d.append(cnt)
    p += 1
if m > 1:
    d.append(1)
ans = mint(1)
for c in d:
    ans *= comb(n - 1 + c, c)
print(ans)


Measured memory_bytes: 82164
import sys
N, Y = map(int, input().split())

for x in range(N+1):
  for y in range(N+1):
    z = N-(x+y)
    if z >= 0:
      if 10000*x + 5000*y + 1000*z == Y:
        print(x,y,z)
        sys.exit()

print(-1,-1,-1)

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


int main(){
  int N;
  cin >> N;
  int A[2][N];
  for (int i=0;i<N;i++) cin >> A[0][i];
  for (int i=0;i<N;i++) cin >> A[1][i];
  
  int dp[2][N+1];
  dp[1][N-1] = A[1][N-1];
  dp[0][N] = 0;
  for (int i=N-2;i>=0;i--){
    dp[1][i] = dp[1][i+1] + A[1][i];
  }
  for (int i=N-1;i>=0;i--){
    dp[0][i] = max(dp[1][i], dp[0][i+1]) + A[0][i];
  }

  cout << dp[0][0] << endl;

}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll n;
  while(cin>>n,n){
  ll sum=0;
  ll a[11111];
  for(int i=0;i<n;i++){
	cin>>a[i];
	sum+=a[i];
  }
  ll cnt=0;
  for(int i=0;i<n;i++){
	if(a[i]<=sum/n)cnt++;
  }
  cout<<cnt<<endl;
  }
  return 0;
}



Measured memory_bytes: 3192
//author:luckYrat(twitter:@luckYrat_)

//#include <bits/stdc++.h>
//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>



using namespace std;

typedef pair<int,int> Paint;
typedef long long ll;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD 1000000007

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  long long T1,T2;cin>>T1>>T2;
  long long A1,A2;cin>>A1>>A2;
  long long B1,B2;cin>>B1>>B2;
  if(A1<B1){
    swap(A1,B1);
    swap(A2,B2);
  }
  

  if(A1==B1 || A2==B2){
    cout << 0 << endl;
    return 0;
  }
  
  if((A1*T1)+(A2*T2) == (B1*T1)+(B2*T2)){
    cout << "infinity" << endl;
    return 0;
  }
  long long nw = 0;
  long long nw2 = 0;
  nw = nw2+T1*(A1-B1);
  if(nw < 0){
    cout << 0 << endl;
    return 0;
  }
  nw2 = nw+T2*(A2-B2);
  if(nw2 > 0){
    cout << 0 << endl;
    return 0;
  }
  long long ans = (nw/(nw2*-1)+(nw%(nw2*-1)==0?0:1))*2;
  //cout << ans << endl;
  nw2 = (nw-nw2);
  //cout << (nw-nw2)*(ans/2)+nw << endl;
  if((nw-nw2)*(ans/2)+nw < 0){
    ans--;
  }
  cout << ans << endl;



}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main()
{
  ll x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p(a), q(b), r(c);
  vector<ll> sr(c + 1), spq(x + y + 1);
  REP(i, a) {
    cin >> p[i];
  }
  REP(i, b) {
    cin >> q[i];
  }
  REP(i, c) {
    cin >> r[i];
  }
  sort(RALL(p));
  sort(RALL(q));
  sort(RALL(r));
  sr[0] = 0;
  REP(i, c) {
    sr[i + 1] = sr[i] + r[i];
  }

  spq[0] = 0;
  ll cx = 0, cy = 0;
  FOR(i, 1, x + y + 1) {
    if (cx == x) {
      spq[i] = spq[i - 1] + q[cy];
      cy++;
    } else if (cy == y) {
      spq[i] = spq[i - 1] + p[cx];
      cx++;
    } else if (p[cx] > q[cy]) {
      spq[i] = spq[i - 1] + p[cx];
      cx++;
    } else {
      spq[i] = spq[i - 1] + q[cy];
      cy++;
    }
  }
  ll ans = 0;
  REP(i, x + y + 1) {
    if (i > c) continue;
    ans = max(ans, sr[i] + spq[x + y - i]);
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    for(int i=0; i < s.size(); ++i){
        if(s[i] == '1'){
            cout << 9;
        }else if(s[i] == '9'){
            cout << 1;
        }else{
            cout << s[i];
        }
    }

    cout << endl;
}

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

MOD = 10**9 + 7

# dp[s][i][j][k] = str[s:s+3]が(i,j,k)となる個数の数え上げ
dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(N-2)]

# 初期条件
for i in range(4):
    for j in range(4):
        for k in range(4):
            if i==0 and j==1 and k==2: continue #AGC
            if i==0 and j==2 and k==1: continue #ACG
            if i==1 and j==0 and k==2: continue #GAC
            dp[0][i][j][k] = 1

# 先頭から末尾に向けてループ
for i in range(N-3):
    # 確定している文字列 (ppp,pp,p)
    for ppp in range(4):
        for pp in range(4):
            for p in range(4):
                # 次の文字 (n)
                for n in range(4):
                    if pp==0 and p==1 and n==2: continue #AGC
                    if pp==0 and p==2 and n==1: continue #ACG
                    if pp==1 and p==0 and n==2: continue #GAC
                    if ppp==0 and p==1 and n==2: continue #A?GC
                    if ppp==0 and pp==1 and n==2: continue #AG?C
                    dp[i+1][pp][p][n] += dp[i][ppp][pp][p]
                    dp[i+1][pp][p][n] %= MOD

ans = 0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans = (ans + dp[-1][i][j][k]) % MOD
print(ans)

Measured memory_bytes: 3316
n, m = map(int, input().split())
l = [input().split() for i in range(n)]

x = set()

if len(l) == 1:
    print(len(l[0])-1)
else:
    x = set(l[0][1:])
    for i in range(1, len(l)):
        x = x & set(l[i][1:])
    print(len(x))


Measured memory_bytes: 3060
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int cnt = 0;
    for (int i = 1; i < n - 1; i++) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) ||
            (p[i - 1] > p[i] && p[i] > p[i + 1])) {
            cnt += 1;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

/*
template<class T>
struct node {
	T value;
	node *lp, *rp;
	node()
		:value{}
		, lp{nullptr}
		, rp{nullptr}
	{}
};
*/

using sll = signed long long;

template<class T>
auto left(const std::vector<T>&tab, int parent_index) {
//	++parent_index;
	auto left_index = 2 * parent_index + 1;
	auto b =
		static_cast<decltype(tab.size())>
		(left_index) < tab.size();
	return
		std::make_pair(b, tab[b?left_index:parent_index]  );
}

template<class T>
auto right(const std::vector<T>&tab, int parent_index) {
//	++parent_index;
	auto right_index = 2 * (parent_index + 1) ;
	auto b = 
		static_cast<decltype(tab.size())>
		(right_index) < tab.size();
	return
		std::make_pair(b, tab[b ? right_index : parent_index]);
}

template<class T>
auto parent(const std::vector<T>&tab, int child_index) {
//	++child_index;
	auto parent_index = (child_index+1) / 2 -1;
	auto b = parent_index != child_index && 0 <= parent_index;
	return
		std::make_pair(b, tab[b ? parent_index : child_index]);
}


int main() {

	int H;//heap size
	std::cin >> H;
	std::vector<sll> tab(H, sll{});

	
	for (auto&e:tab)
		std::cin >> e;
	
	for (int i{}; i < H; ++i) {
		std::cout << "node " << i + 1
			<< ": key = " << tab[i] << ", ";

		auto par = parent(tab, i);
		if (par.first)
			std::cout << "parent key = " << par.second << ", ";

		auto lv = left(tab, i);
		if (lv.first)
			std::cout << "left key = " << lv.second << ", ";

		auto rv = right(tab, i);
		if (rv.first)
			std::cout << "right key = " << rv.second <<", ";

		std::cout << "\n";
	}

	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
    int H, W, dx[8] = { -1,0,1,-1,1,-1,0,1 }, dy[8] = { -1,-1,-1,0,0,1,1,1 };
    char S[50][50],ans[50][50];
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> S[i][j];
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int c = 0;
            for (int k = 0; k < 8; k++)
            {
                if (j + dx[k] >= 0 && i + dy[k] >= 0 && j + dx[k] < W&&i + dy[k] < H) {
                    if (S[i + dy[k]][j + dx[k]] == '#')c++;
                }
            }
            ans[i][j] = c + '0';
            if (S[i][j] == '#')ans[i][j] = '#';
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << ans[i][j];
        }
        cout << endl;
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    int a;
    string s;

    cin >> a >> s;

    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
   

    
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 256
N = int(input())
s = [int(i) for i in input().split()]

ret = 0
for c in range(1, N) :
    k = 1
    tmp = 0
    flag = (N - 1) % c == 0
    while c * k < N - 1 :
        l = c * k
        r = N - 1 - l

        if (flag and r <= l) or r <= c:
            break

        tmp += s[l] + s[r]
        ret = max(ret, tmp)
        k += 1

print(ret)


Measured memory_bytes: 63216
D, G = map(int, input().split())
pc = []
for i in range(D):
    pc.append(list(map(int, input().split())))


def convert(n):
    Bin = []
    while n != 0:
        a = n % 2
        n //= 2
        Bin.insert(0, a)
    if not Bin:
        Bin.append(0)
    return Bin


Min = 10**8
for i in range(0, 2**D):
    Bin = [str(s) for s in convert(i)]
    Bin = ''.join(Bin).zfill(D)
    idx = 0
    ct = 0
    score = 0
    for j in Bin:
        if j == '1':
            p, c = pc[idx]
            ct += p
            score += 100*(idx+1)*p+c
        if score >= G:
            Min = ct if ct < Min else Min
            break
        idx += 1
    if score < G:
        Bin = Bin[::-1]
        idx = 0
        for j in Bin:
            if j == '0':
                p, c = pc[idx]
                for k in range(p-1):
                    ct += 1
                    score += 100*(D-idx)
                    if score >= G:
                        Min = ct if ct < Min else Min
                        break
                score -= 100*(D-idx)*(p-1)
                ct -= (p-1)
            if score >= G:
                break
            idx += 1

print(Min)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    long long n, m, one, k = 1;
    cin >> n >> m;
    one = 100 * (n - m) + 1900 * m;
    for (int i = 0; i < m; i++)
        k *= 2;
    one *= k;
    cout << one << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int a,p; cin>>a>>p;
    OUT((a*3+p)/2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 998244353
const int INF = 1LL<<30;

void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}
 
int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}
 
int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}
 
int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}
 
vector<int64_t> fact, fact_inv;
 
void create_mod_tables(int num){
    fact.assign(num+1, 1);
    fact_inv.assign(num+1, 1);
    for(int i=1; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[num] = inv_mod(fact[num]);
    for(int i=num; i>0; i--) fact_inv[i-1] = fact_inv[i] * i % MOD;
}
 
int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}
 
int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}


int main() {
    int N,M,K;
    cin>>N>>M>>K;
    create_mod_tables(300000);

    int64_t ans=0;
    for(int i=0;i<=K;i++){
        int64_t res=comb_mod(N-1,i);
        int num=N-i;
        mul(res,M);
        mul(res,power_mod(M-1,num-1));
        add(ans,res);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 7924
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(0, 0); }
	V<V<pin>> qab(2);
	int sz = ab.size();
	qab[0].reserve(sz);
	qab[1].reserve(sz);
	for (pin& x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	int c = 0;
	for (pin& x : qab[0]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
	if (!c) {
		pin ans = solve(qab[1], ex - 1);
		ans.first *= 2; ans.second *= 2; ans.second++;
		return ans;
	}
	pin ans = solve(qab[0], ex - 1);
  	c=0;
  	for (pin& x : qab[1]) {
		int qc = (2 * x.first + x.second) % 3;
		c ^= (qc + 1);
	}
  	if (!c) {
		ans.first *= 2; ans.second *= 2;
		return ans;
	}
	c = 0;
	for (pin& x : qab[1]) {
		int w = ans.second - x.second-1;
		if ((w & x.first) == w) { c ^= 1; }
	}
	ans.first *= 2; ans.first++; ans.second *= 2; ans.second -= c;
	return ans;
}
signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long inf = 1e17;
	int n; cin >> n;
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 59);
	cout << ret.first - inf << " " << ret.second - inf << "\n";
}


Measured memory_bytes: 10632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<ll> c(N),v(N);
    rep(i,0,N) cin >> c[i];

    int Q;
    cin >> Q;
    rep(i,0,Q){
        int t,x;
        ll d;
        cin >> t >> x >> d;
        x--;
        if(t == 1){
            v[x] += d;
            if(v[x] > c[x]){
                cout << x + 1 << endl;
                return 0;
            }
        }else if(t == 2){
            v[x] -= d;
            if(v[x] < 0){
                cout << x + 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;

    return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define ll long long
using namespace std;
int main(void){
    string s;
    cin>>s;
    string a,b,c,d,e;
    int l=s.length();
    rep(i,(l-1)/2){
        a+=s[i];
        b+=s[(l-1)/2-i-1];
        c+=s[(l+3)/2+i-1];
        d+=s[l-1-i];
    }
    rep(i,l)e+=s[l-i-1];
    // cout<<l<<endl<<a<<endl<<b<<endl<<c<<endl<<d<<endl;
    if(a==b&&c==d&&s==e)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
struct Z { int opp,l,r; ll full; };
bool operator<(const Z &a,const Z &b) { return a.full>b.full; }

int n,lim;
Z z[MAXN];

ll zfullsum[MAXN+1];

bool can(ll t,ll need) {
	ll nfull=t/lim; ll rem=t%lim;
	if(nfull>=n) return zfullsum[n]>=need;
	REP(i,n) {
		ll cur;
		if(i<nfull) {
			cur=zfullsum[nfull+1]-z[i].full;
		} else {
			cur=zfullsum[nfull];
		}
		cur+=min(rem,(ll)z[i].opp)*z[i].l;
		cur+=max(0LL,rem-z[i].opp)*z[i].r;
		if(cur>=need) return true;
	}
	return false;
}

ll solve() {
	ll need=0; REP(i,n) need+=(ll)z[i].opp*z[i].l;
	REP(i,n) z[i].full=(ll)z[i].opp*z[i].l+(ll)(lim-z[i].opp)*z[i].r;
	sort(z,z+n);
	zfullsum[0]=0; REP(i,n) zfullsum[i+1]=zfullsum[i]+z[i].full;

	ll l=-1,h=(ll)lim*n;
	while(l+1<h) {
		ll m=l+(h-l)/2;
		if(can(m,need)) h=m; else l=m;
	}
	return h;
}

void run() {
	scanf("%d%d",&n,&lim);
	REP(i,n) scanf("%d%d%d",&z[i].opp,&z[i].l,&z[i].r);
	printf("%lld\n",solve());
}

int main() {
	run();
	return 0;
}


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

int main() {
    int n;
    long long sum=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
    {
        for(int j = i+1;j<n;j++)
        {
            sum+= a[i]*a[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void Nomura2020C();

#if 1
int main()
{
	Nomura2020C();
	fflush(stdout);
	return 0;
}
#endif

static void Nomura2020C()
{
	int N;
	getint(N);

	std::vector<LLONG> leaves(N + 2, 0);
	for (int i = 0; i <= N; i++) {
		getint(leaves[i]);
	}
	if (N == 0) {
		if (leaves[0] == 1) {
			printf("1\n");
			return;
		}
		else {
			printf("-1\n");
			return;
		}
	}

	if (leaves[0] != 0) {
		printf("-1\n");
		return;
	}

	std::vector<LLONG> sumLeaves(N + 2, 0);
	sumLeaves[N] = leaves[N];
	for (int i = N - 1; i >= 0; i--) {
		sumLeaves[i] = sumLeaves[i + 1] + leaves[i];
	}

	std::vector<LLONG> nodes(N + 2, 0), needNodes(N + 2, 0);
	nodes[0] = 1;
	for (int depth = 1; depth <= N; depth++) {
		nodes[depth] = (nodes[depth - 1] - leaves[depth - 1]) * 2LL;
		if (depth == N) {
			if (nodes[depth] < leaves[depth]) {
				printf("-1\n");
				return;
			}
			nodes[depth] = leaves[depth];
		}
		else {
			if (nodes[depth] <= leaves[depth]) {
				printf("-1\n");
				return;
			}
			nodes[depth] -= leaves[depth];
			nodes[depth] = std::min(sumLeaves[depth + 1], nodes[depth]);
			nodes[depth] += leaves[depth];
		}
	}
	
	LLONG ans = 0;
	for (auto it = nodes.begin(); it != nodes.end(); it++) {
		ans += *it;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 6436
//A,Elebereth Gilthoniel mantae!
//For Temeria!
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
#include<stack>
#include<queue>
#include<cstring> 
using namespace std;
long long dp[3005][3005][3];
long long n,m; long long mo=1e9+7;
int main()
{
 	//freopen("","r",stdin);
	//freopen("","w",stdout);
	cin>>n>>m;
	for(long long i=0;i<=n-1;i++) 
	{
		dp[1][i][0]+=1;
	}
	dp[1][n][1]+=1;
//	for(int i=1;i<=m+1;i++) dp[i][n][1]+=1;
	for(long long i=1;i<=m;i++)
	{
		for(long long j=0;j<=n;j++)
		{
			dp[i][j][0]%=mo,dp[i][j][1]%=mo;
			if(j==n-1) dp[i+1][j+1][1]+=dp[i][j][0];
		//	if(j==1) dp[i+1][j-1][1]+=dp[i][j][0];
			//if(j==0) dp[i+1][j][1]+=dp[i][j][0];
			if(j==n-1) dp[i+1][j][1]+=dp[i][j][0];
			/////////////////////////////////
			if(j>0)dp[i+1][j][1]+=dp[i][j][1];
			if(j<n)dp[i+1][j][1]+=dp[i][j][1];
			if(j>0)dp[i+1][j-1][1]+=dp[i][j][1];
			if(j<n)dp[i+1][j+1][1]+=dp[i][j][1];
			/////////////////////////////////
			if(j>0)dp[i+1][j][0]+=dp[i][j][0];
			if(j<n-1)dp[i+1][j][0]+=dp[i][j][0];
			if(j>0)dp[i+1][j-1][0]+=dp[i][j][0];
			if(j<n-1)dp[i+1][j+1][0]+=dp[i][j][0];//cout<<dp[2][0][1]; system("pause");
		}
	}
	long long ans=0;
	for(long long i=0;i<=n;i++)
	{
		ans+=dp[m+1][i][1];
	}cout<<ans%mo<<endl;
	return 0;
}

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

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

  int total = 0;

  for (int i = 0; i < N; i++) {
      int l;
      int r;
      cin >> l >> r;
      total += r-l+1;
}
cout << total << endl;

}


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

namespace Getting_Started
{
    class Greatest_Common_Divisor
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = A[0];
            int y = A[1];
            int gcd;
            while(true)
            {
                if (x >= y)
                {
                    x = x % y;
                    if (x == 0) { gcd = y; break; }
                }
                else
                {
                    y = y % x;
                    if (y == 0) { gcd = x; break; }
                }
            }
            Console.WriteLine(gcd);
        }
    }
}

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

n = int(input())

tree = [[] for _ in range(n)]
for i in range(n-1):
    u, v, w = list(map(int, input().split()))
    u, v = u-1, v-1

    tree[u].append((v, w))
    tree[v].append((u, w))

check = [0 for _ in range(n)]
color = [-1 for _ in range(n)]
color[0] = 0
check[0] = 1


queue = [0]
while(len(queue) > 0):
    index = queue.pop()
    tree_tmp = tree[index]
    for next_, weight in tree_tmp:
        # print(color)
        if color[next_] == -1:
            if weight % 2 == 0:
                color[next_] = color[index]
            else:
                color[next_] = (color[index]+1) % 2
            queue.append(next_)


[print(i) for i in color]


Measured memory_bytes: 44196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 100010
int h[N];
int ma[N];
int main()
{
	int n;
	int m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>h[i];
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		ma[a]=max(ma[a],h[b]);
		ma[b]=max(ma[b],h[a]);
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans+=h[i]>ma[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4408
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=1e6+5;

ll m=998244353,dp1[N],dp2[N],ans=0,dp3[N],inv;

ll p(ll a,ll b)
{
	ll r=1;
	while(b)
	{
		if(b%2)r=(r*a)%m;
		a=(a*a)%m;
		b/=2;
	}
	return r;
}

ll sq(ll n)
{
	return (n*n)%m;
}

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
inv=p(2,m-2);
rep(i,0,n-1)
{
	int x;
	cin>>x;
	dp1[x]=(dp1[x]+x)%m;
	dp2[x]=(dp2[x]+sq(x))%m;
}

rep(i,1,N)
{
	for(int j=2*i;j<=N;j+=i)
	{
		dp1[i]=(dp1[i]+dp1[j])%m;
		dp2[i]=(dp2[i]+dp2[j])%m;
	}
}



rep(i,1,N)
{
	dp3[i]=((sq(dp1[i])-dp2[i])*inv)%m;
}
//ol(inv);on;
//rep(i,1,6)
//{
//	o2(i,((sq(dp1[i])-dp2[i])*inv)%m);os;o2(dp2[i],dp3[i]);on;
//}

//rep(i,1,7)
//{
//	o2(i,dp3[i]);on;
//}

ren(i,N,1)
{
	for(int j=2*i;j<=N;j+=i)
	{
		dp3[i]=(dp3[i]-dp3[j])%m;
	}
}

rep(i,1,N)
{
	ans=(ans+dp3[i]*p(i,m-2))%m;
}

ans=(ans+m)%m;
ol(ans);

return 0;
}



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

using namespace std;

int main()
{
    string s, ans="";
    cin>>s;
    for (int i=0; i<s.size(); i++)
    {
        if (s[i]=='0') ans+='0';
        if (s[i]=='1') ans+='1';
        if (s[i]=='B' && ans.size()!=0) ans=ans.substr(0, ans.size()-1);
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
    */
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
         
    		#include<bits/stdc++.h>
            using namespace std;
            typedef long long int  ll;
            typedef long double ld;
            #define ff first
            #define ss second
            #define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define endl "\n"
            #define pb push_back
    		#define F(i,n) for(ll i=0;i<n;i++)
            #define MOD 1000000007
            #define MAX 200005
            #define sz size()
            const ll N=100;
            ll i,j,k;
    signed main(){
    	FAST;
    	ll h,a;
    	cin>>h>>a;
    	ll ans;
    	ans =ceil(h/(ld)a);
    	cout<<ans;
    
    }



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  ll Min = LINF;
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  Min = min(Min, x * a + y * b);
  if (x <= y)
    Min = min(Min, x * c * 2 + b * (y - x));
  else
    Min = min(Min, y * c * 2 + a * (x - y));
  Min = min(Min, max(x, y) * 2 * c);
  cout << Min << endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Monad

solve :: [Int] -> String
solve xs = if any odd xs then "first" else "second"

readLine:: IO [Int]
readLine = fmap (map read . words) getLine

readLines :: Int -> IO [[Int]]
readLines = flip replicateM readLine
    
main :: IO() 
main = do
    [n] <- readLine
    l <- readLines n
    let ans = solve (concat l)
    putStrLn ans


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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(), a.end()

const int maxn = 200010;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
int n, m, a[maxn];
string s, ss;

vector<int> adj[maxn];
bool vis[maxn];
int nodes;

void dfs(int s)
{
    vis[s]=true;
    nodes++;
    for(auto u : adj[s])
    {
        if(vis[u])continue;
        dfs(u);
    }
}

void solve()
{
    cin >> n >> m;
    fill(vis, vis+n+2, false);
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int ans=0;
    for(int i = 1; i <= n; i++)
    {
        if(vis[i]) continue;
        nodes=0;
        dfs(i);
        ans=max(ans, nodes);
    }
    cout << ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t=1;
    //cin >> t;
    while(t--) solve();
}


Measured memory_bytes: 20972
/**
 *      ABC 68 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-04 23:26:52
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    cout << "ABC" << N << endl;
    
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

int mod = 1e9 + 7;

int dp[205][123456];
int fac[205];

int main() {
	fac[0] = 1;
	FOR(i,1,205) fac[i] = (i * 1LL * fac[i-1]) % mod;
	make2(n, x);
	makev(v, n);
	sort(all(v));
	FOR(i,0,x+1) dp[0][i] = i%v[0];

	FOR(i,1,n) {
		int ja = v[i];
		FOR(j,0,x+1) {
			dp[i][j] = (dp[i-1][j%ja] + dp[i-1][j] * 1LL * i)%mod;
		}
	}
	printf("%d\n", dp[n-1][x]);
}






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

int main(){
  int N,M;
  cin>>N>>M;
  int X[M];
  for(int i=0;i<M;i++){
    cin>>X[i];
  }
 sort(X, X + M);
  vector<int> tmp;
  int ans=0;
  for(int i=0;i<M-1;i++){
    tmp.push_back(X[i+1]-X[i]);
  }
  sort(tmp.begin(),tmp.end());
  for(int i=0;i<M-N;i++){
    ans+=tmp[i];
}
cout<<ans<<endl;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)
int main(void)
{
    lli N, A, B;
    scanf("%lld %lld %lld", &N, &A, &B);
    lli *ball;
    ball = (lli *)malloc(sizeof(lli) * N);
    lli total = A + B;
    lli count = 0;
    count = (lli)N/total;
    count *= A;
    if(N%total<=A&&A>0){
        count = count + N%total;
    }else if(N%total>A&&N%total<total&&A>0){
    	count = count + A;
    }
  	if(A==0){
    	count=0;
    }
    printf("%lld", count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t; using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define stlv(t,n) vector<t> n
#define stls(t,n) set<t> n
void _din() {} void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void vsortg(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }
template <typename T>inline void vsortl(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> inline T nmax(T f1, T f2) { return max(f1, f2); }
template <typename T, typename ... Args> inline T nmax(T first, Args ... rest) { return nmax(first, nmax(rest...)); }
template <typename T> inline T nmin(T f1, T f2) { return min(f1, f2); }
template <typename T, typename ... Args> inline T nmin(T first, Args ... rest) { return nmin(first, nmin(rest...)); }
// ==================================================
int main()
{
	din(int, s);
	stls(int, st);
	st.insert(s);
	int l = s;
	rep(i, 1, 1000001)
	{
		int t = l % 2 ? 3 * l + 1 : l / 2;
		if (st.find(t) != st.end())
		{
			dout(i + 1);
			break;
		}
		st.insert(t);
		l = t;
	}
}

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

int main(){
  	int n,l;cin>>n>>l;
  	int sum=0;
  	rep(i,n){
      sum+=l+i;
    }
  	if((l+n-1)<0){
      sum=sum-(l+n-1);
      cout<<sum<<endl;
    }else if(l<0){
      //0 is eliminated
      cout<<sum<<endl;
    }else{
      sum=sum-l;
      cout<<sum<<endl;
    }
  	//cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;
const int MAXN=1e5+50;
const long long INF=1e18;
int n;
int k,p;
long long dis[MAXN];
int vis[MAXN];
struct Edge
{
    int from;
    int to;
    int cost;
    Edge(int a,int b,int c)
    {
        from=a;
        to=b;
        cost=c;
    }
};
vector<Edge> edges;
vector<int> G[MAXN];

void Init()
{
    for(int i=0; i<=n; i++)
        G[i].clear();
    edges.clear();
}
struct Heap
{
    int d,u;
    Heap(int a,int b)
    {
        d=a,u=b;
    }
    bool operator<(Heap h)const
    {
        return d>h.d;
    }
};
void Dijkstra(int s)
{
    priority_queue<Heap> p;
    p.push(Heap(0,s));
    for(int i=0; i<=n; i++) dis[i]=INF;
    dis[s]=0;
    memset(vis,0,sizeof(vis));
    while(!p.empty())
    {
        Heap h=p.top();
        p.pop();
        int  u=h.u;
        if(vis[u]) continue;
        for(int i=0; i<G[u].size(); i++)
        {
            Edge &e=edges[G[u][i]];
            if(vis[e.to]) continue;
            if(dis[e.to]>dis[u]+e.cost)
            {
                dis[e.to]=dis[u]+e.cost;
                p.push(Heap(dis[e.to],e.to));
            }
        }
    }
}
int main()
{
    scanf("%d",&n);
    Init();
    for(int i=0; i<n-1; i++)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        edges.push_back(Edge(x,y,z));
        G[x].push_back(2*i);
        edges.push_back(Edge(y,x,z));
        G[y].push_back(2*i+1);
    }
    scanf("%d%d",&p,&k);
    Dijkstra(k);
    //for(int i=0;i<=n;i++)
    //    cout<<dis[i]<<" ";
  //  cout<<endl;
    for(int i=0; i<p; i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        cout<<dis[x]+dis[y]<<endl;
    }
    return 0;
}


Measured memory_bytes: 13104