akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <queue>
using namespace std;

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,M;
  cin>>N>>M;
  int B,E;
  B=0;
  E=INF;
  int tb,te;
  REP(i,M){
  	cin>>tb>>te;
    if(tb>B){
    B=tb;
    }
    if(te<E){
    E=te;
    }
  }
  if(E-B>=0){
  	cout<<E-B+1<<endl;
  }else{
  	cout<<0<<endl;
  }
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> x(n), y(n), h(n);

    rep(i, n)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    irep(cx, 100) irep(cy, 100)
    {
        set<int> s;
        rep(i, n)
        {
            if (h[i] > 0) {
                s.insert(h[i] + abs(x[i] - cx) + abs(y[i] - cy));
            }
        }

        if (s.size() == 1) {
            int cand = *s.begin();
            bool c = true;
            rep(i, n)
            {
                c = c && (h[i] == max(0L, cand - abs(x[i] - cx) - abs(y[i] - cy)));
            }
            if (c) {
                cout << cx << " " << cy << " " << cand << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,M;
  cin>>N>>M;
  if(M%2){
    for(int i=0;i<M/2;i++)cout<<i+1<<' '<<M-i<<'\n';
    for(int i=0;i<M/2+1;i++)cout<<M+i+1<<' '<<2*M+1-i<<'\n';
  }else{
    for(int i=0;i<M/2;i++)cout<<i+1<<' '<<M-i<<'\n';
    for(int i=0;i<M/2;i++)cout<<M+1+i<<' '<<2*M+1-i<<'\n';
  }
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

struct UnionFind {
  vector<int> par;
  UnionFind(int size) : par(size, -1) {}
  bool unite(int u, int v) {
    if ((u = root(u)) == (v = root(v))) return false;
    if (par[u] > par[v]) swap(u, v);
    par[u] += par[v], par[v] = u;
    return true;
  }
  bool same(int u, int v) { return root(u) == root(v); }
  int root(int u) { return par[u] < 0 ? u : par[u] = root(par[u]); }
  int size(int u) { return -par[root(u)]; }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  int friends[N];
  fill(friends, friends + N, 1);
  while (M--) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    friends[A]++;
    friends[B]++;
    uf.unite(A, B);
  }
  int ans[N];
  fill(ans, ans + N, 0);
  for (int i = 0; i < N; i++) {
    ans[i] = uf.size(i) - friends[i];
  }
  while (K--) {
    int C, D;
    cin >> C >> D;
    C--, D--;
    if (uf.same(C, D)) {
      ans[C]--;
      ans[D]--;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << (i == N - 1 ? "\n" : " ");
  }
  return 0;
}

Measured memory_bytes: 4484
// Try diverta 2019 Programming Contest 2
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut vs = vec![];
    for _ in 0 .. n {
        let v = get!();
        vs.push(v);
    }
    let mut op = vec![];
    vs.sort();
    
    // 最小要素 - 最大以外全プラス要素
    // 最大要素 - 最小以外全マイナス要素 
    // 最大要素 - 最小要素
    
    for i in 1 .. n-1 {
        if vs[i] < 0 {
            continue;
        }
        op.push((vs[0], vs[i]));
        vs[0] -= vs[i];
    }
    for i in 1 .. n-1 {
        if vs[i] >= 0 {
            break;
        }
        op.push((vs[n-1], vs[i]));
        vs[n-1] -= vs[i];
    }
    op.push((vs[n-1], vs[0]));
    vs[n-1] -= vs[0];
    
    println!("{}", vs[n-1]);
    for &(u, v) in op.iter() {
        println!("{} {}", u, v);
    }
}


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

int calc(int, int);

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

    int k;
    cin >> k;
    int n = 1;
    int odd = 0;
    int even = 0;
    while (n <= k) {
        if (n % 2 == 0) {
            even++;
        } else {
            odd++;
        }
        n++;
    }
    cout << odd * even;
}

Measured memory_bytes: 256
def isbingo(ls:list) -> bool:
    for x in ls:
        if set(x)=={0}:return 0
    for x in range(3):
        if ls[0][x] == ls[1][x] == ls[2][x]:return 0
    if ls[0][0] == ls[1][1] == ls[2][2]:return 0
    if ls[0][2] == ls[1][1] == ls[2][0]:return 0
    return 1
a,b,c=(list(map(int,input().split()))for _ in'___')
p=list(map(int,(input()for _ in [0]*int(input()))));a = [a,b,c]
for x in range(3):
    for y in range(3):
        if a[x][y] in p:a[x][y] = 0
print("YNeos"[isbingo(a)::2])

Measured memory_bytes: 38256
from heapq import heappush,heappop

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

S = input()
S = list(S)
def ans():
    ans =0

    for i in range(1,len(S)):
        if S[i-1]==S[i]:
            ans+=1
            S[i] = "1" if S[i]=="0" else "0"
    return ans

print(ans())



Measured memory_bytes: 4084
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


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

  for(int i=0;i<q;i++){
    scanf("%d%d",&a,&b);

    if(n == 1){
      printf("%d\n",min(a,b));
      continue;
    }
    
    a--; b--;
    
    while(a!=b){
      if(a > b){
        a = (a + (n-1)) / n - 1;
      }else{
        b= (b + (n-1)) / n - 1;
      }
    }

    printf("%d\n",a+1);
  }
  
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

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

    bool is_k = true;
    int n = s.length();
    for(int i=0; i<n; i++){
        if(s[i] != s[n-1-i]) is_k = false;
    }

    bool is_kk_1 = true;
    bool is_kk_2 = true;
    for(int i=0; i<=(n/2)-1; i++){
        if(s[i] != s[(n/2)-1-i]) is_kk_1 = false;
    }
    for(int i=(n/2)+1; i<n; i++){
        if(s[i] != s[n-1-i+(n/2)+1]) is_kk_2 = false;
    }

    if(is_k && is_kk_1 && is_kk_2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define INF 1000000

int main(){
	int n,W,D;

	while(cin>>n>>W>>D, n||W||D){
		vector<pair< int,pair<int,int>> > cakes;
		cakes.push_back( {W*D,{W,D}} );

		for(int i=0;i<n;i++){
			int p,q;	cin>>p>>q;
			--p;
			auto pop=*(cakes.begin()+p);

			int w=pop.second.first, d=pop.second.second;
			int len=w+d;
			q%=len;
			if(q<w){
				//cout<<"| "<<endl;
				//printf("(%d,%d)->(%d,%d)(%d,%d)\n",w,d,q,d,w-q,d);
				if(q<w-q){
					cakes.push_back({q*d,{q,d}});
					cakes.push_back({(w-q)*d,{w-q,d}});
				}else{
					cakes.push_back({(w-q)*d,{w-q,d}});
					cakes.push_back({q*d,{q,d}});
				}
				//for(auto it=cakes.begin(); it!=cakes.end();it++){
				//	if(it!=cakes.begin())cout<<" ";
				//	printf("(%d,%d)",(*it).second.first, (*it).second.second);
				//	//cout<<cakes[i].first;
				//}cout<<endl;

			}else{
				//cout<<"- "<<endl;
				q-=w;
				// w < q < w+d
				//printf("(%d,%d)->(%d,%d)(%d,%d)\n",w,d,w,q,w,d-q);
				if(q<d-q){
					cakes.push_back({w*q,{w,q}});
					cakes.push_back({w*(d-q),{w,d-q}});
				}else{
					cakes.push_back({w*(d-q),{w,d-q}});
					cakes.push_back({w*q,{w,q}});
				}
			}
			cakes.erase(cakes.begin()+p);
			//cout<<"->";
			//	for(auto it=cakes.begin(); it!=cakes.end();it++){
			//		if(it!=cakes.begin())cout<<" ";
			//		printf("(%d,%d)",(*it).second.first, (*it).second.second);
			//		//cout<<cakes[i].first;
			//	}cout<<endl;
			//cout<<endl;
		}
		sort(cakes.begin(), cakes.end());
				for(auto it=cakes.begin(); it!=cakes.end();it++){
					if(it!=cakes.begin())cout<<" ";
					//printf("(%d,%d)",(*it).second.first, (*it).second.second);
					cout<<(*it).first;
				}cout<<endl;
	}

	return 0;
}



Measured memory_bytes: 3092
import java.util.Scanner;
class Main
 {
   public static void main(String[] args)
  	{
   Scanner S = new Scanner(System.in);
  	double r = S.nextDouble();
  	System.out.printf("%.6f %.6f\n", r * r * Math.PI, r * 2 * Math.PI);
}
}


Measured memory_bytes: 28300
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<30;
const ll longINF = 1ll<<60;
const ll MOD = 1000000007;
const bool debug = 0;
//---------------------------------//

int main() {
	int M, K; cin >> M >> K;
	vector<int> v, ans;
	if ((1<<M) <= K || (M < 2 && K != 0)) {
		puts("-1");
		return 0;
	}
	else if (M >= 2) {
		REP(i, 1<<M) if (i != K) v.push_back(i);
		ans = v;
		ans.push_back(K);
		reverse(ALL(v));
		ans.insert(ans.end(), ALL(v));
		ans.push_back(K);
	}
	else {
		REP(i, 1<<M) {
			ans.push_back(i);
			ans.push_back(i);
		}
	}
	
	REP(i, 1<<(M+1)) printf("%d%c", ans[i], i + 1 == (1<<(M+1)) ? '\n' : ' ');
	return 0;
}


Measured memory_bytes: 3440
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint n, m;
vector<pair<llint, llint> > vec;

int main(void)
{
	cin >> n >> m;
	llint a, b;
	for(int i = 1; i <= n; i++){
		cin >> a >> b;
		vec.push_back(make_pair(a, b));
	}
	sort(vec.begin(), vec.end());
	
	llint ans = 0;
	for(int i = 0; i < vec.size(); i++){
		llint x = min(vec[i].second, m);
		ans += x * vec[i].first;
		m -= x;
		if(m <= 0) break;
	}
	cout << ans << endl;
	
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    st s ;
    lli a [3] ;
    cin >> s ;
    for (lli i = 0 ;  i < 3 ; i++)
    {
        a[i] = s[i] ;
    }
    sort (a + 0 , a + 3) ;
    for (lli i = 0 ;  i < 3 ; i++)
    {
        s[i] = a[i] ;
    }

    (s == "abc" ? Yes : No) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

int MAX_NODE=100000;
int main()
{
    int N;
    ll L;
    cin >> N >> L;

    int child[MAX_NODE][2];
    fill(child[0], child[0]+MAX_NODE*2, -1);
    int depth[MAX_NODE];
    fill(depth, depth+MAX_NODE, -1);

    depth[0]=0;
    int nodeCount=1;

    for (int i=0;i<N;i++){
        string s;
        cin >> s;
        int prevNode=0;
        int nextNode=-1;

        for (int j=0; j<s.length(); j++){
            int direc = s[j] - '0';

            nextNode = child[prevNode][direc];
            if (nextNode == -1){
                nextNode = nodeCount;
                nodeCount += 1;
                child[prevNode][direc]=nextNode;
                depth[nextNode] = j + 1;
            }
            prevNode = nextNode;
        }
    }

    ll ans = 0;
    for (int i =0;i<nodeCount;i++){
        ll d = L - depth[i];
        if (d > 0) {
            ll g = d&-d;
            for (int j = 0; j < 2; j++) {
                if (child[i][j] == -1) {
                    ans ^= g;
                }
            }
        }
    }

    if (ans!=0){
        cout<<"Alice"<<endl;
    } else {
        cout<<"Bob"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
n = int(input())
t = [int(input()) for _ in range(n)]

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(m, n):
    return m * n//gcd(m, n)


while n > 1:
    i = 0
    next = []
    if n % 2 == 1:
        next.append(t[n-1])
        n -= 1
    while i < n:
        next.append(lcm(t[i], t[i + 1]))
        i += 2
    t = [] + next
    n = len(t)

print(t[0])


Measured memory_bytes: 3064
//In the name of God
#include<bits/stdc++.h>

using namespace std;

const int N = 200;
int n, a, mn = 1e9, mx, cnt[N];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a;
		cnt[a] ++;
		mx = max(mx, a);
		mn = min(mn, a);
	}
	if(mn < (mx+1) / 2)
		return cout << "Impossible", 0;
	for(int i = mx; i >= (mx+1) / 2; --i)
		if(!((i != (mx+1)/2 && cnt[i] >= 2) || (mx%2 == 0 && i == mx / 2 && cnt[i] == 1) || (mx%2 == 1 && i == (mx+1) / 2 && cnt[i] == 2)))
			return cout << "Impossible", 0;
	cout << "Possible";
	return 0;
}

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

import sys
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bfs(N: int, nodes: list, src: int) -> list:
    """ 幅優先探索(頂点数, 隣接リスト(0-indexed), 始点) """

    # 頂点[ある始点からの最短距離] (経路自体を知りたい時はここに前の頂点も持たせる)
    res = [[INF] * N for i in range(3)]
    # スタート位置
    que = deque([(0, 0, src)])
    res[0][src] = 0
    # キューが空になるまで
    while len(que) != 0:
        # 現在のノード
        _, k, cur = que.popleft()
        # 出発ノードcurの到着ノードでループ
        for nxtk, nxt in nodes[k][cur]:
            # 今回の経路のが短い時
            if res[k][cur] + 1 < res[nxtk][nxt]:
                res[nxtk][nxt] = res[k][cur] + 1
                # 現在の移動距離をキューの優先度として、早い方から先に処理するようにする
                que.append((res[nxtk][nxt], nxtk, nxt))
    # ノードsrcからの最短距離リストを返却
    return res

N,M=MAP()
nodes=[[] for i in range(N)]
for i in range(M):
    u,v=MAP()
    nodes[u-1].append(v-1)
S,T=MAP()
S-=1
T-=1

# 元の頂点を3層に拡張する
nodes2=[[[] for j in range(N)] for i in range(3)]
for i in range(3):
    for u, node in enumerate(nodes):
        for v in node:
            nodes2[i][u].append(((i+1)%3, v))

res=bfs(N, nodes2, S)
if res[0][T]==INF:
    print(-1)
else:
    # けんけんぱの回数なので/3する
    print(res[0][T]//3)


Measured memory_bytes: 84696
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(int i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int ans;
	cin >> ans;
	ans = 48 - ans;
	printf("%d\n", ans);
	return 0;
}

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

int32_t main()
{
    int n ;
    cin >> n ;
    int arr[n] ;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> arr[i] ;
    }
    int cur = 1 , cnt = 0 ;
    for(int i = 0 ; i < n ; i++)
    {
        if(arr[i] == cur)
        {
            cur++ ;
            cnt++ ;
        }
    }
    if(!cnt)
    {
        cout << -1 << endl ;
        return 0 ;
    }
    cout << n - cnt << endl ;
    return 0 ;
}


Measured memory_bytes: 1024
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n,W;
    cin>>n>>W;
    ll MX=100001;
    vector<ll> dp(MX,E);
    dp[0]=0;
    ll mx=0;
    for(int i=0;i<n;i++){
        ll w,v;
        cin>>w>>v;
        for(ll t=MX-1;t>=0;t--){
            if(t+v<MX){
                dp[t+v]=min(dp[t+v],dp[t]+w);
                if(dp[t+v]<=W){mx=max(mx,t+v);}
            }
        }
    }
    cout<<mx<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int A;
  int B;
  int C;
  cin >> A >> B >> C;
  
  vector<int> T = {A,B,C};
  
  sort(T.begin(),T.end());
  
  
  int num;
  
  int num2;
  
  if((T[1] - T[0]) % 2 == 0){
    num = T[2] - T[1];
    T[0] = T[0] + num;
    num2 = (T[2] - T[0]) / 2;
    num = num + num2;
    cout << num << endl;
  }
  else{
    T[1] = T[1] + 1;
    T[2] = T[2] + 1;
    num = T[2] - T[1];
    T[0] = T[0] + num;
    num2 = (T[2] - T[0]) / 2;
    num = num + num2 + 1;
    cout << num << endl;
  }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sz 100100
int dp[sz][3];
int ar[sz][3];
int main()
{
    int n; scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &ar[i][0]);
        scanf("%d", &ar[i][1]);
        scanf("%d", &ar[i][2]);
    }
    dp[0][0] = ar[0][0];
    dp[0][1] = ar[0][1];
    dp[0][2] = ar[0][2];
    for (int i = 1; i < n; ++i)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + ar[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + ar[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + ar[i][2];
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
    return 0;
}

Measured memory_bytes: 2560
'use strict'

const main = input => {
	const args = input.trim().split(' ')
	const a = parseInt(args[0], 10)
	const op = args[1]
	const b = parseInt(args[2], 10)

	if (op === '+') {
		console.log(a + b)
	} else {
		console.log(a - b)
	}
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7500
#include <bits/stdc++.h>
//#include <iostream>
//#include <string>
//#include <algorithm>
//#include <stdio>
using namespace std;
#define fr(i, r, n) for(int i = r; i < n; ++i)
const int maxn = (int)2e5 +10;

int main()
{
    int n;
    int arr[maxn], srr[maxn];
    cin>>n;
    fr(i, 0 , n)
    {
        cin>>arr[i];
        srr[i] = arr[i];
    }
    sort(srr, srr+n);
    int maxx = srr[n-1];
    fr(i, 0 , n)
    {
        if(arr[i] == maxx)
        {
            cout<<srr[n-2]<<endl;
        }
        else
            cout<<maxx<<endl;
    }


    return 0;
}



Measured memory_bytes: 3200
#include <iostream>

using namespace std;

typedef long long ll;

ll isPrime(ll num){
    if(num == 2) return 1;
    if(num == 3) return 1;
    if(num == 4) return 0;
    if(num == 5) return 1;
    
    for (ll i = 2; i*i <= num; i++) {
        if (num % i == 0) {
            return 0;
        }
    }
    return 1;
}

ll minfactor(ll n){
    ll i;
    
    if (isPrime(n)) return n;
    
    for (i = 2; i <= n ; i++) {
        if(n % i == 0) break;
    }
    return i;
}


long eulerphi(long n)
{
    long phi = n;
    long m;
    long m0 = 0;
    
    if (n < 1) return(0);
    
    if (n == 1) return(1);
    
    do {
        m = minfactor(n);
        n /= m;
        
        if (m0 != m){
            phi = phi * (m-1) / m;
            m0 = m;
        }
    } while (n != 1);
    
    return(phi);
}


int main(){
    
    ll n, ans = 0;
    
    cin >> n;
    
    ans = eulerphi(n);
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a < b && b < c){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return (0);
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T>
T largestrectangle(vector<T> &v){
  int n=v.size();
  T res=0;
  using P = pair<int, T>;
  stack<P> sp;
  sp.emplace(-1,T(0));
  for(int i=0;i<n;i++){
    int j=i;
    while(sp.top().second>v[i]){
      j=sp.top().first;
      if(sp.top().second)
        res=max(res,(i-j+1)*(sp.top().second+1));
      sp.pop();
    }
    if(sp.top().second<v[i]) sp.emplace(j,v[i]);
  }
  while(!sp.empty()){
    if(sp.top().second)
      res=max(res,(n-sp.top().first+1)*(sp.top().second+1));
    sp.pop();
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(int i=0;i<h;i++) cin>>st[i];

  int ans=max(h,w);
  vector<int> vv(w-1,0);
  for(int i=0;i+1<h;i++){
    for(int j=0;j+1<w;j++){
      int cnt=0;
      for(int a=0;a<2;a++)
        for(int b=0;b<2;b++)
          cnt+=st[i+a][j+b]=='#';
      if(cnt&1) vv[j]=0;
      else vv[j]++;
    }
    chmax(ans,largestrectangle(vv));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC155C()
{
	int N;
	cin >> N;
	map<string, int> strMap;
	for (int i = 0; i < N; ++i)
	{
		string S;
		cin >> S;
		++strMap[S];
	}
	multimap<int, string> reverse;
	for (auto& x : strMap)
	{
		reverse.insert({ x.second, x.first });
	}
	int n = reverse.rbegin()->first;
	auto x = reverse.equal_range(n);

	vector<string> ret;
	for(auto y = x.first; y != x.second; ++y)
	{
		ret.push_back(y->second);
	}
	sort(ret.begin(), ret.end());
	for (auto& z : ret)
	{
		cout << z << endl;
	}
}


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


Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main() {
  int X; cin >> X;
  int rank = 10 - X/200;
  cout << rank << endl;  
return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
typedef long long ll;
using namespace std;

class DisjointSet{
public:
  vector<int> rank,p;
  vector<int> sz;
 
  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
    sz.resize(size,0);
    for(int i=0;i<size;i++) makeSet(i);
  }
 
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
    sz[x]=1;
  }
 
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }
 
  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }
 
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
      sz[x]+=sz[y];
    }else{
      p[x]=y;
      sz[y]+=sz[x];
      if(rank[x]==rank[y]){
        rank[y]++;
      }
    }
  }
 
  int findSet(int x){
    if(x!=p[x]){
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
 
  int findSize(int x){
    return sz[findSet(x)];
  }
};

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

  DisjointSet us(N);
  for(int i=0;i<M;i++){
    int x,y,z;
    cin>>x>>y>>z;

    x--;
    y--;
    if(us.same(x,y)) continue;
    else us.unite(x,y);
  }

  int ans=1;
  for(int i=1;i<N;i++){
    if(us.same(0,i)) continue;

    ans++;
    us.unite(0,i);
  }

  cout<<ans<<endl;

  return 0;
}


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


int main()
{
	int m1, d1, m2, d2;
	cin>>m1>>d1>>m2>>d2;

	if (1== m2-m1 || (12== m2 && 31== d1)){
		printf("1\n");
	}
	else{
		printf("0\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


char masu[101][101];
int H,W,x,y;



int main()
{
	int i,j;
	int f,t1,t2;
	char temp;
	
	for(;;){
		x=0;
		y=0;
		f=0;
		
		scanf("%d %d", &H, &W);
		if(H==0)break;
		scanf("%c",&temp);
		
		for(i=0;i<H;i++){
			for(j=0;j<W+1;j++){
				scanf("%c",&masu[i][j]);
			}
		}
		for(;;){
			if(masu[y][x]==','){
				f=1;
				break;
			}
			t1=x;
			t2=y;
			if(masu[y][x]=='>')x++;
			else if(masu[y][x]=='<')x--;
			else if(masu[y][x]=='v')y++;
			else if(masu[y][x]=='^')y--;
			else if(masu[y][x]=='.')break;
			masu[t2][t1]=',';
		}
		if(f==1)puts("LOOP");
		else printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 0
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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


signed main() {
    int k,a,b;cin >>k>>a>>b;
    int now=k;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout <<"OK"<<endl;
            return 0;
        }
    }
    cout <<"NG"<<endl;
}

















Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <queue>

using namespace std;

int main() {
    int N;
    int X[200000], Y[200000];

    scanf("%d", &N);
    for(int i = 0; i < N; i++) {
        int t; scanf("%d", &t);
        X[i] = Y[i] = t;
    }

    sort(X, X + N);

    int a = X[N / 2 - 1], b = X[N / 2];

    for(int i = 0; i < N; i++) {
        if(Y[i] <= a) printf("%d\n", b);
        else printf("%d\n", a);
    }
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp{
	int t;
	char name[100];
}p;

p Q[LEN];

int head,tail,n;

void enqueue(p x){
	Q[tail] = x;
	tail=(tail+1)%LEN;
	}
	
p dequeue(){
	p x = Q[head];
	head = (head+1)%LEN;
	return x;
}

int min(int a,int b){
	return a<b? a:b;
}

int main(){
	int n,q,els=0;
	p temp;
	scanf("%d %d",&n,&q);
	for(int i=1;i<=n;i++){
		scanf("%s",Q[i].name);
		scanf("%d",&Q[i].t);
	}
	 head=1,tail=n+1;
	
	while(head!=tail){
	 temp = dequeue();
	int c = min(temp.t,q);
	temp.t-=c;
	els+=c;
	if(temp.t>0){
		enqueue(temp);
	}else{
		printf("%s %d\n",temp.name,els);
	}
	}
	return 0;
}

Measured memory_bytes: 12876
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

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

  long dp[200005];
  dp[0] = 0;
  int wi, vi;
  rep (i, n) {
    cin >> wi >> vi;

    drep(j, w - wi + 1) {
      int ni = j + wi;
      dp[ni] = max(dp[ni], dp[j] + vi);
    }
  }
  cout << dp[w] << endl;
  return 0;
}

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

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

    if(N % (2 * D + 1) == 0)cout << N / (2 * D + 1) << endl;
    else cout << N / (2 * D + 1) + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getContents :: IO [Int]
  let
    as' = VU.fromList as :: VU.Vector Int
    x1 = VU.sum . VU.zipWith (*) (VU.iterateN n negate 1) $ as' :: Int
    xs = VU.prescanl subtract x1 . VU.map (2 *) $ as' :: VU.Vector Int
--    xs = VU.tail . VU.prescanl subtract x1 . VU.map (2 *) $ as' :: VU.Vector Int
  T.putStrLn . T.intercalate (T.singleton ' ') . map (T.pack . show) . VU.toList $ xs
--  putStr . show $ x1
--  VU.mapM_ (\x -> putChar ' ' >> putStr (show x)) $ xs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 7100
#include<stdio.h>

main(){
 int i,j;
 int H,W;

while(1){
 scanf("%d %d",&H,&W);

 if(H==0 && W==0){
 break;}

 for(i=1;i<=H;i++){
/////////////////////////
  if(i==1 || i==H){
   for(j=1;j<=W;j++){
    printf("#");
    }
  }
////////////////////////
  else{
   for(j=1;j<=W;j++){
   
   if(j==1 || j==W){
     printf("#");
    }
   else{
   printf(".");
    }

   }
  }
///////////////////////
  printf("\n");
 }
 
 printf("\n");
}

return 0;
}


Measured memory_bytes: 2108
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  input[1] = myconv(input[1],4);
  var T = input[1][0];
  var A = input[1][1];
  var list = myconv(input[2],4);
  var near = 10000000;
  var output;
  for(var i = 0; i < N; i++){
    var ave = T - list[i] * 0.006;
    if(near > Math.abs(A - ave)){
       near = Math.abs(A - ave);
       output = i+1;
    }
  }
  myout(output);
}

Main(myin());


Measured memory_bytes: 7884
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
import java.util.StringTokenizer;
 
public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		int t = 1;
		while(t-->0) solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			int n = scan.nextInt();
			int[] a = new int[n], b = new int[n], c = new int[n-1];
			for(int i = 0; i < n; i++) a[i] = scan.nextInt();
			for(int i = 0; i < n; i++) b[i] = scan.nextInt();
			for(int i = 0; i < n-1; i++) c[i] = scan.nextInt();
			long t = 0;
			for(int i = 0; i < n; i++) {
				t += b[a[i]-1];
				if(i > 0 && a[i] == a[i-1]+1) t += c[a[i-1]-1];
			}
			out.println(t);
		}
		
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
	static void shuffle(long[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
 
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}
 
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
 
}

Measured memory_bytes: 23380
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] ab = sc.intarr;
            string[] ss = Console.ReadLine().Split('-');

            if(ss[0].Length != ab[0])
            {
                Console.WriteLine("No");
                return;
            }

            if (ss[1].Length != ab[1])
            {
                Console.WriteLine("No");
                return;
            }

            Console.WriteLine("Yes");
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


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

typedef long long ll;

ll gcd(ll a, ll b){
return a != 0 ? gcd(b % a, a) : b;
}

int main() {
ll a, b;
while(cin >> a >> b)
cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;}

Measured memory_bytes: 3012
import sys
input = sys.stdin.readline

l, r = map(int, input().split())

l_q, l_mod = divmod(l, 2019)
r_q, r_mod = divmod(r, 2019)

min_v = 2019
if l_q == r_q:
    for i in range(l_mod, r_mod+1):
        for j in range(l_mod, r_mod+1):
            if i != j:
                mul = (i * j) % 2019
                if mul < min_v:
                    min_v = mul
else:
    min_v = 0

print(min_v)

Measured memory_bytes: 3064
#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)
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(C-A+B>0){
    printf("%d",C-A+B);
    }else{
    printf("0");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int n = 4;

int main(){
    char c[4];

    for(int i=0; i<4; i++) cin >> c[i];

    sort(c, c+4);

    for(int i=0; i<2; i++){
        if(c[i] != c[i+1]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

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

using namespace std;

const int inf = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s = "";
    if(n == 0){
        cout << '0' << endl;
        return 0;
    }
    while(n!=0){
        if(n%2 != 0){
            s += '1';
            n--;
        }
        else{
            s += '0';
        }
        n/= -2;
    }
    reverse(s.begin(),s.end());
    cout << s << endl;
	return 0;
}


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

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = s[0];
            int b = s[1];
            int c = s[2];

            for (int i = 0; i < b; i++)
            {
                if (a * i % b == c)
                {
                    WriteLine("YES");
                    return;
                }
            }
            WriteLine("NO");
        }
    }
}


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

const int limit=50;
int n,m;
int a[limit],b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
	visited[v]=true;
  	for(int v2=0; v2<n; v2++){
      if(graph[v][v2]==false) continue;
      if(visited[v2]==true) continue;
      dfs(v2);
    }
}

int main(){
  cin >> n >> m;
  for(int i=0; i<m; i++){
  	cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  
  int ans=0;
  
  for(int i=0; i<m; i++){
  	graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    
    for(int j=0; j<n; j++) visited[j]=false;
    
    dfs(0);
    
    bool bridge=false;
    for(int j=0; j<n; j++) if(visited[j]==false) bridge=true;
    if(bridge) ans++;
    
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
using namespace std;
const int N = 101;
int dp[N][N], a[N][N];
vector<int> split(string s)
{
	vector<int> res;
	for (int i=0; i<s.size(); ++i) if (s[i] == ',') s[i] = ' ';
	istringstream is(s);
	int t;
	while (is >> t) res.push_back(t);
	return res;
}
int main()
{
	string in;
	int pn = 0;
	int n = 0, m = 0;
	while (cin >> in) {
		vector<int> t = split(in);
		for (int i=0; i<t.size(); ++i) a[n][i] = t[i];
		n++;
		m = max(m, (int)t.size());
	}
	dp[0][0] = a[0][0];
	for (int i=1; i<m; ++i)
		for (int j=0; j<m; ++j)
			dp[i][j] = max(dp[i-1][j-1], dp[i-1][j]) + a[i][j];
	for (int i=m; i<n; ++i)
		for (int j=0; j<m; ++j)
			dp[i][j] = max(dp[i-1][j], dp[i-1][j+1]) + a[i][j];
	cout << dp[n-1][0] << endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;



int atcoder(){
    //入力
    int a[3];
    REP(i,3) cin >> a[i];
    int ans = 0;
    
    //処理
    sort(a,a+3);
    
    while(true){
        if(a[0]==a[1]){
            ans += a[2]-a[0];
            break;
        }
        if(abs(a[1]-a[0])==1){
            ans += a[2] - min(a[0],a[1]) + 1;
            break;
        }else{
            a[0] += 2;
            ++ans;
        }
    }
    
    
    
    

    //出力
    cout << ans <<ENT;
    return 0;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

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

	  if((int)a.charAt(0)>90) {
		  System.out.println("a");
	  }else {
		  System.out.println("A");
	  }
  }
}



Measured memory_bytes: 35644
# coding: utf-8
N,M=map(int,input().split())
MOD=10**9+7

if abs(N-M)==0:
    p=2
elif abs(N-M)==1:
    p=1
else:
    p=0

P=[1]

for i in range(max(N,M)):
    num=i+1
    P.append(P[i]*num%MOD)

ans=p*P[N]*P[M]%MOD
print(ans)

Measured memory_bytes: 7060
import copy

def solve():
    V = copy.copy(v)
    while len(V) > 1:
#        print(V)
        V.sort()
        tmp = (V[0]+V[1])/2
        del V[0:2]
        V.append(tmp)
    print(V[0])


if __name__ == "__main__":
    N = int(input())
    v = list(map(float, input().split()))  
    solve()



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  deque<int> dq;
  REP(i,N){
	int x;
	cin >> x;
	if(i%2) dq.push_front(x);
	else dq.push_back(x);
  }

  if(N%2==1) reverse(ALL(dq));
  REP(i,N) cout << (i?" ":"") << dq[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 3072
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
P = [*map(int,input().split())]
ans = 100+100 # inf = x + d + 1
for d in range(100): # [0,100)
    now_diff = abs(ans - x)
    min_x, max_x = x - d, x + d
    if min_x not in P:
        if now_diff > abs(min_x - x): ans = x-d
    elif max_x not in P:
        if now_diff > abs(max_x - x): ans = x+d
print(ans)


Measured memory_bytes: 9200
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define rrep(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define lli long long int
#define vi vector<int> 

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}

int main() {
	string s;
	cin >> s;
	int c[26] = { 0 };

	rep(i, 0, s.length()) {
		c[s[i] - 'a']++;
	}

	bool judge = true;
	rep(i, 0, 26) {
		if (c[i] % 2 != 0)judge = false;
	}
	if (judge)pp("Yes");
	else pp("No");

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] x=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] s=new int[n],a=new int[n];
		Array.Copy(x,s,n);
		Array.Sort(s);
		for(int i=0;i<n;i++){
			if(x[i]<s[n/2]){a[i]=s[n/2];}
			else{a[i]=s[n/2-1];}
		}
		Console.WriteLine(String.Join("\n",a));
	}
}

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

using namespace std;
using ll = unsigned long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int ret = 1;
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto & a : v) cin>>a;
    for(int i=1;i<n;++i){
        bool ok = true;
        for(int j=0;j<i;++j){
           if(v[j] > v[i]) ok = false; 
        }
        if(ok)ret++;
    }
    cout << ret <<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        //参加者数
		int n = sc.nextInt();
        //最初に持っている得点
      	int k = sc.nextInt();
        //正解数
      	int q = sc.nextInt();
      
        int[] a = new int[n];
      
        for(int i = 0; i < a.length; i++){
        	a[i] = k;
        }
      
      	while(sc.hasNext()){
			int number = sc.nextInt();
  			int next = number - 1;
			a[next] += 1; 
		}
      	
      	for(int i = 0; i < a.length; i++){
        	a[i] = a[i] - q;
            if(a[i] > 0){
            	System.out.println("Yes");
            }else{
            	System.out.println("No");
            }
        }
     }
}

Measured memory_bytes: 61904
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n;cin >> n;
	vector<ll> v(n);
	ll ans = 0;
	REP(i, n)cin >> v[i];
	sort(ALL(v), greater<ll>());


	ll cou = 0;
	REP(i, n){
		if(i == 0){
			ans += v[i];
			cou++;
		}
		else {
			ans += v[i];
			cou++;
			if(cou == n - 1)break;
			ans += v[i];
			cou++;
		}
		if(cou == n - 1)break;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4788