akhauriyash/Code-Regression huggingface dataset:
/*
There was a time, looking through myself
Wanting to pretend
If I escaped, I could fill myself
I don't think you can
Been far and wide
But that hole inside
Never really leaves
When I went away, what I really left
Left behind was me

It's telling me
To be on my way home
Million miles away
I can't stay

Each passing day, every passing face
Seems like such a blur
I long to be
Home, silently
Lying next to her
Just to get back, by her side is all
All I need to be
Cause I went away
But what I really left
Left behind was me

I need to be
Getting on my way home
A million miles away
Million miles away
I can't take
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 510031;

int n,a,b;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
Q=int(input())
l=[0]*100001
l2=[0]*100001
def d(n):
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
for i in d(100000):
   l[i]=1
for i in range(3,100001):
   if l[i] == 1:
      if l[(i+1)//2]==1:
         l2[i]=1
for i in range(1,100001):
   l2[i]+=l2[i-1]
qe=[list(map(int,input().split())) for i in range(Q)]
for i in qe:
   print(l2[i[1]]-l2[i[0]-1])

Measured memory_bytes: 31652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    string s;
    int k;
    cin >> s >> k;
    int len=s.size();
    map<string,int>mp;
    for(int i=1; i<=min(5,len); i++){
        int cnt=len+1-i;
        rep(j,cnt){
            string t=s.substr(j,i);
            mp[t]++;
        }
    }
    int now=1;
    for (auto p:mp){
        if(now==k) cout << p.first <<endl;
        now++;
    }
    return 0;
}

Measured memory_bytes: 1920
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,a,b,c,d = readline() |> split |> parseMap
	f = 0
	for i in 0:n-1
		if i*(-d)+(n-i-1)*c<=b-a<=i*(-c)+(n-i-1)*d
			f = 1
		end
	end
	println(f==1?"YES":"NO")
end

main()


Measured memory_bytes: 110348
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(10);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int n;
    cin >> n;
    double x;
    double sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        sum += 1 / x;
    }
    cout << 1 / sum << "\n";
    return 0;
}

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

int main()
{
    int N;
    int C[505], S[505], F[505];

    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        cin >> C[i] >> S[i] >> F[i];
    }
    for(int i = 0; i < N; i++) {
        int sum = 0;
        for(int j = i; j < N - 1; j++) {
            if(sum < S[j]) {
                sum = S[j];
            } else {
                sum = S[j] + (sum - S[j] + F[j] - 1) / F[j] * F[j];
            }
            sum += C[j];
        }
        cout << sum << endl;
    }
    return (0);
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n;
    int a[100000];
    cin >> n;
    int even = 0;
    int odd = 0;
    bool f = true;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] % 2 == 0)
            even++;
        else
            odd++;
    }
    if (odd % 2 == 1)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
}


Measured memory_bytes: 1024
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n,k = ip()
x = ip()
for _ in range(k):
    dp = [0]*(n+1)
    for i in range(n):
        pos1 = max(i-x[i],0)
        pos2 = min(i+x[i]+1,n)
        dp[pos1] += 1
        dp[pos2] -= 1
    for i in range(1,n+1):
        dp[i] += dp[i-1]
    if x == dp:
        break
    x = list(dp)
print(*x[:-1])
        

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

#define llt long long int
#define modm 1000000007

int main(){
	int n,m,ans=INT_MAX,num,res=0;
	string s1,s2;
	cin>>n>>m;
	int arr[m];
	res=n;
	set<int> s;
	bool pres[102]={false};
	for(int i=0;i<m;i++){
		cin>>num;
		pres[num]=true;
	}
	for(int i=0;i<=101;i++){
		if(pres[i]==false){
			if(abs(i-n)<ans){
			ans=abs(i-n);
			res=i;
			}
		}
	}
	cout<<res<<endl;
	
}


Measured memory_bytes: 3624
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	s := getString()
	flg := true

	for i := 0; i < len(s); i++ {
		x := s[i]
		if i%2 == 0 {
			if x == 'L' {
				flg = false
			}
		} else {
			if x == 'R' {
				flg = false
			}
		}
	}
	if flg {
		out("Yes")
		return
	}
	out("No")
}


Measured memory_bytes: 1772
#include<iostream>
#include<complex>
#include<vector>
#include<cstdio>
using namespace std;

typedef complex<double> P;
typedef vector<P> G;

inline double outp(const P & a, const P& b)
{
  return (conj(a)*b).imag();
}


double area(G& g)
{
  int n = g.size();
  double s=0.0;
  for(int i=0;i<n;i++)
    {
      int j=(i+1)%n;
      s+=outp(g[i],g[j])/2;
    }
  return abs(s);
}

int main()
{
  int data=1,n;
  for(;cin>>n,n;data++)
    {
      G g;
      for(int i=0;i<n;i++)
        {
          int x,y;
          cin>>x>>y;
          g.push_back(P(x,y));
        }
      printf("%d %.1f\n",data,area(g));
      //      cout<<data<<" "<<area(g)<<endl;

    }

}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}

const int dm = 1 << 23;
char dn[dm], * di = dn;
inline void putint(ll X, ll X2) {
	if (X == 0) {
		*di++ = '0';
	}
	else {
		if (X < 0) {
			*di++ = '-';
			X = -X;
		}
		int keta = 0;
		char C[20];
		while (X) {
			*(C + keta) = '0' + X % 10;
			X /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	}
	*di++ = ' ';
	if (X2 == 0) {
		*di++ = '0';
	}
	else {
		if (X2 < 0) {
			*di++ = '-';
			X2 = -X2;
		}
		int keta = 0;
		char C[20];
		while (X2) {
			*(C + keta) = '0' + X2 % 10;
			X2 /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	}
	*di++ = '\n';
}

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


	int Q = getint();

	ll X = 0;
	priority_queue<int> mae;
	priority_queue<int, vector<int>, greater<int>> ato;
	mae.push(-2e9);
	ato.push(2e9);
	int sa = 0;

	rep(i, Q) {
		if (getint() == 1) {
			int a = getint();
			X += getint();

			if (sa) {
				int k = mae.top();
				if (a < k) {
					mae.pop();
					ato.push(k);
					mae.push(a);
					X += k + k;
					X -= a;
				}
				else {
					ato.push(a);
					X += a;
				}
				sa = 0;
			}
			else {
				int k = ato.top();
				if (a > k) {
					ato.pop();
					mae.push(k);
					ato.push(a);
					X += a;
					X -= k + k;
				}
				else {
					mae.push(a);
					X -= a;
				}
				sa = 1;
			}
		}
		else {
			int k = mae.top();
			ll ans = sa * k + X;
			putint(k, ans);
		}
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 7676
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
const int N=1e6+10;
int n,m,k;
int main()
{
	int ans,num;
	
	cin >> ans>>num;
	for(int i=0;i<num;i++) {
		int x;
		cin >> x;
		ans-=x;
	}
	if(ans>=0) cout <<ans<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 3636
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var dy = [-1,0,1,0], dx = [0,1,0,-1];
  var h = next(), w = next();
  var [sy,sx] = nexts(2);
  var [gy,gx] = nexts(2);
  sy--,sx--,gy--,gx--;
  var s = nexts(h,1);
  var map = xArray(1e9,h,w);
  map[sy][sx] = 0;
  var q1 = [sy,sx], q2 = [], d = 0;
  while(q1.length){
    while(q1.length){
      var qx = q1.pop(), qy = q1.pop();
      if(map[qy][qx] < d)continue;
      for(var i = 0; i < 4; i++){
        var nx = qx+dx[i], ny = qy+dy[i];
        if(nx < 0 || nx === w || ny < 0 || ny === h)continue;
        if(s[ny][nx] === "#")continue;
        if(map[ny][nx] <= d)continue;
        map[ny][nx] = d;
        q1.push(ny,nx);
      }
      for(var y = -2; y <= 2; y++)for(var x = -2; x <= 2; x++){
        var nx = qx+x, ny = qy+y;
        if(nx < 0 || nx >= w || ny < 0 || ny >= h)continue;
        if(s[ny][nx] === "#")continue;
        if(map[ny][nx] <= d+1)continue;
        map[ny][nx] = d+1;
        q2.push(ny,nx);
      }
    }
    d++, q1 = q2, q2 = [];
  }
  return map[gy][gx] === 1e9 ? -1 : map[gy][gx];
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int H,W,N;
vector<string> S;
struct P{
	int y,x,c;
};
const int dx [] = {0,1,0,-1};
const int dy [] = {-1,0,1,0};

bool in_range(int y,int x)
{
	return y >= 0 && y < H && x >= 0 && x < W;
}

int bfs(char s,char t)
{
	queue<P> q;
	deque<bool> vis(H * W);
	FOR(i,0,H) FOR(j,0,W){
		if(S [i] [j] == s){
			q.push(P{i,j,0});
			vis [i * W + j] = true;
		}
	}

	while(q.empty() == false){
		P f = q.front();
		q.pop();

		if(S [f.y] [f.x] == t) return f.c;
		FOR(i,0,4){
			int ny = f.y + dy [i],nx = f.x + dx [i];
			if(in_range(ny,nx) == false || S [ny] [nx] == 'X' || vis [ny * W + nx]) continue;
			vis [ny * W + nx] = true;
			q.push(P{ny,nx,f.c + 1});
		}
	}
	return -1;
}

int main()
{
	cin >> H >> W >> N;
	S.assign(H,"");
	FOR(i,0,H){
		cin >> S [i];
	}

	int ans = bfs('S','1');
	FOR(i,2,N + 1){
		ans += bfs('0' + (i - 1),'0' + i);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4916
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        long[] Ac = new long[N];
        A[0] = sc.nextInt();
        Ac[0] = A[0];
        for (int i = 1; i < N; i++) {
            A[i] = sc.nextInt();
            Ac[i] = Ac[i - 1] + A[i];
        }
        long half = Long.MAX_VALUE;
        int c1r = 0;
        int c3r = 2;
        for (int c2 = 1; c2 < N - 2; c2++) {
            long half1 = Long.MAX_VALUE;
            for (int c1 = c1r; c1 < c2; c1++) {
                long a = Math.abs(Ac[c1] - (Ac[c2] - Ac[c1]));
                if (half1 >= a) {
                    half1 = a;
                    c1r = c1;
                } else {
                    break;
                }
            }
            long half2 = Long.MAX_VALUE;
            for (int c3 = c2 + 1 < c3r ? c3r : c2 + 1; c3 < N - 1; c3++) {
                long b = Math.abs((Ac[c3] - Ac[c2]) - (Ac[N - 1] - Ac[c3]));
                if (half2 >= b) {
                    half2 = b;
                    c3r = c3;
                } else {
                    break;
                }
            }
            long max = Math.max(Math.max(Ac[c1r], Ac[c2] - Ac[c1r]), Math.max(Ac[c3r]-Ac[c2], Ac[N - 1] - Ac[c3r]));
            long min = Math.min(Math.min(Ac[c1r], Ac[c2] - Ac[c1r]), Math.min(Ac[c3r]-Ac[c2], Ac[N - 1] - Ac[c3r]));
            half = half < max - min ? half : max - min;
        }
        System.out.println(half);
    }
}

Measured memory_bytes: 84780
import java.io.*;

class Elem {
    Elem next;
    Elem prev;
    int key;
     
    Elem(int key) {
        this.key = key;
    }
}
 
class DoubleyLinkedList {
    Elem head;
     
    DoubleyLinkedList() {
        head = new Elem(-1);
        head.next = head;
        head.prev = head;
    }
     
    void insert(int key) {
        Elem e = new Elem(key);
        e.next = head.next;
        e.prev = head;
        e.next.prev = e;
        head.next = e;
    }
     
    void delete(int key) {
        for (Elem e = head.next; e != head; e = e.next) {
            if (e.key == key) {
                e.prev.next = e.next;
                e.next.prev = e.prev;
break;
            }
        }
    }
     
    void deleteFirst() {
        Elem e = head.next;
        e.next.prev = head;
        head.next = e.next;
    }
     
    void deleteLast() {
        Elem e = head.prev;
        e.prev.next = head;
        head.prev = e.prev;
    }
     
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (Elem e = head.next; e != head; e = e.next) {
            sb.append(e.key);
            sb.append(' ');
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append('\n');
        return sb.toString();
    }
}
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
        // BufferedReader br = new BufferedReader(new FileReader("in2.txt"));
        int n = Integer.parseInt(br.readLine());
 
        DoubleyLinkedList list = new DoubleyLinkedList();
        for (int i = 0; i < n; i++) {
            String[] line = br.readLine().split(" ");
            if (line[0].equals("insert")) {
                list.insert(Integer.parseInt(line[1]));
            } else if (line[0].equals("delete")) {
                list.delete(Integer.parseInt(line[1]));
            } else if (line[0].equals("deleteFirst")) {
                list.deleteFirst();
            } else if (line[0].equals("deleteLast")) {
                list.deleteLast();
            }
        }
        System.out.print(list.toString());
    }
}

Measured memory_bytes: 188416
heroes = int(input())
puts = input()
monsters = puts.split()
puts = input()
strength = puts.split()
Ans = 0

for i in range(heroes):
	if (int(strength[i]) > int(monsters[i])):
		if(int(strength[i]) > int (monsters[i]) + int (monsters[i+1])):
			Ans += int(monsters[i]) + int(monsters[i+1])
			monsters[i+1] = 0
		else:
			monsters[i+1] = int(monsters[i+1]) + int(monsters[i]) - int(strength[i])
			Ans += int(strength[i])
	else:
		Ans += int(strength[i])

print(Ans)


Measured memory_bytes: 22924
#include <stdio.h>
int main(void){
  int n,m,a,b,t[50]={},i;
  scanf("%d%d",&n,&m);
  for (i=0;i<m;i++){
    scanf("%d%d",&a,&b);
    t[a-1]++;
    t[b-1]++;
  }
  for (i=0;i<n;i++) printf("%d\n",t[i]);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=810,M=N*N;
bool w[N][N];
char s[N][N];
int a[N],b[N],c[N],m1[4]={1,0,-1,0},m2[4]={0,1,0,-1};
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,m,k,ans=1<<30,x,y;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) {
	scanf("%s",s[i]+1);
	for(int j=1;j<=m;j++)
	    if(s[i][j]=='S') x=i,y=j;
    }
    int t=0,sum=1;
    a[1]=x,b[1]=y,w[x][y]=1;
    while(t<sum) {
	x=a[++t],y=b[t];
	ans=min(ans,(min(min(x-1,n-x),min(y-1,m-y))+k-1)/k+1);
	if(c[t]==k) continue;
	for(int i=0;i<4;i++) {
	    int X=x+m1[i],Y=y+m2[i];
	    if(!w[X][Y]&&s[X][Y]=='.') {
		c[++sum]=c[t]+1,w[X][Y]=1;
		a[sum]=X,b[sum]=Y;
	    }
	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1280
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013

int temp=0;
bool cycle=false;
const int mxn=2e5+10;
vector<vector<int>> adj;
bool vis[mxn],act[mxn];

void dfs(int node,int p)
{
	vis[node]=true;
	act[node]=true;
	temp++;
	for(auto i:adj[node])
	{
		if(vis[i]&&i!=p)
		{
			cycle=true;
		}
		if(!vis[i])
		{
			dfs(i,node);
		}
		
	}
	act[node]=false;
	
}

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		int n,m;
		cin>>n>>m;
		adj=vector<vector<int>> (n);
		set<pair<int,int>> s;
		fi(0,m)
		{
			int x,y;
			cin>>x>>y;
			--x,--y;
			if(s.find({x,y})!=s.end()||s.find({y,x})!=s.end()) continue;
			adj[x].pb(y);
			adj[y].pb(x);
			s.insert({x,y});
		}
		int ans=0;
		fi(0,n)
		{
			if(!vis[i])
			{
				cycle=false;
				temp=0;
				dfs(i,-1);
				ans=max(ans,temp);
			}
		}
		cout<<ans;
	}
}


























Measured memory_bytes: 36428
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(void)
{
   int n, W;
   cin >>  n >> W;

   vector<int> v(n), w(n);
   rep(i, n) cin >> v[i] >> w[i];

   int capa[W+1];
   capa[0] = 0;
   for(int i = 1; i <= W; i++) {
       capa[i] = capa[i-1];
       rep(j, n) {
           if(i - w[j] >= 0) capa[i] = max(capa[i], capa[i-w[j]] + v[j]);
       }
   }
   cout << capa[W] << endl;
    return 0;
}


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

int main () {
  int N;
  cin >> N;
  std::vector<int> L;
  for (auto i = 0; i < N; ++i){
    int l;
    cin >> l;
    L.push_back(l);
  }
  
  std::sort(L.begin(), L.end());

  auto num_triangle = 0;

  for (auto i = N-1; i > 1; --i){
    auto a = L[i];
    for (auto j = i-1; j > 0; --j){
      auto b = L[j];
      auto c = L[j-1];
      if (a >= b+c){ break; }
      num_triangle += j - distance(L.begin(), upper_bound(L.begin(), L.begin()+j, a-b));
    }
  }

  cout << num_triangle << endl;

  return 0;
}

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

bool warenai3(int n){
  if(n%3!=0)return true;
  else return false;
}

bool warenai5(int n){
  if(n%5!=0)return true;
  else return false;
}

int main(){
  int N, ans=0;
  cin>>N;
  
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      for(int k=1;k<=N;k++){
        //cout<<gcd(gcd(i,j),k)<<endl;
        ans+=gcd(gcd(i,j),k);
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  long long x,y;
  long long c=0;
  cin >> x >> y;
  while(1){
    x = x*2;
    c ++;
    if(x > y) break;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
S = list(input())
Flag = 0

if (S[0] == "A"):
    Flag += 1

if (S[2:-1].count("C") == 1):
    Flag += 1

if (Flag == 2):
    S.remove("A")
    S.remove("C")
    if (str(S).islower()):
        Flag += 1

if (Flag == 3):
    print("AC")
else:
    print("WA")


Measured memory_bytes: 3060
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <iostream>
#include <locale>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

string solve(string s) {
    // queue<int> stack;
    stack<int> stack;
    bool flag = true;
    int check;

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '(')
            stack.push(1);
        else if (s[i] == '[')
            stack.push(2);
        if (s[i] == ')') {
            if (stack.empty()) return "no";
            check = stack.top();
            stack.pop();
            if (check != 1) {
                return "no";
            }
        } else if (s[i] == ']') {
            if (stack.empty()) return "no";
            check = stack.top();
            stack.pop();
            if (check != 2) {
                return "no";
            }
        }
    }
    // if (!stack.empty()) flag = false;
    // if (flag) return "yes";
    // return "no";
    return stack.empty() ? "yes" : "no";
}

int main() {
    string st;
    vector<string> ans;
    while (1) {
        // cout << 1;
        getline(cin, st);
        // cout << 2;
        if (st == ".") break;
        // cout << 3;
        // cout << st << endl;
        ans.push_back(solve(st));
        // cout << 4;
    }
    for (auto k : ans) cout << k << endl;
}


Measured memory_bytes: 3336
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int mn=1e5+5,mm=4e5+5;
int dis[mn],vis[mn],nbs[mn],nxt[mm],ev[mm],ew[mm];
int n,m,ok,tot;

void add(int u,int v,int w)
{
	nxt[++tot]=nbs[u],nbs[u]=tot,ev[tot]=v,ew[tot]=w;
}

void spfa(int i)
{
	vis[i]=1;
	for (int j=nbs[i];j!=0;j=nxt[j])
	{
		int v=ev[j],w=ew[j];
		if (dis[v]>dis[i]+w)
		{
			if ((vis[v]==1)||(ok==1)) return ok=1,void();
			dis[v]=dis[i]+w,spfa(v);
		}
	}
	vis[i]=0;
}

int main()
{
	int x,y,z;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) scanf("%d%d%d",&x,&y,&z),add(x,y,z),add(y,x,-z);
	for (int i=1;i<=n;i++) spfa(i);
	printf(ok==1?"No\n":"Yes\n");
	return 0;
}

Measured memory_bytes: 7936
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef struct pair<int,int> P;
typedef long long ll;
bool k[100001]={};
ll x[100001];
ll y[100001];
int main() {
	ll n,m;
	cin>>n>>m;
	ll tx=0;
	ll ty=0;
	for(int i=0;i<n;++i){
		cin>>x[i];
		tx+=x[i];
	}
	for(int i=0;i<m;++i){
		cin>>y[i];
		ty+=y[i];
	}

	ll a=0;
	for(int i=0;i<n-1;++i){
		tx-=x[i];
		a=(a+tx-x[i]*(n-i-1))%1000000007;
	}
	ll b=0;
	for(int i=0;i<m-1;++i){
		ty-=y[i];
		b=(b+ty-y[i]*(m-i-1))%1000000007;
	}
	ll s=(a*b)%1000000007;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

struct data{
    string name;
    double rate;
};

bool cmp(data d1, data d2){
    if(fabs(d1.rate - d2.rate) < 1e-8){
        return d1.name < d2.name;
    }
    return d1.rate > d2.rate;
}

signed main(){
    int n;
    while(cin >> n, n){
        string l;
        double p, a, b, c, d, e, f, s, m;
        vector<data> memo(n);
        rep(i, 0, n){
            cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            double tmp = (f*m*s - p) / (a + b + c + m*(d + e));
            memo[i].name = l;
            memo[i].rate = tmp;
        }
        sort(all(memo), cmp);
        rep(i, 0, n){
            cout << memo[i].name << endl;
        }
        cout << "#" << endl;
    }
}

Measured memory_bytes: 1260
#pragma region Macro
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<int, int> ti2;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;
typedef tuple<ll, ll> tl2;
typedef tuple<ll, ll, ll> tl3;
typedef tuple<ll, ll, ll, ll> tl4;
typedef vector<int> vi;
typedef vector<ti2> vti2;
typedef vector<ti3> vti3;
typedef vector<ti4> vti4;
typedef vector<ll> vl;
typedef vector<tl2> vtl2;
typedef vector<tl3> vtl3;
typedef vector<tl4> vtl4;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vti2> vvti2;
typedef vector<vti3> vvti3;
typedef vector<vti4> vvti4;
typedef vector<vl> vvl;
typedef vector<vtl2> vvtl2;
typedef vector<vtl3> vvtl3;
typedef vector<vtl4> vvtl4;
typedef vector<vs> vvs;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define FORD(i, a, b) for (int i = (a), i##_len = (b); i > i##_len; i--)
#define FORR(t, a) for (auto t : a)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORT(a, func) sort(ALL(a), [](const auto& x, const auto& y) func)
#define GET(i, j) get<j>(i)
#define MT(x, ...) make_tuple(x, __VA_ARGS__)
#define PRINT(i) cout << i << endl
#define PRINT2(i, j) cout << i << " " << j << endl
#define PRINT3(i, j, k) cout << i << " " << j << " " << k << endl
#define PRINT4(i, j, k, l) cout << i << " " << j << " " << k << " " << l << endl
#define PRINTL(a)                                       \
    for (const auto& d9aw : a) { cout << d9aw << " "; } \
    cout << endl

//演算子オーバーロード
bool operator<(const ti2 x, const ti2 y) {
    if (GET(x, 0) != GET(y, 0))
        return GET(x, 0) < GET(y, 0);
    else
        return GET(x, 1) < GET(y, 1);
}
bool operator>(const ti2 x, const ti2 y) {
    if (GET(x, 0) != GET(y, 0))
        return GET(x, 0) > GET(y, 0);
    else
        return GET(x, 1) > GET(y, 1);
}

#pragma endregion Macro

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b and b < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, ans;
    cin >> N;
    if (N % 2 == 0)
    {
        ans = N;
    }
    else
    {
        ans = N*2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String S = in.nextLine();
        String T = in.nextLine();
        
         if (S.equals(T.substring(0,S.length()))){
          System.out.println("Yes");
         }
         else {System.out.println("No");
                }
        }
    }

Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int64_t N;
  cin >> N;
  
  vector<int64_t> Lyca(N + 1);
  Lyca.at(0) = 2;
  Lyca.at(1) = 1;
  for(int i = 2; i <= N; i++){
  	Lyca.at(i) = Lyca.at(i - 1) + Lyca.at(i - 2);
  }
  cout << Lyca.at(N) << endl;
}


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



int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> d;
    for(ll i=1;i*i<=m;i++){
        if(m%i==0){
            d.push_back(i);
            d.push_back(m/i);
        }
    }
    ll ans=1;
    for(int i=0;i<d.size();i++){
        if(d.at(i)*n<=m&&d.at(i)>ans){
            ans=d.at(i);
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

ll dp[105][5];
ll sol[105][5];
string N;
int l;
ll solve(int i, int k)
{
	if(i==0)
		return k==0;
	if(k<0)
		return 0;
	if(sol[i][k]!=-1)
		return sol[i][k];
	sol[i][k] = solve(i-1,k);
	sol[i][k] += 9*solve(i-1,k-1);
	return sol[i][k];
}
ll getAns(int i, int k)
{
	if(i==l)
		return (k==0);
	if(N[i]=='0')
		return getAns(i+1,k);
	if(dp[i][k]!=-1)
		return dp[i][k];
	dp[i][k] = solve(l-i-1,k);
	for(auto c='1'; c<N[i]; c++){
		dp[i][k] += solve(l-i-1,k-1);
	}
	dp[i][k] += getAns(i+1,k-1);
	return dp[i][k];
}
int countA(int x)
{
	int c=0;
	while(x>0)
	{
		int r = x%10;
		c += (r!=0);
		x/=10;
	}
	return c;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll k;
	cin>>N;
	cin>>k;
	l = N.length();
	for(int i=0; i<=l; i++)
		for(int j=0; j<5; j++)
			sol[i][j]=-1,dp[i][j] = -1;
	if(l<4){
		int n = stoi(N);
		int ans=0;
		for(int i=1; i<=n; i++)
			ans += (countA(i)==k);
		cout<<ans<<"\n";
	}
	else
		cout<<getAns(0,k)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  //AさんとCさんが直接話せるか
  if(abs(a-c)<=d){
    puts("Yes");
    return 0;
  }
  else if (abs(a-b)<=d&&abs(b-c)<=d) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100005
int n,ans;
int cnt1[MAXN],cnt2[MAXN],m1,m2,n1,n2;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		if(i%2)
		{
			cnt1[x]++;
			if(m1<cnt1[x])
				m1=cnt1[x],n1=x;
		}
		else 
		{
			cnt2[x]++;
			if(m2<cnt2[x])
				m2=cnt2[x],n2=x;
		}
	}
	sort(cnt1,cnt1+MAXN);
	sort(cnt2,cnt2+MAXN);
	if(n1!=n2)
		ans=n-m1-m2;
	else ans=n-max(m1+cnt2[MAXN-2],m2+cnt1[MAXN-2]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 896
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		String a="";
		String b="";
		for(int i=0;i<N;i++) {
			a=a+sc.next();
		}
		for(int i=0;i<N;i++) {
			b=b+sc.next();
		}
		String f="";
		for(int i=1;i<=N;i++) {
			f=f+i;
		}
		String v=f;
		int ctn=1;
		int aV=0,bV=0;
		boolean aa=true,bb=true;
		if(a.equals(b)) {
			p(0);
		}else {
		while(aa||bb) {
			if(v.equals(a)) {
				aa=false;
				aV=ctn;
			}else if(v.equals(b)){
				bb=false;
				bV=ctn;
			}
			//p(v);
			v=nextPermutation(v);
			if(v.equals("Final")) {
				break;
			}
			ctn++;
		}
		p(Math.abs(aV-bV));
	}
		}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


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

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

  sort(m , m+n);
  long long int count = 0;
  for(int i = n-1-k ; i > -1 ; i--)
  {
      count = count + m[i];
  }

  cout << count ;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

typedef long long ll;

ll w[100], h[100], n[100];

int main() {
	for (int i = 0; i < 100; i++) {
		n[i] = -1;
	}
	int c = 0;
	while (true) {
		ll H, W;
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		ll t = H*H + W*W;
		for (int i = 1; i <= 150; i++) {
			for (int j = i + 1; j <= 150; j++) {
				ll t2 = i*i + j*j;
				if (t < t2 && (n[c] == -1 || n[c] > t2)) {
					h[c] = i;
					w[c] = j;
					n[c] = t2;
				}
				else if (t == t2 && H < i && n[c] != t2) {
					h[c] = i;
					w[c] = j;
					n[c] = t2;
				}
			}
		}
		c++;
	}
	for (int i = 0; i < c; i++) {
		cout << h[i] << " " << w[i] << endl;
	}
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// ya navid navid
const int N=2e5+100;
vector <pair <int,pii> > a;
int32_t main(){
    ll n;
    cin >> n;
    for (int i=0;i<n;i++){
        ll x,y;
        cin >> x >> y;
        a.pb({x+y,{x,y}});
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll x=0,y=0;
    for (int i=0;i<n;i++){
        if (i%2){
            y+=a[i].S.S;
        }
        else{
            x+=a[i].S.F;
        }
    }
    cout << x-y;
}


Measured memory_bytes: 4724
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define pb push_back
#define pi pair<int, int>
#define l first
#define r second
#define all(x) x.begin(), x.end()
#define fori(a, b, step) for (int i = a; i < b; i += step)
#define forj(a, b, step) for (int j = a; j < b; j += step)
#define int long long

const int maxn = 1e6 + 1, mod = 1e9 + 7;

using namespace std;

int a[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int x; cin >> x;
    cout << (x >= 30 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * 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 factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    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(0);
    int a, b; cin >> a >> b;
    if (a == 1) a += 13;
    if (b == 1) b += 13;
    string ans;
    if (a > b) ans = "Alice";
    else if (a < b) ans = "Bob";
    else if (a == b) ans = "Draw";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
from math import isinf
INF = float("inf")
sys.setrecursionlimit(100000)
def dfs(v, tm):
    dts[v] = est[v] = tm + 1
    child = 0
    for i in adj[v]:
        if est[i] == float('inf'):
            child += 1
            parents[i] = v
            dfs(i, tm + 1)
            est[v] = min(est[v], est[i])
            if parents[v] is None and child > 1: aps[v] = True
            if parents[v] is not None and est[i] >= dts[v]: aps[v] = True
        elif parents[v] != i:
            est[v] = min(est[v], dts[i])
n, m = map(int, stdin.readline().split())
adj = [[] for _ in range(n)]
est = [float('inf')] * n
parents = [None] * n
aps = [False] * n
dts = [0] * n
for _ in range(m):
    s, t = map(int, stdin.readline().split())
    adj[s].append(t)
    adj[t].append(s)
dfs(0, 0)
for i in range(n):
    if aps[i]:
        print(i)

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

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

		if(input[0].Last() == input[1].First() && input[1].Last() == input[2].First())
			Console.WriteLine("YES");
		else
			Console.WriteLine("NO");
	}
}


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

using namespace std;
typedef long long ll;
  
int n, m, R;
int r[10];
int g[205][205];
int ans;
    
int main(){
  cin >> n >> m >> R;
  for(int i=0; i<R; i++) {
    cin >> r[i];
    r[i]--;
  }
  memset(g, 0x3f, sizeof(g));
  for(int i=0; i<m; i++) {
                int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    g[u][v] = g[v][u] = w;
  }
  for (int k=0; k<n; k++)
    for (int i=0; i<n; i++)
      for (int j=0; j<n; j++)
        g[i][j] = min(g[i][j], g[i][k]+g[k][j]);
  
  sort(r, r+R);
  ans = (1<<29);
  do {
    int cost = 0;
    for(int i=1; i<R; i++) {
      cost += g[r[i-1]][r[i]];
    }
    ans = min(ans, cost);
  } while (next_permutation(r, r+R));
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
int a[101];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n){
		cin>>a[i];
		if(a[i]%2)
		continue;
		if(a[i]%3!=0&&a[i]%5!=0){
			cout<<"DENIED";
			re 0;
		}
	}
	cout<<"APPROVED";
	
	re 0;
}


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

template<class T>
struct Dinic {
private : 
    const T INF = numeric_limits<T>::max();
    struct Edge {
        int to, rev; T cap;
        Edge (int to, T cap, int rev)
            : to(to), cap(cap), rev(rev) { }
    };
    vector<int> level, idx;
    vector<vector<Edge>> g;
public : 
    Dinic (int n) : g(n), level(n), idx(n) { }

    void add_edge (int from, int to, T cost) {
        g[from].emplace_back(to, cost, g[to].size());
        g[to].emplace_back(from, 0, g[from].size() - 1);
    }

    void init (int s) {
        fill(level.begin(), level.end(), -1); level[s] = 0;
        queue<int> que; que.emplace(s);
        while (not que.empty()) {
            const int v = que.front(); que.pop();
            for (const Edge &e : g[v]) {
                if (e.cap > 0 and level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.emplace(e.to);
                }
            }
        }
    }

    T find_flow (int v, int t, T f) {
        if (v == t) return f;
        for (int &i = idx[v]; i < g[v].size(); i++) {
            Edge &e = g[v][i];
            if (e.cap > 0 and level[v] < level[e.to]) {
                const T flow = find_flow(e.to, t, min(f, e.cap));
                if (flow > 0) {
                    e.cap -= flow;
                    g[e.to][e.rev].cap += flow;
                    return flow;
                }
            }
        }
        return 0;
    }

    T max_flow (int s, int t) {
        T ret = 0;
        while (true) {
            init(s);
            if (level[t] < 0) break;
            fill(idx.begin(), idx.end(), 0);
            while (true) {
                T flow = find_flow(s, t, INF);
                if (flow <= 0) break;
                ret += flow;
            }
        }
        return ret;
    }

};

int main() {
    int n, m;
    cin >> n >> m;
    
    Dinic<int> g(n);
    
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        g.add_edge(a, b, c);
    }
    
    cout << g.max_flow(0, n - 1) << '\n';
    
    return 0;
}


Measured memory_bytes: 3176
nu1,nu2 = gets.chomp.split(" ").map(&:to_i)
li = 1 + (nu2**0.5).to_i
check = []
require 'prime'
if nu2 == 1
  puts 1
  exit
end

Prime.each(li) do |prime|
  check.push(prime)
end
nu3 = nu2
count = 0
divi = []
check.each do |x|
  while nu3 % x == 0
    nu3 /= x
    count += 1
  end
  if count > 0
    divi.push(count)
    count = 0
  end
  if nu3 == 1
    break
  end
end
if nu3 != 1
  divi.push(1)
end

leng = divi.length


ans = 1
for i in 0..leng - 1
  for j in 1..divi[i]
    ans *= (divi[i] + nu1 - j) % (10**9 + 7)
    ans /= j
  end
  ans %= 10**9 + 7
end

p ans


Measured memory_bytes: 2300
using System;
class Program
{
	static void Main(string[] args)
	{
		string t = Console.ReadLine();
		int N = int.Parse(t);
		string S = Console.ReadLine();
		int W = 0;
		int E = 0;
		for(var i=0;i<S.Length;i++){
			string u = S.Substring(i,1);
			if(u == "W"){
				W += 1;
			} else if(u == "E"){
				E += 1;
			}
		}
		int countmin = E;
		int count = E;
		for(var i=0;i<S.Length;i++){
			string u = S.Substring(i,1);
			if(u == "E"){
				count -= 1;
			}
			if(i > 0){
				string v = S.Substring(i-1,1);
				if(v == "W"){
					count += 1;
				}
			}
			countmin = Math.Min(countmin,count);
		}
		Console.WriteLine(countmin);
	}
}

Measured memory_bytes: 17288
#include<bits/stdc++.h>
#define maxn 200005
#define LL long long
using namespace std;
LL a[maxn],k;
LL cut[maxn];
int n;
LL L=1,R=0;
 
bool check(LL t){
	LL cnt=0;
	for(int i=1;i<=n;i++){
		cut[i]=(a[i]/t)-1+(a[i]%t>0);
		cnt+=cut[i];
	}
	if(cnt<=k)return 1;else return 0;
}
 
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)R=max(R,a[i]);
	R++;
	while(L+1<R){
		LL mid=L+R>>1;
	//	cout<<L<<" "<<R<<" "<<mid<<endl;
		if(check(mid))R=mid;else L=mid;
	}
	if(check(L))cout<<L<<endl;else cout<<R<<endl;
}

Measured memory_bytes: 6660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))
#define rep(i, c) for(auto &(i) : (c))
#define x first
#define y second
#define pb push_back
#define PB pop_back()
#define iOS ios_base::sync_with_stdio(false)
#define sqr(a) (((a) * (a)))
#define all(a) a.begin() , a.end()
#define error(x) cerr << #x << " = " << (x) <<endl
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define L(x) ((x)<<1)
#define R(x) (((x)<<1)+1)
#define umap unordered_map
#define double long double
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef complex<double> point;
template <typename T> using os =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>  inline void smax(T &x,T y){ x = max((x), (y));}
template <class T>  inline void smin(T &x,T y){ x = min((x), (y));}
const int maxn = 20;
bool b[maxn];
inline bool bad(int n){
	while(n){
		if(b[n % 10])	return true;
		n /= 10;
	}
	return false;
}
int main(){
	iOS;
	int n, k;
	cin >> n >> k;
	int a;
	while(k--){	cin >> a; b[a] = 1;}
	while(bad(n))	++ n;
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256