akhauriyash/Code-Regression huggingface dataset:
from collections import deque
from heapq import heappush, heappop
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def neighbors4(x, y):
  dxy = (0, 1, 0, -1, 0 )
  for i in range(4):
    yield(x + dxy[i], y + dxy[i+1])

def search(cost, sx, sy):
    # ある地点からジャンプ無しで行ける範囲を探索

    que = deque()
    que.append((sx,sy))

    reached = []

    while que:
        x,y = que.popleft()

        # 訪れた場所リスト
        reached.append((x,y))

        if cost_map[y][x] <= cost:
            continue
        cost_map[y][x] = cost

        for x2, y2 in neighbors4(x,y):
            if x2<0 or x2>=w or y2<0 or y2>=h:
                continue
            if grid_s[y2][x2] == ".":
                que.append((x2, y2))
    
    return reached

def jump(cost, x, y):
    if cost >= cost_map[y][x]:
        return
    reached = search(cost, x, y)
    
    # ゴールに到達したらおわり
    if cost_map[dh][dw] != INF:
        print(cost_map[dh][dw])
        exit()
    
    # 1回ジャンプする
    for x,y in reached:
        for y2 in range(max(0, y-2), min(h, y+3)):
            for x2 in range(max(0, x-2), min(w, x+3)):
                if abs(x-x2) + abs(y-y2) < 2:
                    continue
                if grid_s[y2][x2] == "." and cost_map[y2][x2] > cost+1:
                    heappush(jump_que, (cost+1, x2, y2))

def main():
    global h,w,dh,dw,grid_s,cost_map, jump_que,INF
    INF = 999999999999999999999999
    MOD = 10**9+7

    h,w = get_nums_l()
    ch,cw = get_nums_l()
    dh,dw = get_nums_l()

    # 0-originに変換
    ch -= 1
    cw -= 1
    dh -= 1
    dw -= 1

    grid_s = []
    for i in range(h):
        grid_s.append(input())
    
    cost_map = [[INF] * w for _ in range(h) ]

    jump_que = deque()
    jump_que.append((0, cw, ch))

    while jump_que:
        cost, x, y = jump_que.popleft()
        
        if cost >= cost_map[y][x]:
            continue
        reached = search(cost, x, y)
        
        # ゴールに到達したらおわり
        if cost_map[dh][dw] != INF:
            print(cost_map[dh][dw])
            exit()
        
        # 1回ジャンプする
        for x,y in reached:
            for y2 in range(max(0, y-2), min(h, y+3)):
                for x2 in range(max(0, x-2), min(w, x+3)):
                    if abs(x-x2) + abs(y-y2) < 2:
                        continue
                    if grid_s[y2][x2] == "." and cost_map[y2][x2] > cost+1:
                        jump_que.append((cost+1, x2, y2))
    
    print(-1)

main()

Measured memory_bytes: 219400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	if(n <= 9 && m <= 9){
		print(n*m)
	}
	else{
		print(-1)
	}
	
	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);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[][] student = new int[N][2];
		int[][] checkpoint = new int[M][2];
		for(int i = 0;i < N;++i) {
			student[i][0] = sc.nextInt();
			student[i][1] = sc.nextInt();
		}
		for(int i = 0;i < M;++i) {
			checkpoint[i][0] = sc.nextInt();
			checkpoint[i][1] = sc.nextInt();
		}
		sc.close();
		
		StringBuilder sb = new StringBuilder();
		for(int i = 0;i < N;++i) {
			int ans = 0;
			int min = Integer.MAX_VALUE;
			for(int j = 0;j < M;++j) {
				int div = Math.abs(student[i][0] - checkpoint[j][0])
						+ Math.abs(student[i][1] - checkpoint[j][1]);
				if(min > div) {
					min = div;
					ans = j+1;
				}
			}
			sb.append(ans + "\n");
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n,ans=0;
  cin >> n;
  vector<ll> l(n);
  REP(i, n) { cin >> l[i]; }
  
  REP(i, n) {
    for (ll j = i + 1; j < n; j++) {
      for (ll k = j + 1; k < n; k++) {
        if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue;
        if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[k]+l[i]>l[j])
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
  }


Measured memory_bytes: 3608
/*
 
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define LL long long 
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
using namespace std;
const LL MAXN = 1e6 + 10, INF = 1e9 + 10;
const double eps = 1e-9;
inline LL read() {
    char c = getchar(); LL x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
LL N, K, pos;
LL x[MAXN], suml[MAXN], sumr[MAXN];
LL Get(LL l, LL r) {
	LL ll = x[l], rr = x[r];
	if(ll > 0) ll = 0;
	if(rr < 0) rr = 0;
	LL x1 = abs(rr) * 2 + abs(ll);
	LL x2 = abs(ll) * 2 + abs(rr);
	return min(x1, x2);
}
int main() {
	N = read(); K = read();
	for(LL i = 1; i <= N; i++) x[i] = read();
	x[0] = -INF; x[N + 1] = +INF;
	pos = N;
	for(LL i = 1; i <= N; i++) 
		if(x[i - 1] <= 0 && x[i] >= 0) {pos = i; break;}
	LL ans = INF;
	for(LL i = 1; i <= N; i++) {
		int r = i + K - 1;
		if(r > N) break;
		if(pos < i || pos > r) continue;
	//	printf("%d %d %d\n", i, i + K - 1, Get(i, i + K - 1));
		ans = min(ans, Get(i, r));		
	}
 
	printf("%I64d", ans);
    return 0;
}
/*
3 3
-30 -20 -10
*/

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int A, P;
  cin >> A >> P;

  cout << (A*3+P)/2 << endl;

  return 0;
}


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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // d,a,b,c
  using Ti4 = tuple<int, int, int, int>;
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<Ti4> abcd(Q);
  for (auto& [a, b, c, d] : abcd)cin >> a >> b >> c >> d, --a, --b;
  // sort(begin(abcd), end(abcd));
  vector<int> arr(N, 1);
  int ans = 0;
  auto dfs = [&](auto&& f) {
    return [=](auto&&...args) {
      return f(f, forward<decltype(args)>(args)...);
    };
  }(
    [&](auto&& self, int n, int a) -> void {
      if (n == N) {
        int sum = 0;
        for (const auto& [a, b, c, d] : abcd)
          if (arr[b] - arr[a] == c)sum += d;
        ans = max(ans, sum);
        return;
      }
      for (; a <= M; ++a) {
        arr[n] = a;
        self(self, n + 1, a);
      }
    }
  );
  dfs(0, 1);
  cout << ans << endl;
}


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

using namespace std;

const long long SZ = 26, MAXN = 2e2 + 40, MAXM = 2e6 + 40, mod = 1e9 + 7;
const double eps = 1e-9, Pi = acos(-1), inf = 1e9 + 100;
mt19937 rnd(mod);

char f[MAXN][MAXN];
int dist[MAXN], q[MAXN];

void init (int n) {
    fill(dist, dist + n, inf);
}

int bfs (int v, int n) {
    init(n);
    int qt = 0, qh = 0;
    dist[v] = 1;
    q[qt++] = v;
    int mx = 0;
    while (qh < qt) {
        v = q[qh++];
        mx = max(dist[v], mx);
        for (int u = 0; u < n; ++u) {
            if (f[v][u] == '0')
                continue;

            if (dist[u] != dist[v] - 1 && dist[u] != inf && dist[u] != dist[v] + 1) {
                return -1;
            }
            if (dist[u] == inf) {
                dist[u] = dist[v] + 1;
                q[qt++] = u;
            }
        }
    }
    return mx;
}

void solve () {
    int n;
    cin >> n;
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i < n; ++i) {
            cin >> f[j][i];
        }
    }
    int mx = -1;
    for (int j = 0; j < n; ++j)
        mx = max(mx, bfs(j, n));

    cout << mx << '\n';
}

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

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    long long t = 1;
    while (t--)
        solve();
}
	

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

int main(){
  ll n;
  cin >> n;
  vector<pair<ll,ll>> a(n);
  rep(i,n){
    scanf("%d",&a.at(i).second);
    scanf("%d",&a.at(i).first);
  }
  sort(a.begin(),a.end());
  ll t = 0;
  rep(i,n){
    t += a.at(i).second;
    if( t > a.at(i).first ){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  
  return 0;
}

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

def solve(N, S):
    dp = [[0 for i in range(N+1)] for j in range(N+1)]
    # dp[left][right] := 正しい方向の数
    # まずはdp[0][N]を考える
    for s in S:
        if s == "W":
            dp[0][N] += 1
    maxv = dp[0][N]
    # dpを埋める
    # dp[1][N-1], dp[2][N-2], ...
    for i in range(1, N+1):
        if S[i-1] == "E":
            diff = 1
        else:
            diff = -1
        dp[i][N-i] = dp[i-1][N-i+1] + diff
        if dp[i][N-i] >= maxv:
            maxv = dp[i][N-i]
    print(N - maxv)

def solve2(N, S):
    good = 0
    for s in S:
        if s == "W":
            good += 1
    maxv = good

    nowv = maxv
    for i in range(1, N+1):
        if S[i-1] == "E":
            diff = 1
        else:
            diff = -1
        nowv = nowv + diff
        if nowv >= maxv:
            maxv = nowv
    print(N - maxv)

if __name__ == "__main__":
    N = int(input())
    S = input()
    solve2(N, S)


Measured memory_bytes: 3784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char str[1000];
    char *tok;
    
    int n;
    int a[100][2];
    int i1,i3,i4;
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    n=strtol(tok,NULL,10);
    //printf("%d\n",n);
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    a[0][0]=strtol(tok,NULL,10);
    for(i1=1;i1<n;i1++){
        tok=strtok(NULL," ");
        a[i1][0]=strtol(tok,NULL,10);
    }
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    a[0][1]=strtol(tok,NULL,10);
    for(i1=1;i1<n;i1++){
        tok=strtok(NULL," ");
        a[i1][1]=strtol(tok,NULL,10);;
    }
    
    i4=a[n-1][1];
    for(i1=0;i1<n;i1++){
        i4+=a[i1][0];
    }
    //printf("%d\n",i4);
    
    i3=i4;
    for(i1=1;i1<n;i1++){
        i4=i4-a[n-i1][0]+a[n-1-i1][1];
        if(i4>i3){
            i3=i4;
        }
    }
    
    
    printf("%d",i3);
    
    return 0;
}



Measured memory_bytes: 128
import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		BigInteger x = BigInteger.valueOf(sc.nextInt());
		sc.close();
		int i=0;
		int j=0;
		for (i=-100; i<1000; i++) {
			for (j=-100; j<1000; j++) {
				BigInteger a = BigInteger.valueOf(i).pow(5);
				BigInteger b = BigInteger.valueOf(j).pow(5);
				if (a.subtract(b).equals(x)) {
					System.out.println(i + " " + j);
					return;
				}
			}
		}

	}
}


Measured memory_bytes: 46088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	h, _ := strconv.Atoi(Scanner())
	w, _ := strconv.Atoi(Scanner())
	if h == 1 || w == 1 {
		fmt.Println(1)
	} else if h%2 == 0 {
		fmt.Println(h / 2 * w)
	} else if w%2 == 0 {
		fmt.Println(w / 2 * h)
	} else {
		fmt.Println((w/2+1)*(h/2+1) + (w/2)*(h/2))
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int>P,Q,A;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int p;cin>>p;P.push_back(p);
	}
	for(int i=0;i<N;i++)
	{
		int q;cin>>q;Q.push_back(q);
		A.push_back(i+1);
	}
	int a,b,c=0;
	do{
		if(A==P)a=c;
		if(A==Q)b=c;
		c++;
	}while(next_permutation(A.begin(),A.end()));
	cout<<(a<b?b-a:a-b)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long gcd(long a,long b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
int main()
{
    long a,b,i,j;
    cin>>a>>b;
    long gcdv;
    gcdv=gcd(a,b);
    vector <long> v;
    for(i=1;i<=sqrt(gcdv);i++)
    {
        if(gcdv%i==0)
        {
            if(gcdv/i==i)
                v.push_back(i);
            else 
            {
                v.push_back(i);
                v.push_back(gcdv/i);
            }
        }
    }
    
    sort(v.begin(),v.end());
    if(gcdv==1)
        cout<<"1"<<endl;
    else
    {      
    for(i=1;i<v.size()-1;i++)
    {
      for(j=i+1;j<v.size();j++)
      {
          if(v[i]!=0 && gcd(v[i],v[j])!=1)
          {
              v[j]=0;
          }
          }
    }
    long count=0;
    for(i=0;i<v.size();i++)
    {
        if(v.at(i)!=0)
            count++;
    }
    cout<<count<<endl;
    }
    return 0;
}



Measured memory_bytes: 384
<?php
  $N=+fgets(STDIN);
  $s=rtrim(fgets(STDIN));
  for($i=0;$i<strlen($s);$i++)
  {
    $k=ord($s[$i]);
    $k=($k-65+$N)%26+65;
    $s[$i]=chr($k);
  }
  echo $s;

Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int sum = 0;

                for (int i = 0; i < n; i++)
                {
                    int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                    int s = input[0] + input[1] + input[2];
                    int w = input[3];

                    s = CheckS(s);
                    if (s == -1) continue;

                    w = CheckW(w);
                    if (w == -1) continue;

                    int rank = Math.Max(s, w);

                    sum += (600 + (200 * rank));
                }
                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }

        static int CheckS(int s)
        {
            if (s <= 60) return 0;
            if (s <= 80) return 1;
            if (s <= 100) return 2;
            if (s <= 120) return 3;
            if (s <= 140) return 4;
            if (s <= 160) return 5;
            return -1;
        }

        static int CheckW(int w)
        {
            if (w <= 2) return 0;
            if (w <= 5) return 1;
            if (w <= 10) return 2;
            if (w <= 15) return 3;
            if (w <= 20) return 4;
            if (w <= 25) return 5;
            return -1;
        }
    }
}

Measured memory_bytes: 9368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<29;
const ll LINF = 1LL<<58;

int n, m, q;
int A[60], B[60], C[60], D[60];
int ans;

void dfs(int j, vector<int> X) {
    if (j == n) {
        int ret = 0;
        rep(i, q) {
            if (X[B[i]] - X[A[i]] == C[i]) ret += D[i];
        }
        chmax(ans, ret);
        return;
    }

    for(int i = X.back(); i <= m; i++) {
        auto Y = X;
        Y.pb(i);
        dfs(j + 1, Y);
    }
    return;
}

void solve() {
    cin >> n >> m >> q;
    rep(i, q) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
    }
    vector<int> X(1, 1);
    dfs(0, X);
    cout << ans << endl;
    return;
}

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


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

using namespace std;

int main() {
    string s = "";
    cin >> s;
    int ans = 0, cnta = 0, cntz = 0;

    for (int i = 0; i < s.length(); ++i) {
        if (s.at(i) != 'A') {
            cnta++;
        } else {
            break;
        }
    }

    for (int i = s.length()-1; i >=0; --i) {
        if (s.at(i) != 'Z') {
            cntz++;
        }else{
            break;
        }
    }

    ans=s.length()-cnta-cntz;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
unordered_map<int,int>vis;
int n,k,a[N],sum[N];
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),sum[i]=(sum[i-1]+a[i])%k;
    int s=1;
    ll ans=0;
    vis[0]++;
    for(int i=1;i<=n;i++)
    {
        if(i==k)
            vis[0]--;
        else if(i>k)
            vis[((sum[i-k]-i+k)%k+k)%k]--;
        ans+=vis[((sum[i]-s)%k+k)%k];
        vis[((sum[i]-i)%k+k)%k]++;
        s=(s+1)%k;
    }
    printf("%lld\n",ans);
}
/*
3 4
1 4 2
*/


Measured memory_bytes: 10056
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pll pair<ll,ll>

ll N,x;
ll a[(int)1e6];

int main()
{
    cin >> N >> x;
    for(int i = 0;i < N;i++)
    {
        cin >> a[i];
    }
    ll count = 0;
    for(int i = 0;i < N-1;i++)
    {
        ll first = a[i] + a[i+1];
        if(first > x)
        {
            auto diff = first - x;
            a[i+1] -= min(a[i+1], diff);
            count += diff;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long;


void ABC075C()
{
	int N, M;
	cin >> N >> M;


	vector<pair<int, int> > edge;
	vector<vector<int> > x(N,vector<int>(N,0));
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		edge.push_back(make_pair(a, b));
		x[a][b] = x[b][a] = 1;
	}

	int ct = 0;
	stack<int> st;
	for (int i = 0; i < M; ++i)
	{
		int a = edge[i].first;
		int b = edge[i].second;
		x[a][b] = x[b][a] = 0;

		vector<int> arrival(N, 0);
		arrival[0] = 1;
		st.push(0);
		while (!st.empty())
		{
			auto k = st.top();
			st.pop();
			for (int j = 0; j < N; ++j)
			{
				if (x[k][j] > 0 && arrival[j] == 0)
				{
					arrival[j] = 1;
					st.push(j);
				}
			}
		}
		if (*min_element(arrival.cbegin(), arrival.cend()) == 0)
			++ct;
		x[a][b] = x[b][a] = 1;

	}
	cout << ct << endl;
}

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

Measured memory_bytes: 256
import sys
from collections import Counter

n, k, *a = map(int, sys.stdin.read().split())

def main():
    c = Counter(a)
    l = len(c)
    if l <= k:
        return 0

    c = sorted(c.items(), key=lambda x: x[1])
    res = 0
    for i in range(l - k):
        res += c[i][1]

    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 40336
X = int(input())

# A**5 - B**5, >0 A>B (Bminusあり)

for a in range(1000000):
  a5 = a ** 5
  for b in range(a-1,-1000000,-1):
    b5 = b**5
    if a5 - b5 == X:
      print(a,b)
      exit(0)
    elif a5 - b5 > X:
      break


Measured memory_bytes: 9112
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
#include <map>
using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	
	int A, B;
	cin >> A >> B;

	string U;
	cin >> U;

	if (S == U) {
		A -= 1;
	}
	else {
		B -= 1;
	}
	cout << A << " " << B << endl;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# int(input()) # 入力が1つ
n, k, q = map(int, input().split()) # 入力が複数
A = [0] * n
for _ in range(q):
    m = int(input())
    A[m - 1] += 1

for i in range(n):
    A[i] = k - (q - A[i])

for i in range(n):
    if A[i] <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 47196
#include <iostream>
using namespace std;
const int maxn = 100000;
int n,a[maxn+1];
int main() 
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	for (int i=1; i<=n; i++)
	cin >> a[i];
	int dem=0;
	for (int i=1; i<=n; i++)
	if (a[a[i]]==i) dem++;
	cout << dem/2;
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#define For(i,x,y) for(register int i=(x); i<=(y); i++)
using namespace std;
typedef long long ll;
const ll INF =0x3f3f3f3f3f3f3f3f;
int main()
{
    ll n, k,dis;
    cin>>n>>k;
    dis=n;
    if(n>k)
    {
        dis=min(n-k,dis);
        n=n%k;
        dis=min(dis,n);
    }
    ll temp=abs(n-k);
    dis=min(temp,dis);
    cout<<dis<<endl;
    return 0;
}


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

#define endl '\n'

void solvetask(){
    int n, ans = 0;
    double d;
    cin >> n >> d;
    for (int i=0; i<n; i++){
        double x, y; cin >> x >> y;
        if (sqrt(x*x + y*y) <= d) ans++;
    }
    cout << ans << endl;
}

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

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

int getAns(int A[], int n, int k){
    vector<int>dp(n+1, INT_MAX);

    dp[0] = 0;
    
    for(int i=1;i<=n;i++){
        for(int j=i-1;j>=0 && (i-j) <= k;j--){
            dp[i] = min(dp[i], dp[j] + abs(A[i]-A[j]));
        }
    }

    return dp[n-1];
}

int main() {
    int n, k; cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++) cin>>A[i];

    cout<<getAns(A, n, k);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int N, K, Q; cin >> N >> K >> Q;

    vector<int> A(Q+10, 0); rep(i,Q) cin >> A[i];

    vector<int> cnt(N+10, 0);
    rep(i,Q)
    {
        cnt[A[i]-1]++;
    }

    rep(i,N)
    {
        if (K + cnt[i] - Q > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1408
def nextTurn(a):
  if a == "a":
    return 0
  elif a == "b":
    return 1
  else:
    return 2
    
hand = [list(input()) for i in range(3)]
turn = nextTurn(hand[0].pop(0))
while(True):
  if len(hand[turn]) == 0:
    if turn == 0:
      print("A")
    elif turn == 1:
      print("B")
    else:
      print("C")
    break
  turn = nextTurn(hand[turn].pop(0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  vector<ll> X(m);
  vector<ll> diff;
  rep(i, m) cin >> X[i];
  sort(all(X));
  rep(i, m) if(i) diff.push_back(X[i]-X[i-1]);
  sort(all(diff));
  ll ans = 0;
  rep(i, m-n) ans += diff[i];
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 5060
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string a, b;
    cin >> a >> b;
    string c = a + b;
    int d = stoi(c);
    int e = sqrt(d);
    if(e * e == d) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let num: i32 = buf.trim().parse().unwrap();

    println!("{}", solve(num));
}

fn solve(num: i32) -> i32{
    let mut array = vec![num];
    let mut counter = 1;
    let mut current = num;
    let mut is_ever ;
    loop {
        counter += 1;
        is_ever = current % 2 == 0;
        match is_ever{
            false => current = 3 * current + 1,
            true => current = current / 2,
        }
        if array.contains(&current){
            return counter
        }

        array.push(current);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 3e3 + 5;
int n, a[M], dp[M][M][2];

int solve(int i, int j, int turn)
{
	if(i == j)	return (!turn ? a[i] : -a[i]);

	if(dp[i][j][turn] != -1)	return dp[i][j][turn];

	int c1 = (turn ? -a[i] : a[i]) + solve(i + 1, j, turn ^ 1);
	int c2 = (turn ? -a[j] : a[j]) + solve(i, j - 1, turn ^ 1);
	int ans = max(c1, c2);
	if(turn)
		ans = min(c1, c2);

	return dp[i][j][turn] = ans;	
}

int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++)	cin >> a[i];
	memset(dp, -1, sizeof dp);
	cout << solve(0, n - 1, 0) << "\n";
    return 0;
}


Measured memory_bytes: 141568
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
  int h, w; cin >> h >> w;
  vector<vector<char>> c(h+1, vector<char>(w+1, '.'));
  rep(i, h){
    rep(j, w){
      cin >> c.at(i).at(j);
    }
  }

  rep(i, 2*h){
    rep(j, w){
      int t = i/2;
      cout << c.at(t).at(j);
    }
    cout << endl;
  }

  
  return 0;
}


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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');

            int H = int.Parse(input1[0]);
            int W = int.Parse(input1[1]);

            char[][] field = new char[H][];
            int[,] ans = new int[H,W];

            string input2;

            for (int i = 0; i < H; i++)
            {
                input2 = Console.ReadLine();
                field[i] = input2.ToCharArray();

            }

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (field[i][j] == '#')
                    {
                        ans[i,j] = -1000;

                        for (int i1 = i - 1; i1 <= i + 1; i1++)
                        {
                            for (int j1 = j - 1; j1 <= j + 1; j1++)
                            {
                                if (i1 >= 0 && i1 < H && j1 >= 0 && j1 < W)
                                {
                                    ans[i1,j1]++;
                                }
                            }
                        }

                    }
                }
            }

            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (ans[i,j] < 0)
                    {
                        Console.Write('#');
                    }
                    else
                    {
                        Console.Write(ans[i,j]);
                    }
                }
                Console.WriteLine("");
            }
        }
    }
}


Measured memory_bytes: 11220
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    priority_queue<ll, vector<ll>, greater<ll> >Q;
    rep1(i, 9)Q.push(i);
    ll K;
    cin >> K;
    rep1(i, K){
        ll n = Q.top();
        Q.pop();
        if(i == K)cout << n << endl;
        Q.push(n * 10 + n % 10);
        if(n % 10 != 0)Q.push(n * 10 + n % 10 - 1);
        if(n % 10 != 9)Q.push(n * 10 + n % 10 + 1);
    }
    


    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

 
void solve(){
    int n;
    cin >> n;
    double ans = 0;
    while(n--){
        double x;
        string u;
        cin >> x >> u;
        if(u == "BTC"){
            ans += x * 380000;
        }
        else ans += x;
    }
    cout << fixed << setprecision(6) << ans;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
n, m, q = map(int, input().split())
pairs = [list(map(int, input().split())) for i in range(q)]
ans = 0
combos = []

def f(l):

    if len(l) == n:
        combos.append(l)
        return

    start = 1 if len(l) == 0 else l[-1]

    for i in range(start, m + 1):
        f(l + [i])

f([])

for combo in combos:
    tmp = 0
    for pair in pairs:
        if combo[pair[1]-1] - combo[pair[0]-1] == pair[2]:
            tmp += pair[3]
    ans = max(tmp, ans)

print(ans)

Measured memory_bytes: 22804
x, y = map(int, input().split())

ans = None

if x < 0:
    if y < x:
        ans = x - y + 2
    elif y <= 0:  # x <= y < 0
        ans = y - x
    else:
        ans = max(abs(x), abs(y)) - min(abs(x), abs(y)) + 1
elif x == 0:
    if y < x:
        ans = x - y + 1
    else:
        ans = y - x
else:
    if y >= x:
        ans = y - x
    elif x > y > 0:
        ans = x - y + 2
    elif y == 0:
        ans = x - y + 1
    else:
        ans = max(abs(x), abs(y)) - min(abs(x), abs(y)) + 1

print(ans)

Measured memory_bytes: 38384
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

m = 10
l = 0

for i in [A,B,C,D,E]:
    j = i // 10
    l += j * 10
    if i % 10 != 0:
        m = min(i%10,m)
        l += 10
        
l += m - 10
print(l)

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

typedef long long LL;
const LL N = 10010;
LL a[N], b[N], c[N];
LL n;
bool v[N];

inline LL gcd(LL a, LL b)
{
    return (b ? gcd(b, a % b) : a);
}
bool ok(int p) {
    if (a[0] % p) {
        return false;
    }
    for (int i = 0; i <= n; ++i) {
        b[i] = a[i];
    }
    for (int i = n; i >= p - 1; --i) {
        (b[i - (p - 1)] += b[i]) %= p;
        b[i] = 0;
    }
    for (int i = 0; i <= n; ++i) {
        if (b[i] % p) {
            return false;
        }
    }
    return true;
}
bool isprime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)return false;
    }
    return true;
}
int main()
{
    register LL p = 0, num = 0;
    scanf("%lld", &n);
    for (register LL i = n; i >= 0; --i) {
        scanf("%lld", &a[i]);
        p = gcd(p, abs(a[i])), b[i] = a[i];
    }
    /*for (register LL i = 2, q; i <= n; ++i) {
        if (v[i] == 1) continue;
        for (register LL j = 0; j <= n; ++j)
            a[j] = b[j];
        for (register LL j = n; j >= i - 1; --j)
            a[j - (i - 1)] = (a[j] + a[j - (i - 1)]) % i, a[j] = 0;
        int f=0;
        for (register LL j = 0; j <= n; ++j) {
            if (a[j] % i != 0) //goto nxt;
            {
                f=1;
                break;
            }
        }
        if(!f) c[++num] = i;
        //nxt:;
        q = n / i;
        for (register LL j = i; j <= q; ++j)
            v[i * j] = 1;
    }*/
    for(int i=2;i<=n;i++)
    {
        if(isprime(i)&&ok(i))c[++num]=i;
    }
    for (register LL i = 2; i*i <= p; ++i) {
        if (p % i == 0) {
            c[++num] = i;
            while (p % i == 0) p = p / i;
        }
    }
    if (p > 1) c[++num] = p;
    sort(c + 1, c + num + 1);
    for (register int i = 1; i <= num; ++i) {
        if (c[i] == c[i - 1]) continue;
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << "a > b" << endl;
	} else if (a < b) {
		cout << "a < b" << endl;
	}
	  else if (a == b) {
	    cout << "a == b" << endl;
	}
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int cnt = 0;
	while (n > 0) {
		cnt += n % 10;
		n /= 10;
	}
	if (cnt == 1) {
		cout << 10 << endl;
	}
	else {
		cout << cnt << endl;
	}
	
}

Measured memory_bytes: 256
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    c = collections.Counter()
    for _ in range(K):
        D = int(input())
        A = [int(x) for x in input().split()]
        for a in A:
            c[a] += 1

    ans = 0
    for i in range(1, N + 1):
        if c[i] == 0:
            ans += 1

    print(ans)

        


if __name__ == '__main__':
    main()


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  string s; cin>>s;
  int l = s.size();
  for (int i=l-2; i; i-=2) {
    if (strncmp(s.c_str(), s.c_str()+i/2, i/2)==0) {
      cout << i << endl;
      return;
    }
  }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;

int main() {
int ans = 0;
	int N, a, b;
	cin >> N >> a >> b;
	for(int i=0; i<N; i++) {
		int p,q;
		cin >> p ;
		if(!(a<=p && p < b)) ans++;
	}
	cout << ans << endl;
	return 0;
}



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

def prime_or(num):
    mx = int(num**(1/2))
    
    for i in range(2,mx):
        if(num%i == 0):
            return 0
    
    return 1
    
flag = 0
st = n
while True:
    if(prime_or(st)==1):
        print(st)
        break
    else:
        st += 1

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int p=1000000007;
struct node { LL x,y; } a[102*102];
LL F[102],x,y,X,Y;
int S[102],E[102],i,j,k,n,m,T,g,Z,an;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

LL read(){ LL z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

bool cmp(node a,node b){ return a.x<b.x; }

int gcd(LL a,LL b)
{
	int z=0;
	if (a<b) swap(a,b);
	while (b)
		a%=b,swap(a,b);
	return z;
}

void solve()
{
	S[1]=1,E[1]=g=2,a[1]=(node){1,2},a[2]=(node){1,3};
	for (i=2;i<=85;++i)
	{
		S[i]=g+1;
		for (j=S[i-1];j<=E[i-1];++j)
		{
			x=a[j].x,y=a[j].y;
			if (x+y<=F[i+2])
				a[++g]=(node){y,x+y};
			if (x+(y<<1)<=F[i+2])
				a[++g]=(node){y,x+(y<<1)};
		}
		sort(a+S[i],a+g+1,cmp);
		k=S[i];
		for (j=S[i]+1;j<=g;++j)
			if (a[k].x!=a[j].x||a[k].y!=a[j].y)
				a[++k]=a[j];
		E[i]=k;
	}
}

int main()
{
	T=read();
	for (F[0]=F[1]=1,i=2;i<=90;++i) F[i]=F[i-1]+F[i-2];
	solve();
	while (T--)
	{
		an=0,X=read(),Y=read();
		if (X>Y) swap(X,Y);
		
		for (Z=2;F[Z]<=X&&F[Z+1]<=Y;++Z);
		--Z;
		printf("%d ",Z);
		if (Z==1)
			printf("%d\n",X%p*(Y%p)%p);
		else
		{
			for (i=S[Z-1];i<=E[Z-1];++i)
			{
				x=a[i].x,y=a[i].y;
				if (y<=X)
					an=(an+(Y-x)/y)%p;
				if (y<=Y)
					an=(an+(X-x)/y)%p;
			}
			printf("%d\n",an);
		}
	}
	return 0;
}

Measured memory_bytes: 12672
function Main(input) {
  [a, b] = input.split(' ');
  a = parseInt(a);
  b = parseInt(b);
  if (a < b) {
    console.log('a < b');
  } else if (a > b) {
    console.log('a > b');
  } else {
    console.log('a == b');
  }
}

function debug() {
  input = document.getElementById('id1').value;
  Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 15108
#import sys
#input = sys.stdin.readline

def main():
  A, B, M = map(int, input().split())
  reizoko = list(map(int, input().split()))
  renji = list(map(int, input().split()))
  x = [0] * M
  y = [0] * M
  c = [0] * M
  for i in range(M):
    x[i], y[i], c[i] = map(int, input().split())
  waribiki = []
  ans = []
  ans.append((min(reizoko)) + (min(renji)))
  for i in range(M):
    waribiki.append(reizoko[x[i]-1] + renji[y[i]-1] - c[i])
  ans.append(min(waribiki))
  print(min(ans))
  

if __name__ == '__main__':
  main()

Measured memory_bytes: 76012
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

vector<vector<ll>> adj;
vector<bool> visited;
vector<ll> comp;

bool mysort(pair<ll,ll> A, pair<ll,ll> B){
    if(A.first == B.first) return A.second < B.second;
    return A.first < B.first;
}

void mydfs(ll scr){
    visited[scr] = true;
    for(auto i:adj[scr]){
        if(!visited[i]) mydfs(i);
    }
}

void virus(){
    ll len,fct;
    cin>>len>>fct;
    set<pair<ll,ll>> uniq;
    for(auto i=0; i<fct; i++){
        ll ini, fnl;
        cin>>ini>>fnl;
        if(ini > fnl) swap(ini,fnl);
        uniq.insert({ini,fnl});
    }
    vector<pair<ll,ll>> arr(uniq.begin(),uniq.end());
    sort(all(arr),mysort);
    ll actlen = (ll)arr.size();
    adj.resize(len); visited.resize(len,false);
    for(auto i:arr){
        adj[i.first-1].push_back(i.second-1);
        adj[i.second-1].push_back(i.first-1);
    }
    ll cp = 0;
    for(auto i=0; i<len; i++){
        if(!visited[i]){
            mydfs(i);
            cp++;
        }
    }
    cout<<cp-1<<endl;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}


Measured memory_bytes: 17716
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a); i < (b); ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1); i >= (b); --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) RP(__i,n)
template<class T>
void cmax(T & a, T b) {a = max(a, b);}
template<class T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)(a).size())
#define ALL(a) begin(a), end(a)
#define CLR(a) (a).clear()
#define BK(a) ((a).back())
#define FT(a) ((a).front())
#define DB(a) (a).pop_back()
#define DF(a) (a).pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<class T, class ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		for (char x : "([{") c += *s == x;
		for (char x : ")]}") c -= *s == x;
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD() {return 1;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<class T, class ... TT>
bool RD(T & a, TT & ... b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define DR(T,...) T __VA_ARGS__; RD(__VA_ARGS__)
#define RI(...) DR(int,__VA_ARGS__)

/* For it's time for you to fulfill your output. */
void PT(const char & a) {putchar(a);}
void PT(char const * const & a) {fputs(a, stdout);}
void PT(const double & a) {printf("%.16f", a);}
void PT(const int & a) {printf("%d", a);}
void PT(const ll & a) {printf("%lld", a);}

/* The line will last forever! */
template<char s = ' ', char e = '\n'>
void PL() {if (e) PT(e);}
template<char s = ' ', char e = '\n', class T, class ... TT>
void PL(const T & a, const TT & ... b)
{PT(a); if (sizeof...(b) && s) PT(s); PL<s,e>(b...);}

/* Good Luck && Have Fun ! */
int main()
{
	RI(n);
	int ans = 0, c = 0;
	RP1(i,n) {
		RI(p);
		if (p == i)
			++c;
		else {
			ans += (c + 1) / 2;
			c = 0;
		}
	}
	PL(ans += (c + 1) / 2);
}


Measured memory_bytes: 256
s1 = input()
s2 = input()
dp = [[0 for i in range(len(s2)+1)] for j in range(len(s1)+1)]
for i in range(len(s2)+1):
    dp[0][i] = i
for i in range(len(s1)+1):
    dp[i][0] = i
for i in range(1, len(s1)+1):
    for j in range(1, len(s2)+1):
        if s1[i-1] == s2[j-1]:
            dp[i][j] = dp[i-1][j-1]
        else:
            cost = 0 if s1[i-1] == s2[j-1] else 1
            dp[i][j] = min(dp[i-1][j]+1, dp[i][j-1]+1, dp[i-1][j-1]+cost)
print(dp[-1][-1])



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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int A, B;
  cin >> A >> B;
  cout << max(A-2*B, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int n;
    int i;
    int x;
    scanf("%d", &n);
    for( i = 1; i <= n; ++i){
        if( i%3 == 0 ){
            printf(" %d", i);
        }else{
            x = i;
            while(x){
                if( x%10 == 3){
                    printf(" %d", i);
                    break;
                }
                x /= 10;
            }
        }
    }
    printf("\n");
    return 0;
}

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

def main():
    blue = [input() for i in range(int(input()))]
    red = [input() for i in range(int(input()))]
    l = list(set(blue))
    print(max(0, max(blue.count(l[i]) - red.count(l[i]) for i in range(len(l)))))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9048
a,b,c,d,s="%d %d\n";main(n){for(;scanf(s+3,&n),n;printf(s,c,d))for(c=d=0;n--;*(a<b?&d:&c)+=a,*(b<a?&c:&d)+=b)scanf(s,&a,&b);}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
//  cout << (N-N%100)/100 << (N%100-N%10)/10  << N%10 << endl;
  if((N-N%100)/100==7 || (N%100-N%10)/10==7||N%10==7){
    cout << "Yes";
  }else {
    cout << "No";
  }
}


Measured memory_bytes: 3632