akhauriyash/Code-Regression huggingface dataset:
def binarySearch(l, key):
    left = 0
    right = len(l)
    while left < right:
        mid = (left + right) // 2
        if key == l[mid]:
            return True 
            
        if key < l[mid]:
            right = mid 
        else:
            left = mid + 1
    return False
    
input()
S = list(map(int, input().split()))
input()
T = map(int, input().split())

count = 0
for t in T:
    if binarySearch(S, t):
        count += 1

print(count)
    


Measured memory_bytes: 16708
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
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;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,k;
    cin>>n>>k;
    vector<ll>h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(all(h));
    ll smin=INF;
    for(int i=0;i<n-k+1;i++)
        chmin(smin,h[i+k-1]-h[i]);
    cout<<smin<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
using namespace std;
const int MAXN = 100010;
string s[100010];
int cnt, last;

int main()
{
    s[cnt++] = "1";
    s[cnt++] = "2";
    s[cnt++] = "3";
    s[cnt++] = "4";
    s[cnt++] = "5";
    s[cnt++] = "6";
    s[cnt++] = "7";
    s[cnt++] = "8";
    s[cnt++] = "9";
    last = 0;
    while (cnt < MAXN)
    {
        int len = s[last].length() - 1;
        if (s[last][len] > '0') s[cnt++] = s[last] + (char) (s[last][len] - 1);
        if (cnt >= MAXN) break;

        s[cnt++] = s[last] + s[last][len];
        if (cnt >= MAXN) break;

        if (s[last][len] < '9') s[cnt++] = s[last] + (char) (s[last][len] + 1);
        if (cnt >= MAXN) break;
        last++;
    }

    int k;
    cin >> k;
    cout << s[k - 1] << endl;
}

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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var count = IOUtils.ReadInt();
            var clocks = Enumerable.Repeat(0, count).Select(_ => IOUtils.ReadUlong()).ToArray();

            var res = MathUtils.Lcm(clocks);
            Console.WriteLine(res);
        }
    }

    static class IOUtils
    {
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }

    static class MathUtils
    {
        public static ulong Gcd(params ulong[] nums)
        {
            if (nums.Length == 0) return 0;
            if (nums.Length == 1) return nums.Single();

            var tmp = nums[0];
            var rest = new Queue<ulong>(nums.Skip(1));
            while (rest.Any())
            {
                tmp = gcd(tmp, rest.Dequeue());
            }
            return tmp;
        }
        private static ulong gcd(ulong a, ulong b)
        {
            while (true)
            {
                if (a % b == 0)
                {
                    return b;
                }
                else
                {
                    var x = a % b;
                    a = b;
                    b = x;
                }
            }
        }

        public static ulong Lcm(params ulong[] nums)
        {
            if (nums.Length == 0) return 0;
            if (nums.Length == 1) return nums.Single();

            var tmp = nums[0];
            var rest = new Queue<ulong>(nums.Skip(1));
            while(rest.Any())
            {
                tmp = lcm(tmp, rest.Dequeue());
            }
            return tmp;
        }

        private static ulong lcm(ulong a, ulong b)
        {
            return a / gcd(a, b) * b;
        }

        private static IEnumerable<long> PrimeFactors(long n)
        {
            int i = 2;
            long tmp = n;

            while (i * i <= n)
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,C,D;
    cin >>A>>B>>C>>D;
    if(A+B==C+D){
        cout<<"Balanced"<<endl;
    }else if(A+B>C+D){
        cout << "Left" << endl;
    }else{
        cout << "Right" << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	string s;
	cin >> s;
	rep(i, s.size()) {
		cout << 'x';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3556
//ITP1_7_C_19140837_小島優希也.cpp
//学修番号　１９１４０８３７　 氏名　小島優希也
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
    int h, w;
    cin >> h >> w;
    vector<vector<int> > mat(h, vector<int>(w, 0));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mat.at(i).at(j);
        }
    }
    for (int i = 0; i < h; i++) {
        int sum = 0;
        for (int e : mat.at(i)) {
            sum += e;
        }
        mat.at(i).push_back(sum);
    }
    vector<int> nv(w + 1, 0);
    for (int j = 0; j < w + 1; j++) {
        for (int i = 0; i < h; i++) {
            nv.at(j) += mat.at(i).at(j);
        }
    }
    mat.push_back((vector<int>)nv);
    for (int i = 0; i < mat.size(); i++) {
        for (int j = 0; j< mat.at(0).size() - 1; j++) {
            cout << mat.at(i).at(j) << " ";
        }
        cout << mat.at(i).at(w) << endl;
    }
}




Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long solve(long long n){
    if(n>1)return 1+2*solve(n/2);
    return 1;
}
int main(){
    long long n;
    cin >> n;
    cout << solve(n) << endl;
}


Measured memory_bytes: 256
from itertools import product

N = int(input())
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]

ans = float('-inf')
t = [0, 1]
for store in product(t, t, t, t, t, t, t, t, t, t):
    if sum(store) == 0:
        continue

    profit = 0
    for i in range(N):
        c = 0
        for j in range(10):
            if store[j] + F[i][j] == 2:
                c += 1
        profit += P[i][c]
    ans = max(ans, profit)
print(ans)


Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>
#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <int, int> pii;
const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 998244353;
const ll INF = 0x3F3F3F3F;
template <typename T>
inline T Abs(T x)
{
    return x < 0 ? x * -1 : x;
}
template <typename T>
inline T Max(T x, T y, T z)
{
    return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
    return std::min(std::min(x, y), z);
}
template <typename T>
inline T Ckmax(T &x, T y)
{
    return x = std::max(x, y);
}
template <typename T>
inline T Ckmin(T &x, T y)
{
    return x = std::min(x, y);
}
template <typename T>
inline T Sqr(T x)
{
    return x * x;
}
template <typename T>
inline T Pow(T x, T y)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= MOD;
        (x *= x) %= MOD;
        y /= 2;
    }
    return r % MOD;
}
template <typename T>
T Pow(T x, T y, T z)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= z;
        (x *= x) %= z;
        y /= 2;
    }
    return r % z;
}
template <typename T>
inline T gcd(T x, T y)
{
    return y > 0 ? gcd(y, x % y) : x;
}
template <typename T>
inline T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}
inline void cinspu(void)
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
}
inline ll read(void)
{
    char x;
    while (x = getchar(), x != '-' && !isdigit(x))
        ;
    char flg = x == '-';
    ll num = (flg ? getchar() : x) - '0';
    while (isdigit(x = getchar()))
        (num *= 10) += x - '0';
    return flg ? -num : num;
}
const int N = 1000 + 10;

int main()
{
	cinspu();
	int n;
	std::cin >> n;
	int a[10];
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];std::sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n - 1; ++i) ans += a[i];
	std::cout << ans + a[n - 1] / 2 << std::endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
def main():
    h, w = map(int, input().split())
    a = [list(map(int, input().split())) for _ in range(h)]
    b = [list(map(int, input().split())) for _ in range(h)]
    n = 80*(80+80) + 10
    m = n//2
    dp = [[None]*w for i in range(h)]
    for i in range(h):
        for j in range(w):
            dp[i][j] = np.zeros(n, np.bool)
    dp[0][0][m+abs(a[0][0] - b[0][0])] = True
    dp[0][0][m-abs(a[0][0] - b[0][0])] = True
    for i in range(h):
        for j in range(w):
            x = abs(a[i][j] - b[i][j])
            if 0 < i and 0 < h:
                dp[i][j][x:] |= dp[i-1][j][:n-x]
                dp[i][j][:n-x] |= dp[i-1][j][x:]
                dp[i][j][x:] |= dp[i][j-1][:n-x]
                dp[i][j][:n-x] |= dp[i][j-1][x:]
            elif 0 < i:
                dp[i][j][x:] |= dp[i-1][j][:n-x]
                dp[i][j][:n-x] |= dp[i-1][j][x:]
            elif 0 < j:
                dp[i][j][x:] |= dp[i][j-1][:n-x]
                dp[i][j][:n-x] |= dp[i][j-1][x:]
    ans = float("inf")
    for i in range(m-80-1, m+80+2):
        if dp[h-1][w-1][i]:
            ans = min(ans, abs(m-i))
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 93836
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
#include <bitset>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 2005;

int n;
bitset <MaxN * MaxN> bs;
int dp[2005];
int a[MaxN + 5];

void p() {
	dp[0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 100; j >= a[i]; j--) 
			dp[j] = dp[j] | dp[j - a[i]];
		for(int j = a[i] - 1; j >= 0; j--)
			dp[j] |= dp[j];
	}
	for(int j = 0; j <= 12; j++)
		printf("%d ", dp[j]);
	printf("\n");
}

int main()
{
	while(scanf("%d", &n) != EOF)
	{
		//for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
		//p();
		int sum = 0;
		bs[0] = 1;
		for(int i = 1; i <= n; i++) {
			int x;
			scanf("%d", &x);
			sum += x;
			bs = bs | (bs << x);
		}
		int ans = (sum + 1) / 2;
		while(bs[ans] == false) ans++;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2176
#include "omp.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <random>
#include <bitset>
#include <unordered_set>
#include <cassert>
#include <list>
#include <functional>


using namespace std;

typedef long long ll;
typedef long double ld;


const int sze = 1 << 17, INF = 1e9 + 10;


int used[sze];
vector<vector<int>> vertices;


void dfs(int v, int color)
{
	used[v] = color;

	for (int u : vertices[v])
	{
		if (!used[u])
			dfs(u, color);
	}
}


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

	int n, m;
	cin >> n >> m;


	vertices.resize(n + 1);
	vector<int> values(n);
	for (int i = 0; i < n; ++i)
		cin >> values[i];

	for (int i = 0; i < m; ++i)
	{
		int a, b;
		cin >> a >> b;
		vertices[a].push_back(b);
		vertices[b].push_back(a);
	}

	int color = 1;
	for (int i = 1; i <= n; ++i)
	{
		if (!used[i])
			dfs(i, color++);
	}

	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (used[values[i - 1]] == used[i])
			ans++;
	}

	cout << ans;
	return 0;
}


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

int main() {
	int n; cin >> n;
	vector<int> d(n);
	vector<int> fnd(110);
	for (int i = 0; i < 110; i++) fnd[i] = 0;
	for (int i = 0; i < n; i++) cin >> d[i];

	for (int i = 0; i < n; i++)
	{
		fnd[d[i]]++;
	}

	int cnt = 0;
	for (int i = 0; i < 110; i++)
	{
		if (fnd[i] != 0) cnt++;
	}

	cout << cnt << endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll N, K;
    ll d[200];
    ll A[200][200];
    cin >> N >> K;
    ll list[200] = {};
    for (int i = 0; i < K; i++)
    {
        cin >> d[i];
        for (int j = 0; j < d[i]; j++)
        {
            cin >> A[i][j];
            list[A[i][j]]++;
        }
    }
    ll sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if (list[i] == 0)
        {
            sum++;
        }
    }
    cout << sum << endl;
}

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

int main(){
  string s;
  cin >> s;
  
  int count =700;
  if(s[0]=='o') count+=100;
  if(s[1]=='o') count+=100;
  if(s[2]=='o') count+=100;
  
  cout << count <<endl;
  
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int M = scanner.nextInt();
    int R = scanner.nextInt();

    int[][] edges = new int[M][3];
    int[] r = new int[R];

    for (int i = 0; i < R; i++) r[i] = scanner.nextInt() - 1;
    for (int i = 0; i < M; i++) {
      edges[i][0] = scanner.nextInt() - 1;
      edges[i][1] = scanner.nextInt() - 1;
      edges[i][2] = scanner.nextInt();
    }

    final int[][] dist = new int[N][N];
    final int INF = 100_000_000;
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) if (i != j) dist[i][j] = INF;
    for (int i = 0; i < M; i++) dist[edges[i][0]][edges[i][1]] = dist[edges[i][1]][edges[i][0]] = edges[i][2];

    for (int k = 0; k < N; k++) {
      for (int j = 0; j < N; j++) {
        for (int i = 0; i < N; i++) {
          dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }

    int cost = Integer.MAX_VALUE;
    int[] order = new int[R];
    for (int i = 0; i < R; i++) order[i] = i;
    do {
      int c = 0;
      for (int i = 0; i < R - 1; i++) {
        c += dist[r[order[i]]][r[order[i + 1]]];
      }
      cost = Math.min(cost, c);
    } while (next(order));
    System.out.println(cost);
  }

  public static boolean next(int[] p) {
    final int n = p.length;

    int i = n - 1;
    while (i > 0 && p[i - 1] >= p[i]) i--;
    if (i <= 0) return false;

    int j = n - 1;
    while (j >= i && p[j] <= p[i - 1]) j--;

    swap(p, i - 1, j);

    j = n - 1;
    while (i < j) swap(p, i++, j--);

    return true;
  }

  private static void swap(int[] a, int i, int j) {
    int tmp = a[j];
    a[j] = a[i];
    a[i] = tmp;
  }
}

Measured memory_bytes: 47524
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  int maX, maY, miX, miY;
  maX = w;
  maY = h;
  miX = miY = 0;
  rep (i, n) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      miX = max(miX, x);
    } else if (a == 2) {
      maX = min(maX, x);
    } else if (a == 3) {
      miY = max(miY, y);
    } else if (a == 4) {
      maY = min(maY, y);
    }
  }
  int ansX = (maX - miX);
  int ansY = (maY - miY);
  int ans = ansX * ansY;
  if (ansX < 0 || ansY < 0) ans = 0;
  P(ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<cmath>
#include<map>
#include<vector>
#define int long long int
int binary_search1(vector<int> &v,int start,int end,int val)
{
	if(start>end)
	   return -1;
	else
	{
		int mid=(start+end)/2;
		if(v[mid]>=val)
		{
			int x=mid;
			int y=binary_search1(v,start,mid-1,val);
			if(y==-1)
			   return x;
			else
			   return y;
		}
		else
		{
			return binary_search1(v,mid+1,end,val);
		}
    }
}
int binary_search2(vector<int> &v,int start,int end,int val)
{
	if(start>end)
	    return -1;
	else
	{
		int mid=(start+end)/2;
		if(v[mid]<=val)
		{
			int x=mid;
			int y=binary_search2(v,mid+1,end,val);
			if(y==-1)
			   return x;
			else
			   return y;
		}
		else
		{
			return binary_search2(v,start,mid-1,val);
		}
	}
}
int32_t main()
{
      string str;
      cin>>str;
      vector<int> v1,v2;
      map<int,int> mp;
      int j;
      for(j=0;str[j]!='\0';j++)
      {
		  if(str[j]=='R')
		     v1.push_back(j);
		  else
		     v2.push_back(j);
	  }
	  int index;
	  for(j=0;str[j]!='\0';j++)
	  {
		  if(str[j]=='R')
		  {
			  index=binary_search1(v2,0,v2.size()-1,j);
			  index=v2[index];
			  if((index-j)%2==0)
			  {
				  mp[index]++;
			  }
			  else
			  {
				  mp[index-1]++;
			  }
		  }
		  if(str[j]=='L')
		  {
			  index=binary_search2(v1,0,v1.size()-1,j);
			  index=v1[index];
			  if((j-index)%2==0)
			  {
				  mp[index]++;
			  }
			  else
			  {
				  mp[index+1]++;
			  }
		  }
	  }
	  for(j=0;str[j]!='\0';j++)
	  {
		  auto it=mp.find(j);
		  if(it==mp.end())
		      cout<<0<<" ";
		  else
		     cout<<it->second<<" ";
	  }
	  cout<<endl;
}	



Measured memory_bytes: 7540
"""
最長経路問題として解く。

各試合のノードを作成。
各試合ノードごとに、「この試合が終わったら、次はこの試合ができるようになる。」という対応関係を作っていく。
"""
def main():
    import sys
    sys.setrecursionlimit(1000000)
    input = sys.stdin.readline

    N = int(input())

    A = [[0]*(N)]
    for i in range(N):
        A.append([0]+list(map(int,input().split())))
    
    #選手iにとって、選手jが何番目の相手かを逆引きするメモを用意しておく。
    reverseMemo = [[-1]*(N+1) for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(1,N):
            a = A[i][j]
            reverseMemo[i][a] = j
    edges = {}
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            match = (i,j)
            edges[match] = []
            if reverseMemo[i][j] != N-1:
                nx = A[i][reverseMemo[i][j]+1]
                edges[match].append((min(i,nx),max(i,nx)))
            if reverseMemo[j][i] != N-1:
                nx = A[j][reverseMemo[j][i]+1]
                edges[match].append((min(j,nx),max(j,nx)))
    
    del reverseMemo
    del A
    
    stepMemo = {}
    def dfs(i,j,path):
        #i,jの試合日を含めて、あと何日必要なのかを返す。
        if (i,j) not in stepMemo:
            if (i,j) in path:
                print(-1)
                exit()
            else:
                path.add((i,j))
            res = 1
            for a,b in edges[(i,j)]:
                res = max(res,dfs(a,b,path)+1)
            stepMemo[(i,j)] = res
        return stepMemo[(i,j)]

    ans = 0
    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if (i,j) not in stepMemo:
                ans = max(ans,dfs(i,j,set()))
    print(ans)
main()




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

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

  int k;
  cin >> k;

  string s;
  cin >> s;

  cout << s.substr(0, min(k, (int)s.length())) << ((s.length() > k) ? "...\n" : "\n");

  return (0);
}


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

int main(){
    bool flag=false;
    int A[3][3];
    bool check[3][3];
    int N;
    for(int i=0;i<3;i++){
        for(int j=0; j<3; j++){
            cin >>  A[i][j];
            check[i][j] = false;
        }
           
    }
        
    cin >> N;
    int b[N];
    for(int i=0; i<N; i++){
        cin >>b[i];
        for(int j=0;j<3;j++){
            for(int k=0; k<3; k++){
                if(b[i] == A[j][k]){
                    check[j][k] = true;
                }
            }
        }
    }
    for(int i=0;i<3;i++)
        if(check[i][0] and check[i][1] and check[i][2]) flag = true;
    for(int i=0;i<3;i++)
        if(check[0][i] and check[1][i] and check[2][i]) flag = true;
    if(check[0][0] and check[1][1] and check[2][2]) flag = true;
    if(check[0][2] and check[1][1] and check[2][0]) flag = true;

    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int tmp = n % 10;
        if (tmp == 2 || tmp == 4 || tmp == 5 || tmp == 7 || tmp == 9) {
            System.out.println("hon");
        } else if (tmp == 3) {
            System.out.println("bon");
        } else {
            System.out.println("pon");
        }
    }
}


Measured memory_bytes: 35740
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll a,b,c; cin >> a >> b >> c;
  cout << max(c-a+b,0LL) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std;
int main()
{
	int a, b, p;
  	string s;
  	cin >> a >> b;
  	p = a*b;
	if (p%2 == 0){
      s = "Even";
    }else {
      s = "Odd";
    }
  	cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int w;//長方形横
	int h;//長方形たて
	int x;//円の中心座標横軸
	int y;//円の中心座標縦軸
	int r;//円の半径
	
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	
	if((y + r) <= h && (x + r) <= w &&
		h > 0 && h <= 100 && w > 0 && 
		w <= 100 && x > 0 && x <= 100 &&
		y > 0 && y <= 100 &&r > 0 && r <= 100)
	{
	    printf("Yes\n");
	}else{
	    printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
const int MAX_N = 100000;
const int NIL = -1;
using namespace std;

int n;
vector<int> G[MAX_N];
int color[MAX_N];

void dfs(int u, int col) {
    color[u] = col;
    for (auto i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (color[v] == NIL) {
            color[v] = col;
            dfs(v, col);
        }
    }
}

void dfs_init(void) {
    int id = 1;
    for (int i = 0; i < n; i++) color[i] = NIL;
    for (int i = 0; i < n; i++) {
        if (color[i] == NIL) {
            dfs(i, id);
            id++;
        }
    }
}

int main(void) {
    int m, s, t;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    dfs_init();

    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> s >> t;
        if (color[s] == color[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 10180
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
vector<ll> v;
vector<string> vs;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
map<ll, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if(a%b==0)
	{
		cout << "NO" << endl;
		return 0;
	}
	int tmp = a;
	REP(i,10000)
	{
		tmp += a;
		tmp %= b;
		if((tmp%b)==c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = print n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStrLn n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  [a, b, k] <- readInts
  let ms = [x | x<-[100,99..],a `mod` x==0,b`mod`x==0] in print $ ms !! (k-1) 






Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
int n;
int a[500];

signed main(){
	n=read();
	int ans=0;
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++) ans+=a[i]*a[j];
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m,x,y;
  cin >> n >> m >> x >> y;
  int mx = x, my = y;
  rep(i,n){
    int xi;
    cin >> xi;
    mx = max(mx,xi);
  }
  rep(i,m){
    int yi;
    cin >> yi;
    my = min(my,yi);
  }
  cout << (mx<my?"No War":"War") << endl;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/24
@author: shinjisu
"""


# ABC 122
# import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)
def getIntLines(n): return [int(input()) for i in range(n)]
def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob_TLE():
    d = Debug()
    #d.off()
    N, Q = getIntList()
    d.dmp((N, Q), 'N, Q')
    S = input()
    d.dmp((S), 'S')
    for i in range(Q):
        L, R = getIntList()
        d.dmp((L, R), 'L, R')
        j = L-1
        count = 0
        while j < R-1:
            d.dmp(j,'j')
            d.dmp(S[j:j+2],'S[j:j+2]')
            if S[j:j+2] == 'AC':
                count += 1
                j += 2
            else:
                j += 1
        print(count)
    return None

def prob():
    d = Debug()
    d.off()
    N, Q = getIntList()
    d.dmp((N, Q), 'N, Q')
    S = input()
    d.dmp((S), 'S')
    aclist = zeros(N)  # 左にいくつＡＣがあるか
    j = 0
    R = len(S)
    count = 0
    while j < R:
        #d.dmp(j,'j')
        #d.dmp(S[j:j+2],'S[j:j+2]')
        if S[j:j+2] == 'AC':
            aclist[j] = count
            count += 1
            aclist[j+1] = count
            j += 2
        else:
            aclist[j] = count
            j += 1
    d.dmp((aclist), 'aclist')
   
    for i in range(Q):
        L, R = getIntList()
        #d.dmp((L, R), 'L, R')
        print(aclist[R-1]-aclist[L-1])

    return None

ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)
    





Measured memory_bytes: 6108
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
	char a, b;

	cin >> a >> b;

	if (((a == 'H') && (b == 'H')) || ((a == 'D') && (b == 'D'))) {
		cout << 'H' << '\n';
	}
	else {
		cout << 'D' << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<class T> void re(T& x) { cin >> x; }
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "/home/o_o/MyCodes/pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ;re(n);
	vi a(n);re(a);
	int mx = *max_element(all(a));
	vi tm = a ;
	remdup(tm);
	int sd = tm[sz(a)-2];
	trav(i,a){
		if(i!=mx){
			cout << mx << endl;
		}
		else cout << sd << endl;
	}
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 6332
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

int main(){
    int h, w, k;
    pii x, y;
    cin >> h >> w >> k;
    cin >> x.F >> x.S >> y.F >> y.S;
    x.F--; x.S--; y.F--; y.S--;
    vector<vint> pond(h, vint(w, 0));
    vector<vint> ans(h, vint(w, 1e9));
    vector<vector<bool>> visit(h, vector<bool>(w, 0));
    rep(i,h){
        rep(j,w){
            char c;
            cin >> c;
            if(c == '@') pond[i][j] = 1;
        }
    }

    queue<pii> q;
    // priority_queue<tuple<int, int, int>> q;
    q.push(mp(x.F, x.S));
    ans[x.F][x.S] = 0;
    pii pos;
    while(!q.empty()){
        pos = q.front(); q.pop();
        if(visit[pos.F][pos.S]) continue;
        visit[pos.F][pos.S] = 1;
        rep(i,4){
            rep(j,k){
                int nx = pos.F + dx[i]*(j+1);
                int ny = pos.S + dy[i]*(j+1);
                if(nx < 0 || h <= nx || ny < 0 || w <= ny ) break;
                if(pond[nx][ny] == 0){
                    // printf("nx = %d, ny = %d\n", nx, ny);
                    if(ans[nx][ny] <= ans[pos.F][pos.S]){
                        break;
                    }else{
                        ans[nx][ny] = ans[pos.F][pos.S] + 1;
                        if(nx == y.F && ny == y.S){
                            goto exit;
                        }
                        q.push(mp(nx, ny));
                    }
                }else break;
            }
        }

    }
    exit:
    // rep(i,h){
    //     rep(j,w){
    //         cout << ans[i][j] << " ";
    //     }
    //     cout << endl;rep(i,h);
    // }
    int ans_n = ans[y.F][y.S];
    if(ans_n == 1e9) ans_n = -1;
    cout << ans_n << endl;
}



Measured memory_bytes: 14972
D,G = map(int,input().split())
P = []
C = []
for i in range(D) :
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)
ans = float("inf")
for i in range(1 << D) : # 2**D
    ct = 0 #cost
    score = 0
    for j in range(D) :
        if (i >> j) & 1 : #bit全探索
            score += C[j] #bonus
            score += P[j] * (j+1) * 100 #normal
            ct += P[j] #cost
    for j in range(D-1,-1,-1) : #降順
        if score >= G : 
            break
        if (i >> j) & 1 : #すでに計算された得点帯を除外
            continue
        g = (j+1)*100
        got = (G-score)//g
        score += min(got,P[j])*g
        ct += min(got,P[j])
    ans = min(ans, ct)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
int dy[] = {1, 0, 0, -1};
int dx[] = {0, 1, -1, 0};
bool used[110][110];
string s[110];
int h, w;
void dfs(int y, int x, char c){
    rep(i, 4){
        int ny = y + dy[i], nx = x + dx[i];
        if(!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
        if(used[ny][nx]) continue;
        if(s[ny][nx] != c) continue;
        used[ny][nx] = true;
        dfs(ny, nx, c);
    }
    return;
}
int main(void){
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) return 0;
        rep(i, 110)rep(j, 110) used[i][j] = false;
        int cnt = 0;
        rep(i, h){
            cin >> s[i];
        }
        rep(i, h)rep(j, w){
            if(!used[i][j]){
                cnt++;
                used[i][j] = true;
                dfs(i, j, s[i][j]);
            }
        }
        cout << cnt << endl;
    }
}


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

#define ll long long

using namespace std;

ll P=1000000007,a[500010][62],ans[500010][62],anss=0;

int n;

int main() {	
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		ll x;
		int cnt=61;
		cin>>x;
		while(x)
		{
			a[i][cnt]=x%2;
			ans[i][cnt]=ans[i-1][cnt]+a[i][cnt];
			x/=2;
			--cnt;
		}
		for(;cnt>=1;--cnt)
			ans[i][cnt]=ans[i-1][cnt];
	}
	for(int i=61;i>=1;--i)
	{
		ll t=1ll<<(61-i);
		t%=P;
		for(int j=1;j<n;++j)
			if(a[j][i]==1)
			{
				ll num=n-j-ans[n][i]+ans[j][i];
				anss+=num*t;
				anss%=P;
			}
			else
			{
				ll num=ans[n][i]-ans[j][i];
				anss+=num*t;
				anss%=P;
			}
	}
	cout<<anss<<endl;
	return 0;
}


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

using namespace std;

bool adj[55][55],vis[55];
int n,m;

void dfs(int node){
    vis[node] = 1;
    for(int i = 0 ; i <= n ; i ++){
        if(adj[node][i] && !vis[i]){
            dfs(i);
        }
    }
}

int main()
{
    cin >> n >> m;
    for(int i = 0 ; i < m ; i ++){
        int a,b;
        cin >> a >> b;
        adj[a][b] = 1;
        adj[b][a] = 1;
    }
    int ans = 0;
    for(int i = 0 ; i <= n ; i ++){
        for(int j = 0 ; j <= n ; j ++){
            if(adj[i][j]){
                adj[i][j] = 0;
                memset(vis,0,sizeof vis);
                dfs(1);
                for(int k = 2 ; k <= n ; k ++){
                    if(!vis[k]){
                        ans ++;
                        break;
                    }
                }
                adj[i][j] = 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c, d = list(map(int, input().split()))
i = 1
while a>0 and c>0:
    if i % 2 == 0:
        a -= d
    else:
        c -= b
    i += 1
else:
    if a > c:
        print("Yes")
    else:
        print("No")


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

using namespace std;


int main() {
	string a, b;
	cin >> a;
	cin >> b;
	if (a.size() > b.size()) {
		cout << "GREATER";
	}
	else if (a.size() < b.size()) {
		cout << "LESS";
	}
	else if (a.size() == b.size()) {
		if (a > b) {
			cout << "GREATER";
		}
		else if (a < b) {
			cout << "LESS";
		}
		else {
			cout << "EQUAL";
		}
	}
}

Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <set>

using namespace std;
using ll = long long;

template<typename T> void print(T t) { cout << t << endl; }

int main() {
	int N, flag=0, a;
	cin >> N;
	vector<int> As(N+2);
	for (int i = 1; i <= N; i++) {
		cin >> a;
		if (a == As[i - 1]) {
			N--;
			i--;
		}
		else {
			As[i] = a;
		}
	}
	As[0] = 10000;
	As[N + 1] = 0;

	ll M = 1000, K = 0;
	for (int i = 1; i <= N; i++) {
		if (As[i - 1] < As[i] && As[i] > As[i + 1]) {
			//sell
			M += As[i] * K;
			K = 0;
		}
		else if (As[i - 1] > As[i] && As[i] < As[i + 1]) {
			//buy
			K = M / As[i];
			M -= As[i] * K;
		}
	}
	print(M);
}


Measured memory_bytes: 3624
ABCD=input()
answer=[ABCD[0],"-",ABCD[1],"-",ABCD[2],"-",ABCD[3]]
for i in range(8):
    pat=str(bin(i))[2:].rjust(3,"0")
    sum=int(ABCD[0])
    for j in range(3):
        if pat[j]=="0":
            sum-=int(ABCD[j+1])
            answer[2*j+1]="-"
        else:
            sum+=int(ABCD[j+1])
            answer[2*j+1]="+"
    if sum==7:
        print("".join(map(str,answer))+"=7")
        break

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

ll dp[100010];
vector<vector<ll>> vec(100010);

ll rec(ll i)
{
    if (dp[i] != -1)
        return dp[i];
    else
    {
        ll res = 0;
        for (auto j : vec[i])
            res = max(res, rec(dp[j]) + 1);
        dp[i] = res;
        return res;
    }
}
int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    vector<string> tab(h);
    rep(i, h) cin >> tab[i];
    ll dp[h][w];
    rep(i, h) rep(j, w) dp[i][j] = 0;
    rep(i, h)
    {
        if (tab[i][0] == '#')
            break;
        dp[i][0] = 1;
    }
    rep(i, w)
    {
        if (tab[0][i] == '#')
            break;
        dp[0][i] = 1;
    }

    for (ll i = 0; i < h - 1; ++i)
    {
        for (ll j = 0; j < w - 1; ++j)
        {
            if (tab[i + 1][j + 1] != '#')
                dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j];
            dp[i + 1][j + 1] %= MOD;
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 11520
import heapq as hq
inf = 10 ** 18

N, M = map(int, input().split())
n = 1 << N
dis = [inf] * n
que = []
key = []

for _ in range(M):
    a, _ = map(int, input().split())
    c = map(int, input().split())
    k = 0
    for x in c:
        k += 1 << (x-1)
    key.append((k, a))

dis[0] = 0
hq.heappush(que, (0, 0))

while que != []:
    # print(*dis)
    # print(que)
    d, v = hq.heappop(que)
    if d == dis[v]:
        for gain, cost in key:
            if not (gain & v) == gain:
                to = gain | v
                if dis[to] > d + cost:
                    dis[to] = d + cost
                    hq.heappush(que, (dis[to], to))
if dis[n-1] == inf:
    print(-1)
else:
    print(dis[n-1])

Measured memory_bytes: 4412