akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int m = Integer.parseInt(in.next());
            int k = Integer.parseInt(in.next());
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            int[] b = new int[m];
            for (int i = 0; i < m; i++) {
                b[i] = Integer.parseInt(in.next());
            }
            long[] sum_a = new long[n + 1];
            for (int i = 1; i < n + 1; i++) {
                sum_a[i] = sum_a[i - 1] + a[i - 1];
            }
            long[] sum_b = new long[m + 1];
            for (int i = 1; i < m + 1; i++) {
                sum_b[i] = sum_b[i - 1] + b[i - 1];
            }
            int ans = 0;
            int j = m;

            for (int i = 0; i < n + 1; i++) {
                if (sum_a[i] > k) break;
                while (sum_b[j] > k - sum_a[i]) {
                    j -= 1;
                }
                ans = Math.max(ans, i + j);
            }
            // 出力
            out.println(ans);
        }

    }
}



Measured memory_bytes: 60256
#include<stdio.h>
#include<string.h>
int main(){
  char s[100];
  int k;
  
  scanf("%d",&k);
  scanf("%s",s);
  if(strlen(s)>k){
    s[k]='.';
    s[k+1]='.';
    s[k+2]='.';
    s[k+3]=0;
  }
  
  printf("%s",s);
  return 0;
}

Measured memory_bytes: 1732
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

alpha = "abcdefghijklmnopqrstuvwxyz"

s = raw_input()
K = int(raw_input())
dic = dict([alpha[i], i] for i in xrange(len(alpha)))

ans = [] 
for si in s:
    d = 26 - dic[si] if si != "a" else 0
    if d <= K:
        ans.append("a")
        K -= d
    else:
        ans.append(si)

if K > 0:
    ans[-1] = alpha[(dic[ans[-1]] + K) % 26]

print "".join(ans)


Measured memory_bytes: 5284
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>

using namespace std;

set<string> S[100];
map<string, int> mp;
vector< vector<string> > vs;

int search(int cur){
	for(int i=0;i<vs[cur].size();i++){
		if(mp.count(vs[cur][i])){
			int next = mp[vs[cur][i]];
			if(S[next].empty()) search(next);
			for(set<string>::iterator it=S[next].begin();it!=S[next].end();it++)
				S[cur].insert(*it);
		}
		else{
			S[cur].insert(vs[cur][i]);
		}
	}
	return S[cur].size();
}

int main(){
	int n;
	while(cin >> n, n){
		mp.clear();
		vs.assign(n, vector<string>());
		for(int i=0;i<n;i++){
			S[i].clear();
			string str; cin >> str;
			for(int j=0;j<str.size();j++)
				if(!islower(str[j])) str[j] = ' ';
			istringstream iss(str);
			iss >> str; mp[str] = i;
			while(iss >> str) vs[i].push_back(str);
		}
		cout << search(0) << endl;
	}
}

Measured memory_bytes: 0
from collections import deque

while True:
  w,h = map(int,input().split())
  ww = w*2-1
  hh = h*2-1
  if w == 0:
    break
  field = [input() for _ in range(hh)]
  d = [[0]*(ww) for _ in range(hh)]
  q = deque()
  q.append([0,0])
  dmov = [(-1,0),(1,0),(0,-1),(0,1)]
  d[0][0] = 1
  
  while len(q) > 0:
    node = q.popleft()
    x = node[0]
    y = node[1]
    c = d[y][x]
    for i,j in dmov:
      xx = x+i
      yy = y+j
      xxx = xx+i
      yyy = yy+j
      if 0<=xx<ww and 0<=yy<hh:
        if d[yyy][xxx] == 0 and field[yy][xx] == "0":
          d[yyy][xxx] = c+1
          q.append([xxx,yyy])
  print(d[hh-1][ww-1])


Measured memory_bytes: 6084
n,m = [int(it) for it in input().split()]

lm,rm = 0,n+1
for i in range(m):
  l,r = [int(it) for it in input().split()]
  lm = max(l,lm)
  rm = min(r,rm)
s = max(rm - lm + 1,0)
print ( s )

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  in(string, s);
  rep(i, s.size()) s[i] = (s[i] - 'A' + n) % 26 + 'A';
  out(s);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.14159265358979323846
using namespace std;
int main(){
    int m;
    cin>>m;
    vector<int>v;map<int,int>m1;
    for(int i=0;i<m-1;i++ ){
        int x;cin>>x;v.push_back(x);
        m1[x]++;
    }
    for(int i=1;i<=m;i++){
        if(m1[i])cout<<m1[i]<<endl;
        else cout<<"0"<<endl;
    }
    
    return 0;
    
}

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

using namespace std;
using ll = long long;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (auto &a: A) {
    cin >> a;
  }

  vector<int> visited(N,-1);
  vector<int> cycle;
  int town = 1;
  while(1) {
    visited[town - 1] = cycle.size();
    cycle.push_back(town);
    if (cycle.size() == K + 1) {
      cout << town << endl;
      return 0;
    }
    town = A[town-1];
    //    cout << i << " " << town << endl;
    if (visited[town-1] != -1) break;
  }

  int ivisit = visited[town-1];
  int ncycle = cycle.size()-ivisit;
  //  cout << "visited: " << ivisit << endl;
  //  cout << "ncycle: " << ncycle << endl;
  cout << cycle[ivisit+(K-ivisit)%ncycle] << endl;
  //  cout << "idx: " << ivisit+(K-ivisit)%ncycle << endl;
    
  //  for (auto i: cycle) {
  //    cout << i << " ";
  //  }
  //  cout << endl;
  return 0;
}


Measured memory_bytes: 5832
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int n, m, k;

int ct_n[nax];
int ct_m[nax];

vector <pair <int, int>> a;
vector <int> b[nax];

int main() {
    clock_t start = clock();
    scanf("%d %d %d", &n, &m, &k);

    while ((clock() - start) / double(CLOCKS_PER_SEC) < 2.6);

    for (int i = 1 ; i <= k ; ++ i) {
        int h, w;
        scanf("%d %d", &h, &w);
        ++ ct_n[h];
        ++ ct_m[w];
        a.emplace_back(h, w);
        b[h].emplace_back(w);
    }

    int ans = 0;

    multiset <int> naive;

    for (auto [x, y] : a) {
        ans = max(ans, ct_n[x] + ct_m[y] - 1);
    }

    for (int i = 1 ; i <= m ; ++ i) {
        naive.insert(ct_m[i]);
    }

    for (int i = 1 ; i <= n ; ++ i) {
        for (int j : b[i]) {
            naive.erase(naive.find(ct_m[j]));
        }

        int res = naive.empty() ? 0 : *naive.rbegin();
        ans = max(ans, ct_n[i] + res);
        for (int j : b[i])
            naive.insert(ct_m[j]);
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 38392
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    
    int takahashi_P,takahashi_A,aoki_P,aoki_A;
    int i, j, k;
    long long ans;
    string ans_str="Yes";
    
    cin >> takahashi_P >> takahashi_A >> aoki_P >>aoki_A;
    
    while(takahashi_P > 0 && aoki_P >0){
        
        //takahashi attacks
        
        aoki_P = aoki_P - takahashi_A;
        
        if(aoki_P<=0){
            break;
        }
        
        takahashi_P = takahashi_P - aoki_A;
        
        if(takahashi_P<=0){
            ans_str = "No";
            break;
        }
        
        //aoki attackes
        
    }
    
    cout << ans_str << endl;
    
}

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

int main() {
    int n;
    cin >> n;
    set <string> st;
    while(n--) {
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << (int)st.size() << endl;
    return 0;
}

Measured memory_bytes: 19220
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
//constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

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

int main(){
    int n,p;
    string s;
    cin>>n>>p>>s;
    ll ans=0;
    if(p==2||p==5){
        rep(i,n){
            int d=s[i]-'0';
            if(d%p==0){
                ans+=i+1;
            }
        }
        cout<<ans<<endl;
        return 0;
    }
    int cnt[p]={1};
    int r=0;
    for(int i=n-1;i>=0;--i){
        int d=s[i]-'0';
        r=(d*modpow(10%p,n-1-i,p)+r)%p;
        ans+=cnt[r];
        ++cnt[r];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 644
def main():
    n, w = tuple([int(e) for e in input().split()])
    items = []
    for i in range(n):
        items.append(tuple([int(e) for e in input().split()]))
    items.sort(key=lambda x: x[0])
    
    t = [[0] * (n + 1) for _ in range(w + 1)]
    for i in range(1, w + 1):
        for j in range(1, n + 1):
            if i - items[j - 1][0] >= 0:
                t[i][j] = t[i - items[j - 1][0]][j - 1] + items[j - 1][1]
            t[i][j] = max(t[i][j], t[i][j - 1], t[i - 1][j], t[i - 1][j - 1])
    print(t[w][n])
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 130652
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int n = sc.nextInt();

    
		// 出力
		System.out.println(1.0 - (double)Math.floor(n / 2) / n);
	}
}

Measured memory_bytes: 21460
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>

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

int main( void ){
	int n;
	if (!scanf( "%d", &n ))
		return -1;
	int* A = new int[ n ];
	int* B = new int[ n ];
	int* C = new int[ n - 1 ];
	rep( i, 0, n ){
		if (!scanf( "%d", A + i ))
			return -1;
		A[ i ]--;
	}
	rep( i, 0, n ){
		if (!scanf( "%d", B + i ))
			return -1;
	}
	rep( i, 0, n - 1 ){
		if (!scanf( "%d", C + i ))
			return -1;
	}
	int sum = 0;
	int pre_num = A[ 0 ];
	rep( i, 0, n ){
		sum += B[ A[ i ] ];
		if (A[ i ] == pre_num + 1)
			sum += C[ A[ i ] - 1 ];
		pre_num = A[i];
	}
	printf( "%d\n", sum );
}


Measured memory_bytes: 384
'use strict';
const p = s => console.log(s);

// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  let N = input[0].split(" ")[0];

  p(2 * Math.PI * N);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29596
#!/usr/bin/perl

my ($n) = map {$_ - 0} split(/\s+/o,<STDIN>);

my @d =();
for(my $i=0;$i<$n;$i++){
  my $dd = <STDIN>;
  $dd =~ /^\d+/o;
  my $dd1 = $&;
  $dd1 -= 0;
  push(@d,sprintf("%03d",$dd1));
}

my @d2 = sort @d;

my %d3 = ();
foreach my $x (@d2){
  $d3{$x} = 1;
}

my @d4 = keys %d3;

my $r = 1 + $#d4;

print "$r\n";

exit(0);




Measured memory_bytes: 512
import java.util.*;
class Main{

public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
long a[]=new long[n];
long f[]=new long[n];
long b[]=new long[n];
for(int i=0;i<n;i++) a[i]=Long.parseLong(sc.next());
for(int i=0;i<n;i++){
if(i==0){
f[i]=a[i];
b[n-i-1]=a[n-i-1];
}
else{
f[i]=gcd(f[i-1], a[i]);
b[n-i-1]=gcd(b[n-i], a[n-i-1]);
}
}
long ans=1;
for(int i=0;i<n;i++){
if(i==0) ans=Math.max(ans, b[i+1]);
else if(i==n-1) ans=Math.max(ans, f[i-1]);
else ans=Math.max(ans, gcd(f[i-1], b[i+1]));
}
System.out.println(ans);
}
static long gcd(long a, long b){
if(a<b) return gcd(b, a);
long r=a%b;
while(r>0){
a=b;
b=r;
r=a%b;
}
return b;
}

}

Measured memory_bytes: 48352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59



int main(){
  ll i,j;
  ll x,a;
  cin>>x>>a;
  if(x<a) cout<<0<<endl;
  else cout<<10<<endl;
  return 0;
  
}

Measured memory_bytes: 256
package main

import "fmt"

const mod = 2019

func main() {
	var s string
	fmt.Scan(&s)
	s = reverse(s)

	ms := make(map[int]int)
	ms[0] = 1

	m := 0
	x := 1
	ans := 0
	for i := 0; i < len(s); i++ {
		m = (m + int(s[i]-'0')*x) % mod
		ans += ms[m]
		ms[m]++
		x *= 10
		x %= mod
	}
	fmt.Println(ans)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 4448
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;cin >> n;
    int count = 0;

    for (int i=0;i<=n;i++){
        int tmpCount = 0;

        if (i%2 == 1){
            for(int j=1;j<=i;j++) {
                if (i%j ==0) {
                    tmpCount++;
                }
            }
        } else {
            continue;
        }

        if (tmpCount == 8){
            count++;
        } 
    }

    cout << count << endl;
    return 0;
}

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

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var n = int.Parse(System.Console.ReadLine());
        var nums = System.Console.ReadLine().Split(' ').Select(long.Parse);

        Dictionary<long, int> dic = new Dictionary<long, int>();

        foreach(var num in nums)
        {
            if (dic.ContainsKey(num))
            {
                System.Console.WriteLine("NO");
                return;
            }
            dic.Add(num, 0);
        }
        System.Console.WriteLine("YES");
    }


}



Measured memory_bytes: 40016
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int par[100010];
int root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = root(par[x]);
	}
}
int main() {
	int n, q, a, b;
	int x, y;
	cin >> n >> q;
	for (int i = 1; i <= n; i++) {
		par[i] = i;
	}
	for (int j = 0; j < q; j++) {
		cin >> a >> b;
		x = root(a);
		y = root(b);
		if (x != y) {
			par[x] = y;
		}
	}
	set<int> st;
	for (int i = 1; i <= n; i++) {
		st.insert(root(i));
	}
	cout << st.size() - 1 << endl;
	return 0;
}


Measured memory_bytes: 7968
#include <iostream>
#include <algorithm>
#include <array>
#include <queue>

using namespace std;

int const Inf = 10000000;
int const N = 100;

typedef array<int, 2> line;

struct tg { int c, v; };
bool operator>( tg const& lhs, tg const& rhs )
{
    return lhs.c > rhs.c;
}

int main()
{
    int n, m;
    priority_queue<tg, vector<tg>, greater<tg>> w;

    while( cin >> n >> m, n||m ) {
        line table[N][N] = {};

        for( int i=0; i<n; ++i ) {
            int a, b, cost, time;
            cin >> a >> b >> cost >> time;

            int const from = a-1, to = b-1;
            line const in = {{cost, time}};
            table[from][to] = ( table[to][from] = in );
        }

        int k;
        cin >> k;
        for( int i=0; i<k; ++i ) {
            int p, q, r;
            cin >> p >> q >> r;
            int const from = p-1, to = q-1;

            bool v[N] = {};
            int d[N];
            fill( d, d+N, Inf );

            tg const val = { 0, from };
            w.push( val );
            d[from] = 0;

            while( !w.empty() ) {
                int const cur = w.top().v;
                w.pop();

                if ( v[cur] )
                    continue;
                v[cur] = true;

                for( int ii=0; ii<m; ++ii ) {
                    if ( table[cur][ii][0] == 0 )
                        continue;

                    if ( d[cur] + table[cur][ii][r] < d[ii] ) {
                        d[ii] = d[cur] + table[cur][ii][r];
                        tg const val = { d[cur] + table[cur][ii][r], ii };
                        w.push( val );
                    }

                    //cout << cur+1 << " -> " << ii+1 << " c " << d[ii] << endl;
                }
                

            }

            cout << d[to] << endl;
        }
    }
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;
const LL P = 1e9+7;
const int N = (1<<18)+5;

int h, n, x, a[N], ans = 0;
LL prod[N], sumprod[N];

LL pw(LL x, int n){
	LL res = 1;
	for(;n;n>>=1,x=x*x%P) if(n&1) res=res*x%P;
	return res;
}

void workl(int l, int r, LL div, bool flag){
	rep(i,l,r){
		LL x = prod[i] * div % P * a[i] % P;
		for(LL y = a[i]>>1; y; y>>=1){
			x = x * y % P;
			if (flag) (sumprod[y] += x) %= P;
			else sumprod[y] = 0;
		}
	}
}

LL workr(int l, int r){
	LL res = 0;
	rep(i,l,r){
		LL x = prod[i] * a[i] % P, done = 0;
		for(LL y = a[i]>>1; y; y>>=1){
			res = (res + (sumprod[y] - done) * x) % P;
			done = sumprod[y] * (y>>1) % P;
			x = x * y % P;
		}
	}
	return (res+P) % P;
}

int main(){
	scanf("%d",&h);
	n = 1<<h-1;
	rep(i,n,2*n-1) scanf("%d",&x), a[i] = n+x-1;
	
	prod[1] = 1;
	rep(i,2,n*2-1) prod[i] = prod[i>>1] * i % P;
	
	rep(k,1,h-1) rep(i,1<<k-1,(1<<k)-1){
		int l = i<<h-k, r = (i+1<<h-k)-1, mid = l+r>>1;
		int div = pw(prod[i]*prod[i]%P,P-2) * i % P;
		workl(l,mid,div,true);
		ans = (ans + workr(mid+1,r)) % P;
		workl(l,mid,div,false);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 7264
from sys import stdin

n,k = [int(x) for x in stdin.readline().rstrip().split()]

point = 0
kaku = 0.0

for i in range(1,n+1):
    point = 0
    point += i
    kaisu = 0
    while 0 < point < k:
        kaisu += 1
        point *= 2
    kaku += (1/n)*(1/(2**kaisu))
print(kaku)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[30],b[30];
int ans;
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(int i=1;i<=n;i++){
		if(b[i]<a[i])
			ans+=(a[i]-b[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define A 1
#define C 2
#define G 3
#define T 4
ll dp(int i,int a,int b,int c);
ll memo[109][5][5][5];
int n;

int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n;
  cout<<dp(0,0,0,0)<<endl;
  return(0);
}

ll dp(int i,int a,int b,int c){
  ll rec=0;
  if(memo[i][a][b][c]!=-1)return memo[i][a][b][c];
  if(i==n)return 1;
  rec+=dp(i+1,b,c,A);
  if(!(b==A&&c==G)&&!(a==A&&b==G)&&!(a==A&&c==G)&&!(b==G&&c==A)){
    rec+=dp(i+1,b,c,C);
  }
  if(!(b==A&&c==C)){
    rec+=dp(i+1,b,c,G);
  }
  rec+=dp(i+1,b,c,T);
  return memo[i][a][b][c]=rec%mod;
}

// AGC
//AG C
//A GC
// GAC
// ACG


Measured memory_bytes: 384
from sys import stdin


def get_result(data):
    N = data[0]
    if '7' in list(str(N)):
        return 'Yes'
    return 'No'


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 9200
//auto 関数名 = [(&:ラムダ外の引数をとる時))](引数の型1 引数名1, 引数の型2, 引数名2, ...) { 関数の処理 }; //inside main() define function. take care of };
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }
// sort(配列変数.begin(), 配列変数.end());
// do {
//   // 順列に対する処理
// } while (next_permutation(配列変数.begin(), 配列変数.end()));
//const double PI = acos(-1); M_PI
// cout << fixed << setprecision(10);
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG /GCC環境下で[]による配列要素参照のエラーを出す
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end() //sort(all(vec)); ,reverse(all(vec));etc

int main(){
int n;
cin>>n;
while(n!=0){
vector<int> vec(n);

double sum =0;
double powsum=0;
rep(i,n){
  cin>>vec.at(i);
  sum+=vec.at(i);
  powsum+=(vec.at(i)*vec.at(i));
}
double a;
a=sqrt(powsum/n-(sum*sum)/(n*n));
cout<<fixed<<setprecision(10);
cout<<a<<endl;
cin>>n;
}
}


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

void trace(vector<int> &a,int N){
  for(int i=0;i<N;i++){
    if(i){
      cout<<" ";
    }
    cout<<a[i];
  }
  cout<<endl;
  
}

int selectionsort(vector<int> &v,int N){
  int cnt=0;
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(v[j]<v[minj]){
        minj=j;
      }
    }
    if(i !=minj){
      swap(v[i],v[minj]);
      cnt++;
    }
  }
  return cnt;
}
int main() {
  int N,T;
  cin>>N>>T;
  
  bool flg=false;
  int minv=1001;
  for(int i=0;i<N;i++){
    int c,t;
    cin >>c>>t;
    if(t<=T){
      minv=min(minv,c);
      flg=true;
    }
  }
  if(flg){
    cout<<minv<<endl;
  }
  else{
    cout<<"TLE"<<endl;
  }
}

Measured memory_bytes: 256
import sys
import copy

input = sys.stdin.readline

A = None


def dfs(i, v):
    global A
    v.add(i)

    ans = 0
    for j in A[i]:
        if j not in v:
            v2 = copy.deepcopy(v)
            ans += dfs(j, v2)

    if len(A) - 1 == len(v):
        ans += 1
    return ans


def main():
    global A
    N, M = [int(x) for x in input().split()]
    A = [[] for j in range(N + 1)]
    for _ in range(M):
        a, b = [int(x) for x in input().split()]
        A[a].append(b)
        A[b].append(a)

    print(dfs(1, set()))


if __name__ == '__main__':
    main()


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

int a[110][110];

int main()
{
    int r,c;
    cin >> r >> c;
    for(int i = 0;i<r;i++){
        for(int j = 0;j<c;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int count = 0;
    for(int i = 0;i<=r;i++){
        for(int j = 0;j<=c;j++){
            if(i!=r && j==c){
                a[i][j] = count;
                count = 0;
            }else if(i != r && j !=c){
                count += a[i][j];
            }else if(i == r){
                for(int k=0;k<r;k++){
                    count += a[k][j];
                }
                a[i][j] = count;
                count = 0;
            }
        }
    }

    for(int i = 0;i<=r;i++){
        for(int j = 0;j<=c;j++){
            if(j!=c) printf("%d ",a[i][j]);
            if(j==c) printf("%d",a[i][j]);
        }
        printf("\n");
    }
       
    

    return 0;
}


Measured memory_bytes: 3252
#include<stdio.h>

char s[10], c;
int l, i, cnt, ok=1;

int main(void){
        while((c=getchar())!='\n') s[l++] = c;
        for(i=0; i<l; i++){
                if('a'<=s[i] && s[i]<='z') cnt++;
                else if(s[i]=='C'){
                        if(i<2 || l-2<i) ok = 0;
                }
                else if(s[i]=='A'){
                        if(i!=0) ok = 0;
                }
                else ok = 0;
        }
        if(cnt!=l-2) ok = 0;
        if(ok) puts("AC");
        else puts("WA");
        return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){

  int a, b;
  char op;
  while(1){
    scanf("%d %c %d", &a, &op, &b);
    if(op == '?'){
      break;
    }
    else if(op == '+'){
        printf("%d\n", a + b);
    }
    else if(op == '-'){
        printf("%d\n", a - b);
    }
    else if(op == '*'){
        printf("%d\n", a * b);
    }
    else if(op == '/'){
        printf("%d\n", a / b);
    }
  }
  return 0;
}

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

using namespace std;

#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define imod(a , n) (a % n + n ) % n

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define inF freopen("bbreeds.in","r",stdin );
#define outF freopen("bbreeds.out" , "w" , stdout ) ;

#define ll long long

const double eps = 1e-6 , PI = acos(-1) ;
const long long OO = 1e18 ;
const int N = 1e2 + 2 , oo = 1e9 , M = N * 4, mod = 2012 , K = 12;
int W , n , wt[N] , val[N];
ll H , dp[N][100005];

ll calc(int idx , int V){
    if(V >= H)
        return 0 ;
    if(idx == n)
        return OO ;

    ll &ret = dp[idx][V];
    if(~ret)
        return ret ;

    ret = calc(idx + 1 , V);

    ret = min(ret , calc(idx + 1 , V + val[idx]) + wt[idx]);
    return ret ;

}

int32_t main(){
    fastio ;

    // Dont Forget memset

    //calculate constraints please!!!
    cin >> n >> W ;
    for(int i = 0 ; i < n ; i ++)
        cin >> wt[i] >> val[i];
    int l = 0 , r = 1e5 + 5 , md ;
    while(l < r){
      md = (l + r + 1) / 2;
      memset(dp , -1 , sizeof dp);
      H = md ;
      if(calc(0 , 0) <= W )
        l = md ;
      else
        r = md - 1 ;
    }
    cout << l ;

     return 0 ;
}




Measured memory_bytes: 83316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;
int top, S[500];

void push(int x){
	/*top?????????????????????????????????????????\*/
	top++;
	S[top] = x;
}

int pop(){
	top--;
	/*top??????????????????????´??????????*/
	return S[top + 1];
}

int main(){
	int a, b;
	top = 0;
	char s[100];

	while (scanf("%s",s) != EOF){
		if (s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		}
		else{
			push(atoi(s));
		}
	}
	cout << pop() << endl;
}

Measured memory_bytes: 1164
import bisect
from collections import deque

n=int(input())

ans=[0]

for i in range(2**20):
  ch=0
  for j in range(20):
    
    if (i>>j)&1:
      ch+=2**(j*2)
  ans.append(ch)
  
ans1=[]
for x in range(2**20):
  ch1=0
  for y in range(20):
    if (x>>y)&1:
      ch1+=(-2)**(y*2+1)
  ans1.append(ch1)
  

for a in ans1:
  if n-a>=0:
    d=bisect.bisect_right(ans,n-a)
    if ans[d-1]==n-a:
      ans_min=a
      ans_plus=ans[d-1]
      break
      
v=1
C=0
while v<=ans_plus:
  v*=4
  C+=2
C-=2
pl_list=[]
while C>-1:
  if ans_plus>=2**C:
    pl_list.append(1)
    ans_plus-=2**C
    C-=2
  else:
    pl_list.append(0)
    C-=2
w=-2
D=1

while ans_min<=w:
  w*=4
  D+=2
D-=2

mi_list=[]
while D>0:
  if ans_min<=(-2)**D:
    mi_list.append(1)
    ans_min-=(-2)**D
    D-=2
  else:
    mi_list.append(0)
    D-=2

ans_str=[]
P=deque(pl_list)
M=deque(mi_list)

while P or M:
  if P:
    x=P.pop()
  else:
    x=0
  if M:
    y=M.pop()
  else:
    y=0
  ans_str.append(str(x))
  ans_str.append(str(y))

ans_str_r=list(reversed(ans_str))
if len(ans_str_r)>1:
  if ans_str_r[0]=='0':
    ans_str_r.remove('0')
  
if n!=0:
  print(''.join(ans_str_r))
else:
  print(0)

Measured memory_bytes: 158108
#include <stdio.h>

int main(){
  int min,now,value,n,i;

  scanf("%d",&n);

  scanf("%d%d",&min,&now);
  value=now-min;
  if(now<min)min=now;
  
  
  for(i=2;i<n;i++){
    scanf("%d",&now);

    if(value<now-min) value=now-min;
    if(now<min) min=now;
  }

  printf("%d\n",value);

  return 0;
}
    



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

data = {}

total = 0
for i in range(N):
  total += A[i]
  if A[i] in data:
    data[A[i]] += 1
  else:
    data[A[i]] = 1

Q = int(input())
for i in range(Q):
  B, Q = map(int, input().split())
  if B in data:
    num = data[B]
    data[B] = 0
    if Q in data:
      data[Q] += num
    else:
      data[Q] = num
    total = total - B * num + Q * num
  print(total)

  

Measured memory_bytes: 85316
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e18
#define ss second
#define ff first

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
//const int mod=1e9+7;
const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;
int a[up];

void solve()
{
    int n,m;
    cin>>n>>m;
    repn(i,0,n-1)
    {
        cin>>a[i];
    }
    int dp[n+2][m+2];
    mem(dp,0);
    dp[0][0]=1;
    repn(i,0,n-1)
    {
        repn(j,0,m)
        {
            dp[i+1][j]+=2*dp[i][j];
            dp[i+1][j]%=mod;
            if(j+a[i]<=m)
            {
                dp[i+1][j+a[i]]+=dp[i][j];
                dp[i+1][j+a[i]]%=mod;
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[n][m]<<endl;
}


int32_t main()
{
    int t;
    t=1;
    //sieve();
    //cin>>t;
    while(t--)
    {
        solve();
    }
}



Measured memory_bytes: 74060
#include<cstdio>
#include<algorithm>
using namespace std;

int n, m;
int a[200100], b[200100];

bool cmp(int g, int b){
	return g > b;
}

int main(){
	scanf("%d",&n);
	for(int i=0; i < n; i++)
		scanf("%d",&a[i]);
	sort(&a[0],&a[n],cmp);
	scanf("%d",&m);
	for(int j=0; j < m; j++)
		scanf("%d",&b[j]);
	sort(&b[0],&b[m],cmp);
	int A = 0;
	int B = 0;
	int ans = 0;
	while(A <= n && B <= m){
		if(a[A] == b[B]){
			A++;
			B++;
			ans++;
		}
		else
			A++;
		if(ans == m){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin>>n;
  cout<<800*n-200*(n/15)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,x=1;
    cin>>n;
    for(int i=1;i<=9;i++)
    {
       for(int j=1;j<=9;j++)
       {
          x=i*j;
           if(n==x)
           {
               cout<<"Yes"<<endl;
               return 0;
           }
           x=1;
       }
    }
    cout<<"No"<<endl;
    return 0;
}


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

int main(){

	int a, b, N, s, f;
	int ans = 0;
	cin >> a >> b;
	cin >> N;

	for(int i = 0; i < N; i++){
		cin >> s >> f;
			//同じ時間を使用しているとき
			if(a == s && b == f) ans =1;
			//時間をすでに使用（被っている）させているとき
			for(int j = s+1; j < f; j++){
				if(a == j || b == j) ans = 1;
			}
			//時間の使い過ぎ
			for(int k = a+1; k < b; k++){
				if( k == s || k == f) ans = 1;
			}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3124
n=int(input())
l=list(map(int,input().split()))
cost=0
def diff(a,b):
    if a>b:
        return(a-b)
    else:
        return (b-a)
dp={}#i:j means min cost of going from i to 1 is j
dp[1]=0
dp[2]=diff(l[1],l[0])
for i in range(3,len(l)+1):
    dp[i]=min(diff(l[i-1],l[i-3])+dp[i-2],diff(l[i-1],l[i-2])+dp[i-1])
print(dp[n])


Measured memory_bytes: 27048
/*  
    Talkin' to myself and feelin' old
    Sometimes I'd like to quit, nothin' ever seems to fit
    Hangin' around, nothin' to do but frown
    Rainy days and Mondays always get me down
    _________________________
    _________________________
    912 Hours of Solitude
    Quarantine_Day : 38
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005


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

	string s; cin>>s;
	
	while(true){
		s.pop_back();
		if(s.size() & 1) continue;

		string a, b;
		a = s.substr(0, s.size() / 2);
		b = s.substr(s.size() / 2);

		if(a == b){
			cout<<s.size()<<"\n";
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
/*
   Author: Shivam Shukla
*/
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}
 

int32_t main(int argc,char** argv){
	fastio();
	auto tstart= clock();

    int n; cin >> n;
    map<string, int> mp;
    repa(i, n) {
    	str a; cin >> a;
    	mp[a]++;
    }
    
    int mx = -1;
    trv(i, mp)
       mx = max(i.ss, mx);

    trv(i, mp)
       if (i.ss == mx)
          cout << i.ff << endl;
             
    cerr<<setprecision(2)<<fixed<<"Time elapsed: "<<(double)(clock() - tstart)/CLOCKS_PER_SEC<<endl; 
    return 0; 
}

Measured memory_bytes: 25088
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
 
string solve(vector<int>& v, int k)
{
    bool dp[k+1];
    memset(dp, 0, sizeof dp);
 
    for(int i = 1; i <= k; i++)
    {
        for(int move : v)
        {
            if(move > i)
                continue;
            if(dp[i - move] == 0)
                dp[i] = 1;
        }
    }
    
    return dp[k] ? "First" : "Second";
}
 
int main() {
   int n,k;
   cin >> n >> k;
   vector<int> v(n);
   for(int i =0; i<n; i++)
    cin>>v[i];
   cout<<solve(v, k);
   return 0;
}

Measured memory_bytes: 384
a, b, k = map(int, input().split())
flag, divisor, common_divisors = 0, 1, list()
while flag != -1:
    if a % divisor == 0 and b % divisor == 0:
        common_divisors.append(divisor)
    if divisor >= min(a, b):
        flag = -1
    divisor += 1
print(sorted(common_divisors, reverse=True)[k-1])

Measured memory_bytes: 3060
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int[] num = { 63, 6, 91, 79, 102, 109, 125, 39, 127, 111 };

		while (true) {
			int pre = 0;
			int n = scanner.nextInt();
			if (n == -1)
				break;
			while (n-- > 0) {
				int now = num[scanner.nextInt()];
				int ans = Integer.parseInt(Integer.toBinaryString(pre ^ now));
				System.out.printf("%07d\n", ans);
				pre = now;
			}
		}

	}
}

Measured memory_bytes: 20824
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))

typedef struct edge{ll s,g,c;}E;
typedef struct vertex{ll no,c;}V;


E e[200010];
V v[100010];
ll vnow[100010];
ll epre[200010];
 
ll que[200010];
void bfs(int k){
	if(v[k].no!=-1)return;
	ll qcnt=1;
	que[0]=k;
	v[k].no=k;
	rep(i,0,qcnt){
		ll vv=que[i];
		for(ll t=vnow[vv];t!=-1;t=epre[t])if(v[e[t].g].no==-1){
			que[qcnt++]=e[t].g;
			v[e[t].g].no=k;
		}
	}
}

int uni(const void*p,const void*q){
	V pp=*(V*)p,qq=*(V*)q;
	if(pp.no<qq.no)return -1;
	if(pp.no>qq.no)return 1;
	if(pp.c>qq.c)return -1;
	return 1;
}
int cost(const void*p,const void*q){
	V pp=*(V*)p,qq=*(V*)q;
	if(pp.c<qq.c)return -1;
	return 1;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	//連結成分がN-M個あるので(N-M-1)個の辺を追加する
	//2(N-M-1)個の頂点を選ぶ必要がある。N>2M+2なら無理
	if(n>2*m+2){
		puts("Impossible");
		return 0;
	}
	if(n-m==1){
		puts("0");
		return 0;
	}
	
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		v[i].no=-1;
		v[i].c=t;
	}
	v[n].no=-1;
	
	rep(i,0,n)vnow[i]=-1;
	rep(i,0,m){
		ll a,b;
		scanf("%lld%lld",&a,&b);
		e[2*i].s=a;
		e[2*i].g=b;
		epre[2*i]=vnow[a];
		vnow[a]=2*i;
		
		e[2*i+1].s=b;
		e[2*i+1].g=a;
		epre[2*i+1]=vnow[b];
		vnow[b]=2*i+1;
	}
	rep(i,0,n)bfs(i);

	//各連結成分から1つとる
	qsort(v,n,sizeof(V),uni);
	ll ans=0;
	rep(i,0,n)if(v[i].no!=v[i+1].no){
		ans+=v[i].c;
		v[i].c=INF;
	}
	
	//残りのN-M-2個をとる
	qsort(v,n,sizeof(V),cost);
	rep(i,0,n-m-2)ans+=v[i].c;
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11132
# -*- coding: utf-8 -*-
S =input()
T =input()

match_list = [0]*len(S)

for i in range(len(S)-len(T)+1):
  for j in range(len(T)):
    if S[i+j] == T[j]:
      match_list[i] += 1

print(len(T) - max(match_list))

Measured memory_bytes: 67456
N = int(input())
ls = []
for _ in range(N):
    x, l = map(int, input().split())
    ls.append([x-l, x+l])
ls = sorted(ls, key= lambda x: x[1])

ans = N
for i in range(1, N):
    if ls[i-1][1] > ls[i][0]:
        ls[i][1] = ls[i-1][1]
        ans -= 1
print(ans)

Measured memory_bytes: 22104
def b(x,y):
 A[y][x]='0'
 for d in range(-3,4):
  0<=x+d<8and'1'==A[y][x+d]and b(x+d,y)
  0<=y+d<8and'1'==A[y+d][x]and b(x,y+d)
e=input
for i in range(int(e())):
 print(f'Data {i+1}:')
 e()
 A=[list(e())for _ in[0]*8]
 b(int(e())-1,int(e())-1)
 for r in A:print(*r,sep='')


Measured memory_bytes: 5632
a = []
f = 1
for i in range(6):
    a.append(int(input()))
amax = max(a)
amin = min(a)
for i in range(5):
    if abs(amax - a[i]) <= a[-1] and abs(a[i] - amin) <= a[-1]:
        continue
    else:
        f = 0
if f:
    print("Yay!")
else:
    print(":(")

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  int min=200001;
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> p.at(i);
    if(p.at(i)<min){
      ans++;
      min=p.at(i);
    }
  }
  cout << ans << endl;
}

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

int main(){
    int a,counter,other;
    cin >> a >> counter;
    if(a > counter){
        other = a;
        a = counter;
        counter = other;

    }
    for(int i = 0;i < counter;i++){
        cout << a;
    }
    cout << endl;
}

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

const int MOD = 1000000007;
const int N = 700;

long long dp[2001];

void solve() {
  int s;
  cin >> s;
  
  memset(dp, -1, sizeof(dp));
  
  function<long long(int)>
  f = [&](int sum) -> long long {
    if (sum < 0) return 0;
    if (dp[sum] != -1) return dp[sum];
    if (sum == 0) return 1;
    long long ans = 0;
    for (int i = 3; i <= sum; ++i) {
      ans += f(sum - i);
      ans %= MOD;
    }
    return dp[sum] = ans;
  };
  
  cout << f(s) << '\n';
}

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


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define allc c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(allc,x) != c.end())
#define ll long long
using namespace std;

int main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll x;
	cin>>x;
	ll ans=1;
	ll p=x/500;
    ans = p*1000;
    ll m=x-p*500;
    ll n =m/5;
    ans = ans+(5*n);
    cout<<ans;

}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)
ll moddiv(ll a,ll b){
    a %= MOD;
    b %= MOD;
    for(ll m=MOD-2;m>0;m/=2){
        if(m&1){
            a=a*b%MOD;
        }
        b=b*b%MOD;
    }
    return a;
}

ll N,M;
ll i, j, k;
ll Fa[202020];
vector<ll> pr;
int main(){
    scanf("%lld%lld", &N, &M);
    Fa[0] = 1;
    fornum(i,0,200000){
        Fa[i + 1] = Fa[i] * (i + 1)%MOD;
    }
    fornum(i,2,101010){
        if(M%i>0)
            continue;
        j = 0;
        while(M%i==0){
            M /= i;
            ++j;
        }
        pr.push_back(j);
    }
    if(M>1){
        pr.push_back(1);
    }
    ll ans = 1;
    fornum(i,0,pr.size()){
        ans *= moddiv(Fa[N - 1 + pr[i]], Fa[N - 1] * Fa[pr[i]]);
        ans %= MOD;
    }
    printf("%lld", (ll)ans);

    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

int min(int a,int b){
  if(a>b){
    return b;
  }else{
    return a;
  }
}

int main(void){
  int i,l;
  long int tmp;
  int n;
  long long a[120000];
  int count=0;
  long long sum=0;


  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }

  for(i=0;i<n;i++){
    if(a[i]<0){
      count++;
      a[i]=abs(a[i]);
    }
  }
  if(count%2==0){

    for(i=0;i<n;i++){
      sum+=a[i];
    }
    printf("%lld",sum);
  }else if(count%2!=0){
      long long minmax=a[0];
    for(i=0;i<n;i++){
      minmax=min(minmax,a[i]);
    }

    for(i=0;i<n;i++){
      sum+=a[i];
    }
    sum=sum-(minmax*2);
    printf("%lld",sum);
  }


  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define name "bai3"
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fto(i,a,b) for(int i=a; i<=b; ++i)
#define maxn 100009
#define ll long long
using namespace std;
const int mod=1e9+7;
int n,a[maxn*2],xd[maxn*2];
ll p[maxn];
//ll q[maxn*2];
/*ll mu(int a, int b){
    if(b==0) return 1;
    ll tg=mu(a,b/2);
    tg=(tg*tg)%mod;
    if(b%2)tg=(tg*a)%mod;
    return tg;
}
ll c(int a, int b){
    ///return b!/(a!*(b-a)!)
    if(a==0)return 0;
    if(a>b)return 0;
    return (((p[b]*q[a])%mod)*q[b-a])%mod;
}*/
int main()
{
    cin >> n;
    int s=0;
    p[0]=1;
    fto(i,1,n)p[i]=(p[i-1]*i)%mod;
    /*q[0]=1;
    q[1]=1;
    fto(i,2,n*2) q[i]=mu(p[i],mod-2);*/
    fto(i,1,n*2){
        char c;
        cin >> c;
        if(c=='B')a[i]=1;
        else a[i]=0;
        if(a[i]==s){
            xd[i]=-1;
        }
        else{
            xd[i]=1;
        }
        s^=1;
    }
    int s1=0,s2=0;
    ll res=1;
    fto(i,1,n*2)
    if(xd[i]==1)++s1;
    else{
        if(s1>s2)res=(res*(s1-s2))%mod;
        else res=0;
        if(res==0)break;
        ++s2;
    }
    if(s1!=s2)res=0;
    cout << res*p[n]%mod;
    return 0;
}
/*
BWWB
WWWW


*/


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int k,x;
  cin >> k >> x;
  if(500*k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
  }



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

bool compare(const string &a,const string &b){
  if(b=="invalid") return 0;
  if(a=="invalid") return 1;
  if(a.size()!=b.size()) return a.size()<b.size();
  for(int i=0;i<(int)a.size();i++)if(a[i]!=b[i]) return a[i]<b[i];
  return 0;
}

string getNum(int l,int r){
  string res;
  if(l<r && A[l]=='0')  return "invalid";
  for(int i=l;i<=r;i++){
    if(!isdigit(A[i])&&A[i]!='?') return "invalid";
    res += A[i]=='?'? '9':A[i];
  }
  return res;
}

string mem[100][100];
int used[100][100];
string dfs(int l,int r){
  if(l>r) return "invalid";
  if(used[l][r]++) return mem[l][r];

  string &res = mem[l][r] = "invalid";
  res = getNum(l,r);
  if(res!="invalid") return res;

  if(A[l]!='L'&&A[l]!='R'&&A[l]!='?')return res;
  if(A[l+1]!='('&&A[l+1]!='?')return res;
  if(A[r]!=')'&&A[r]!='?') return res;
  
  for(int i=l+3;i<=r-2;i++){
    if(A[i]!=','&&A[i]!='?') continue;
    string L = dfs(l+2,i-1);
    string R = dfs(i+1,r-1);
    if(L=="invalid"||R=="invalid")continue;
    if((A[l]=='?'||A[l]=='L')&&compare(res,L)) res = L;
    if((A[l]=='?'||A[l]=='R')&&compare(res,R)) res = R;
  }
  return res;
}


int main(){
  cin>>A;
  A+='#';
  cout<<dfs(0,A.size()-2)<<endl;
  return 0;
}

Measured memory_bytes: 3340
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	ll a,b,n;
	ll res = 0;
	scanf("%lld", &a);
	scanf("%lld", &b);
	scanf("%lld", &n);
	if (n < b - 1) {
		res += (ll)(a*n / b);
	}
	else {
		res += (ll)(a*(b-1) / b);
	}

	printf("%lld\n", res);
	return(0);
}

Measured memory_bytes: 3104