akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 1000006;

void solv()
{
    int x, y;
    scanf("%d%d", &x, &y);
    if (y % 2 == 1)
    {
        printf("No\n");
        return;
    }
    y /= 2;
    int q = 2 * x - y;
    if (0 <= q && q <= x)
        printf("Yes\n");
    else
        printf("No\n");
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 3580
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
	char s1[4],s2[4];
	while(~scanf("%s%*c%s",&s1,&s2))
	{
		if(s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2 [0])
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define CIN(s) int (s);cin>>(s);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;

int main(){
    ll n;
    cin>>n;
    ll res=INF;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            chmin(res,i+(n/i));
        }
    }
    cout<<res-2<<endl;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    string s, t;
    cin >> s >> t;

    for (int i = 0; i < N; ++i)
        cout << s[i] << t[i];

    cout << endl;

    return 0;
}


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

namespace kyopro
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] kx = Console.ReadLine().Split(' ');
            int k = int.Parse(kx[0]);
            int x = int.Parse(kx[1]);
            int d = x - k + 1;
            int u = x + k - 1;
            if(d < -100000)
            {
                d = -1000000;
            }
            if(u > 1000000)
            {
                u = 1000000;
            }
            for(int i = d;i <= u; i++)
            {
                Console.Write(i + " ");
            }
        }
    }
}

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

int a[100005];

int n,k,q;

int main(){
	cin>>n>>k>>q;
	for(int i=1;i<=q;i++){
		int x;cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++){
		if(k+a[i]-q<=0) cout<<"No"<<endl;
		else cout<<"Yes"<<endl; 
	}
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
a.sort()
M = max(a)
m = M / 2

diff = 10 ** 9
r = None
for i in range(n):
    if a[i] == M:
        continue
    else:
        if abs(m - a[i]) < diff:
            diff = abs(m - a[i])
            r = a[i]

print(M, r)


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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	if(n == 2){
		cout << -1 << '\n';
		return 0;
	}
	vector<string> s(n, string(n, '.'));
	if(n == 3){
		s[0][0] = s[1][0] = 'z';
		s[2][1] = s[2][2] = 'y';
		n -= 3;
	} else if(n == 7){
		s[0][0] = s[0][1] = 'z';
		s[2][1] = s[2][2] = 'y';
		s[2][4] = s[2][5] = 'x';
		s[3][3] = s[3][4] = 'w';
		s[4][3] = s[4][4] = 'v';
		s[5][5] = s[5][6] = 'u';
		s[6][5] = s[6][6] = 't';

		s[1][0] = s[2][0] = 'a';
		s[5][0] = s[6][0] = 'b';
		s[5][1] = s[6][1] = 'c';
		s[0][2] = s[1][2] = 'd';
		s[3][2] = s[4][2] = 'e';
		s[0][3] = s[1][3] = 'f';
		s[3][6] = s[4][6] = 'g';
		n -= 7;
	} else if(n & 1){
		s[0][1] = s[0][2] = 'z';
		s[1][2] = s[1][3] = 'y';
		s[2][0] = s[2][1] = 'x';
		s[4][0] = s[4][1] = 'w';
		s[4][3] = s[4][4] = 'v';

		s[0][0] = s[1][0] = 'a';
		s[3][2] = s[4][2] = 'b';
		s[2][3] = s[3][3] = 'c';
		s[0][4] = s[1][4] = 'd';
		s[2][4] = s[3][4] = 'e';
		n -= 5;
		reverse(s.begin(), s.end());
		for(auto& x : s) reverse(x.begin(), x.end());
	}
	assert(n != 2);
	for(int i = 0; i < n / 2; i++){
		s[2*i][2*i] = s[2*i][2*i+1] = 'z';
		s[2*i+1][2*i] = s[2*i+1][2*i+1] = 'y';
		int j = (i + 1) % (n / 2);
		s[2*j][2*i] = s[2*j+1][2*i] = 'a';
		s[2*j][2*i+1] = s[2*j+1][2*i+1] = 'b';
	}

	for(string z : s){
		cout << z << '\n';
	}
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 998244353
#define rep(i,x) for(int i=0;i<x;i++)
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[300005],R[300005],ans;
void make(){
	F[0] = 1;
	for(int i=1;i<300005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<300005;i++) R[i] = modpow(F[i],mod-2);
}
ll c(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
ll sol(int n,int m,string a,string b,string cc,string d){
	ll zan = 0,ret = 0;
	int A = 0,B = 0,C = 0,D = 0;
	rep(i,n) A+=a[i]-'0',B+=b[i]-'0';
	rep(i,m) C+=cc[i]-'0',D+=d[i]-'0';
	int CC = 0,DD = 0;
	for(int i=m-1;i>=0;i--){
		ll add = 0;
		if(CC+DD == 0 && B == 0){
			add = 1;
		}
		else if(B){
			add = c(B-1+CC+DD,B-1);
		}
		int cnt = cc[i]-'0' + d[i]-'0';
		C -= cc[i]-'0'; D -= d[i]-'0';
		CC += cc[i]-'0'; DD += d[i]-'0';
		if(A){
			ret += c(A-1+C+D,A-1) * ((add+zan)%mod) % mod * cnt % mod;
		}
		else if(C+D==0){
			ret += ((add+zan)%mod) % mod * cnt % mod;
		}
		zan = add * cnt % mod + zan * max(1,cnt) % mod;
	}
	return ret%mod;
}
int n,m,flag;
string a,b,cc,d;
int main(){
	cin>>n>>m>>a>>b>>cc>>d;
	rep(i,n) if(a[i]=='1'||b[i]=='1') flag=1;
	rep(i,m) if(cc[i]=='1'||d[i]=='1') flag=1;
	if(!flag){
	    puts("1");
	    return 0;
	}
	make();
	ans+=sol(n,m,a,b,cc,d);
	ans+=sol(m,n,cc,d,a,b);
	cout<<ans%mod<<endl;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		sc.nextLine();
		
		int[] score = new int[2];
		for (int i = 0; i < n; i++) {

			String[] taro_hana = sc.nextLine().split(" ");

			int res = taro_hana[0].compareTo(taro_hana[1]);

			if(res == 0) {
				score[0] += 1;
				score[1] += 1;
			} else if(res > 0) {
				score[0] += 3;
			} else {
				score[1] += 3;
			}
		}
		sc.close();

		System.out.println(score[0] + " " + score[1]);
	}
}

Measured memory_bytes: 31476
n, m, l = map(int, input().split())
A = [[int(x) for x in input().split()] for _ in range(n)]
B = [[int(x) for x in input().split()] for _ in range(m)]

ans = []
for i in range(n):
    row_lst = []
    for j in range(l):
        tmp_k = 0
        for k in range(m):
            tmp_k += A[i][k] * B[k][j]
        row_lst.append(tmp_k)
    ans.append(row_lst)
for row in ans:
    print(*row)


Measured memory_bytes: 7048
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int N, M, X, sum_l = 0, sum_r = 0;
    cin >> N >> M >> X;
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        (a < X) ? sum_l++ : sum_r++;
    }

    cout << min(sum_l,sum_r) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int l,k;
long ans;
long C(long a,long b)
{
	long ans=1;
	for(long i=1;i<=b;i++)ans=ans*(a-i+1)/i;
	return ans;
}
main()
{
	cin>>l>>k;
	for(int i=0;i<=l;i++)
	{
		for(int j=0;j<=l;j++)
		{
			if(i+j==0||i+j-1+i+j*k>l)continue;
			ans+=C(i+j,i);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main()
{

    char s[11];
    scanf("%s",s);
    int n=strlen(s);
    if(s[0]!='A'||s[1]=='C'||s[n-1]=='C')
    {
        cout<<"WA";
        return  0;
    }
    int c=0,cc=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]>='A'&&s[i]<='Z')c++;
        if(s[i]=='C')cc++;
    }
    if(cc!=1||c!=2)
    {
        cout<<"WA";
        return  0;

    }
    cout<<"AC";
    return 0;

}


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

int N, M, K;
int MOD = 998244353;
int MAX = 300000;

vector<long long int> fac(MAX), finv(MAX), inv(MAX);

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

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long int COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin >> N >> M >> K;
  COMinit();
  long long int ans = modpow(M - 1, N - 1);
  for (int i = 1; i <= K; i++) {
    ans += COM((long long int)N - 1, (long long int)i) * modpow(M - 1, N - 1 - i) % MOD;
    ans %= MOD;
  }
  ans *= M;
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 10280
#include<iostream>

using namespace std;

int main(){
  int A[3][3],N,bingo[3][3];
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> A[i][j];
      bingo[i][j]=0;
    }
  }
  cin >> N;
  for (int k = 0; k < N; k++){
    int b;
    cin >> b;
      for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
          if(A[i][j]==b){
            bingo[i][j]=1;
          }
        }
      }
  }
  
  int flg=0;
  for (int i = 0; i < 3; i++){
      if(bingo[i][0]==1 && bingo[i][1]==1 && bingo[i][2] == 1){
        flg=1;
      }
      if(bingo[0][i]==1 && bingo[1][i]==1 && bingo[2][i] == 1){
        flg=1;
      }
  }

  if(bingo[0][0]==1 && bingo[1][1]==1 && bingo[2][2] == 1){
    flg=1;
  }
  if(bingo[0][2]==1 && bingo[1][1]==1 && bingo[2][0] == 1){
    flg=1;
  }

  if(flg==1){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}


Measured memory_bytes: 3628
n,m=map(int,input().split())
g=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

from collections import deque

def bfs(u):
    queue = deque([u])
    d=[-1]*n
    pre=[-1]*n
    d[u]=0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is -1:
                if pre[i] == -1:
                    pre[i]=v
                d[i]=d[v]+1
                queue.append(i)
    return d,pre
d,pre=bfs(0)
print('Yes')

for i in range(n):
    if i==0:
        continue
    print(pre[i]+1)

Measured memory_bytes: 34500
#include <iostream>
using namespace std;
using ll = long long;

ll d[300][300];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> d[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (d[i][k] + d[k][j] < d[i][j]) {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      bool need = true;
      for (int k = 0; k < N; k++) if(k != i && k != j) {
        if (d[i][k] + d[k][j] == d[i][j]) {
          need = false;
          break;
        }
      }
      if (need) {
        res += d[i][j];
      }
    }
  }
  cout << res / 2 << endl;
  return 0;
}


Measured memory_bytes: 896
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Main
fn main(){
    input!{
        D: usize,
    }
    print!("{}", "Christmas");
    for _i in 0..25-D{
        print!("{}"," Eve");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950



int main() {
    int a, b, c, x; std::cin >> a >> b >> c >> x;
    int count = 0;
    for (int i = 0; i <= a; ++i) {
        for (int j = 0; j <= b; ++j) {
            for (int k = 0; k <= c; ++k) {
                if (500 * i + 100 * j + 50 * k == x)
                    ++count;
            }
        }
    }
    std::cout << count << std::endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int s[101];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
	}
	int min=10001;
	for(int i=1;i<=n;i++)
	{
		int a,b;
		a=b=0;
		for(int j=1;j<i;j++)
		{
			a+=s[j];
		}
		for(int j=i;j<=n;j++)
		{
			b+=s[j];
		}
		int c=abs(a-b);
		if(c<min)
		{
			min=c;
		}
	}
	cout<<min;
}

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/


int main(){
  ll N;
  string s;

  cin >> N >> s;
  
  vector<ll> v(N),w(N),e(N);
  
  REP(i,N-1) w[i] = w[i-1] + (s[i-1] == 'W'?1:0);
  for(int i = N-2;i >= 0;i--) e[i] = e[i+1] + (s[i+1] == 'E'?1:0);
  
  rep(i,N) v[i] = e[i] + w[i];
  

  sort(ALL(v));
  
  cout << v[0] << endl;
}
    

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n, d;
    cin >> n >> d;
    cout << (n + 2 * d) / (2 * d + 1) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	static long mod=1000000007;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long ans=0;
		long[] x=new long[n];
		for(int i=0; i<n; i++){
			x[i]=sc.nextLong();
		}
		long fact=1;
		for(int i=2; i<n; i++){
			fact*=i;
			fact%=mod;
		}
		long sum=0;
		for(int i=0; i<n-1; i++){
			sum+=pow(i+1,mod-2);
			sum%=mod;
			ans+=(x[i+1]-x[i])*(sum*fact%mod);
			ans%=mod;
		}
		System.out.println(ans);
	}
	static long pow(long p,long q){
		long res=1;
		while(q>0){
			if((q & 1)==1){
				res*=p;
				res%=mod;
			}
			q>>=1;
			p*=p;
			p%=mod;
		}
		return res;
	}
}


Measured memory_bytes: 50472
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef vector<int> vi;

void bf(vp e[], int n, int dis[]) {
    for (int i = 0; i < n; i++) {
        for (int x = 0; x < n; x++) {
            for (pii y : e[x]) {
                dis[y.second] = max(dis[y.second], dis[x] + y.first);
            }
        }
    }
}

void dfs(vp e[], int x, bool v[]) {
    if (v[x]) {
        return;
    }

    v[x] = true;
    for (pii y : e[x]) {
        dfs(e, y.second, v);
    }
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    vp e[n], ie[n];
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--, c -= p;
        e[a].push_back({c, b});
        ie[b].push_back({c, a});
    }

    int dis[n];
    fill(dis, dis+n, -5e8);
    dis[0] = 0;
    bf(e, n, dis);

    // buggy
    // a path with negative cycle may be relaxed
    // after 1e9 times of loop
    // we should check all points in negative cycle
    // if they can go to vertex n
    /*
    bf(e, n, dis);
    int sc2 = dis[n-1];
    */

    bool inc[n];
    memset(inc, false, sizeof(inc));
    for (int i = 0; i < n; i++) {
        for (int x = 0; x < n; x++) {
            for (pii y : e[x]) {
                if (dis[x] + y.first > dis[y.second]) {
                    inc[y.second] = true;
                }
            }
        }
    }

    bool v0[n];
    memset(v0, false, sizeof(v0));
    dfs(e, 0, v0);

    bool vn[n];
    memset(vn, false, sizeof(vn));
    dfs(ie, n - 1, vn);

    bool cycle = false;
    for (int i = 0; i < n; i++) {
        cycle |= inc[i] && v0[i] && vn[i];
    }

    cout << (cycle ? -1 : max(0, dis[n-1])) << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int a, b, c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"; return 0;
    }
    else {
        cout<<"win"; return 0;
    }
}

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


int main()
{
	int n; cin >> n;
	int ans;
	for (int i = 1; i < 11; ++i)
		if (i * 1000 >= n)
		{
			ans = i * 1000 - n;
			break;
		}
	cout << ans << endl;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 5005;
const int mod = 1e9 + 7;

int n, m, tot, ans, a[MAXN], f[MAXN];

inline int Qow(int x, int y)
{
	int r = 1;
	for (; y; y >>= 1, x = 1LL * x * x % mod)
		if (y & 1)
			r = 1LL * r * x % mod;
	return r;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read();
	for (int i = 1; i * i <= n; i ++)
		if (n % i == 0)
		{
			a[++ tot] = i;
			if (i * i < n)
				a[++ tot] = n / i;
		}
	sort(a + 1, a + tot + 1);
	for (int i = 1; i <= tot; i ++)
	{
		f[i] = Qow(m, a[i] + 1 >> 1);
		for (int j = 1; j < i; j ++)
			if (a[i] % a[j] == 0)
				f[i] = (f[i] - f[j] + mod) % mod;
		ans = (1LL * f[i] * (a[i] & 1 ? a[i] : a[i] >> 1) + ans) % mod;
	}
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 256
# coding: utf-8
import math
#n = int(input())
#x, y = map(int,input().split())
#A = list(map(int,input().split()))
ans = 0
s = input()
n = len(s)
s=s[::-1]
i=0
flg=True
while True:
    if i>=n:
        break
    if s[i:i+7]=="remaerd":
        i+=7
    elif s[i:i+6]=="resare":
        i+=6
    elif s[i:i+5]=="maerd" or s[i:i+5]=="esare":
        i+=5
    else:
        flg=False
        break
if flg:
    print("YES")
else:
    print("NO")

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

signed main() {
  int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    	std::string s(a,'0');
    	std::string t(w-a,'1');
        std::string ans=s+t;
  		std::string S(a,'1');
  		std::string T(w-a,'0');
  		std::string Ans=S+T;
  for(int i=0;i<h;++i){
    if(i<b){
    	printf("%s\n",ans.c_str());
    }
    else{
    	printf("%s\n",Ans.c_str());
    }
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    vector<int> sorted(n);
    rep(i,n){
        int tmp;cin>>tmp;
        vec[i]=tmp;
        sorted[i] = tmp;
    }
    sort(all(sorted));
    int first = sorted[n/2-1];
    int second = sorted[n/2];
    rep(i,n){
        if (vec[i]<=first){
            cout << second << endl;
        }else{
            cout << first << endl;
        }
    }
}

Measured memory_bytes: 3712
#include<stdio.h>

int main(void) {
	int b, f, r, v, A[4][3][10] = { 0 }, n, i, j, k;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		A[b-1][f-1][r-1] += v;
	}

	for (i = 0; i < 4; ++i) {
		for (j = 0; j < 3; ++j) {
			for (k = 0; k < 10; ++k) printf(" %d", A[i][j][k]);
			puts("");
		}
		if (i != 3) {
			for (j = 0; j < 20; ++j) printf("#");
			puts("");
		}
	}
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
int a,b,h,m;
int main()
{
    cin>>a>>b>>h>>m;
    return printf("%.10f",sqrt(a*a+b*b-2*a*b*cos((h*30-m*5.5)/180*PI))),0;
}

Measured memory_bytes: 4164
def main():
    t_n = int(input())
    price_a, price_b = map(int, input().split())
    cal_a = int(input())
    t_c = sorted([int(input()) for _ in range(t_n)], reverse=True)

    cpd_a = cal_a / price_a
    cal_sum = cal_a
    price_sum = price_a
    b_sum = 0
    for i in range(t_n):
        b_sum += t_c[i]
        new_cpd_a = (cal_a + b_sum) / (price_a + (i + 1) * price_b)
        if new_cpd_a > cpd_a:
            cal_sum += t_c[i]
            price_sum += price_b
            cpd_a = new_cpd_a

    print(int(cal_sum / price_sum))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
N = int(input())
S = input()

LETTERS = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
LETTERS_dict = {}
for i in range(26):
    LETTERS_dict[LETTERS[i]] = i
ans = ""
for s in S:
    ans = ans + LETTERS[(LETTERS_dict[s]+N)%26]
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;

int main(){
	cin>>n;
	cout<<(n-2)*180<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int main(int argc, char **argv) {
    int N, K, h[100000];
    cin >> N >> K;
    for(int i = 0; i < N; ++i) {
        cin >> h[i];
    }

    sort(h, h + N);

    int res = INF;
    for(int i = 0; i + K - 1 < N; ++i) {
        res = min(res, h[i + K - 1] - h[i]);
    }
    
    cout << res << endl;
}

Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Data.List
import Data.Ratio
import Data.IntMap (IntMap)
import qualified Data.IntMap as IM
import Text.Printf

main :: IO ()
main = do
  [n, w] <- map read <$> words <$> getLine
  unless (n == 0 && w == 0) $ do
    solve w <$> (replicateM n readLn) >>= printf "%f\n"
    main

solve :: Int -> [Int] -> Double
solve w vs = fr $ IM.foldlWithKey g (1 % 100) hg
  where hg = foldl' f IM.empty vs :: IntMap Int
        f m v = IM.insertWith (+) (v `div` w) 1 m
        mk = fst . IM.findMax $ hg
        mv = IM.foldl' max 0 hg
        g s k v = s + ((mk - k) % mk) * (v % mv)
        fr x = (fromIntegral (numerator x)) / (fromIntegral (denominator x))



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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 256
import sys; readline = sys.stdin.readline
from collections import deque

X, Y = map(int, readline().split())

ans = 0

for a in (X, Y):
    if a == 1:
        ans += 300000
    elif a == 2:
        ans += 200000
    elif a == 3:
        ans += 100000

if X == 1 and Y == 1:
    ans += 400000

print(ans)

Measured memory_bytes: 40500
#include <iostream>
#include <cstring>
using namespace std;
//strÌ(start)Ú©ç(len)¶æèo·
char* strpick(char *str, int start, int len)
{
	char *result = new char[len+1];
	for (int i = 0; i < len; i++)
	{
		result[i] = str[start+i];
	}
	result[len] = '\0';
	return result;
}
int main()
{
	char str[10001];
	char *tmp = new char[4];
	int ioi, joi, i;
	while (cin >> str)
	{
		if (cin.eof()) break;
		ioi = joi = 0;
		for (i = 0; i < strlen(str);)
		{
			if (str[i] == 'I' || str[i] == 'J')
			{
				tmp = strpick(str, i, 3);
				if (strcmp(tmp, "IOI") == 0)
					ioi++, i+=2;
				else if (strcmp(tmp, "JOI") == 0)
					joi++, i+=2;
				else
					i++;
			}
			else
				i++;
		}
		cout << joi << endl << ioi << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>

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

using namespace std;

int main(){
  string S;
  cin >> S;
  //入力終了

  int N = S.size();

  //白石に関して，左側にある黒石の数だけ移動できることに着目
  
  //i番目の石の左側に黒石が何個あるか(実装上，自分も含む)
  int left_black_num[N];
  rep(i, N)
    left_black_num[i] = 0;

  //初期値
  if(S[0] == 'B')
    left_black_num[0]++;

  rep(i, N-1){
    int tmp = 0;
    //次が黒石ならカウントの準備
    if(S[i+1] == 'B')
      tmp = 1;
    //「左黒石数」の更新
    left_black_num[i+1] = left_black_num[i]+tmp;
  }

  long long ans = 0;
  //白石に関して，左側にある黒石の数を足していく
  rep(i, N)
    if(S[i] == 'W')
      ans += left_black_num[i];

  //解答
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4496
#include<cstdio>
using namespace std;
int n,m,dis;
char str[5]="BGRY";
int main(){
	scanf("%d%d%d",&n,&m,&dis);
	if (dis&1){
		for (int i=0;i<n;i++){
			for (int j=0;j<m;j++) printf("%c",str[i+j&1]);
			printf("\n");
		}
	}
	else{
		for (int i=0;i<n;i++){
			for (int j=0;j<m;j++) printf("%c",str[((i+j)/dis&1)+((i-j+10000)/dis&1)*2]);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 384
//============================================================================
// Name        : ATCoder.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>

using namespace std;

int F[101]={};
int P[101][11]={};

int main() {
	int N;
	cin>>N;
	int f1;
	for(int i=0;i<N;++i){
		for(int j=1;j<(1<<10);j=j<<1){
			cin>>f1;
			F[i]+=f1*j;
		}
	}
	for(int i=0;i<N;++i){
		for(int j=0;j<11;j++){
			cin>>P[i][j];
		}
	}
	int x,m,sum;
	int total=-1000000000;
	for(int i=1;i<(1<<10);i++){
		sum=0;
		for(int j=0;j<N;++j){
			x=i&F[j];
			m=0;
			for(int k=1;k<(1<<10);k=k<<1){
				if((x&k)==k)m++;
			}
			sum+=P[j][m];
		}
		total=max(total,sum);
	}


	cout <<total<< endl; // prints !!!Hello World!!!
	return 0;
}


Measured memory_bytes: 256
// AOJ 2332: Space-Time Sugoroku Road
// 2017.11.27 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 150000
typedef struct { int t, node; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].node, *t = que[0].t, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
//	return 1;
}

void enq(int n, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].node = n, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

typedef struct { int to[6]; char one[6]; } TBL;
TBL tbl[100002];
int len[100002];
int dist[100002];

int dijkstra(int start, int goal)
{
	int i, s, e, d;

	qsize = 0;
	dist[start] = 0;
	enq(start, 0);
	while (qsize) {
		s = que[0].node; deq();
		if (s == goal) break;
		for (i = 0; i < len[s]; i++) {
			e = tbl[s].to[i];
			d = dist[s] + tbl[s].one[i];
			if (d < dist[e]) dist[e] = d, enq(e, d);
		}
	}
	return dist[goal];
}

char buf[10], *bp;
int getint()
{
	int n = 0;
	if (*bp == '-') {
		bp++; while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
		return -n;
	}
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, i, p, j, jj;

	while (fgets(bp=buf,10, stdin) && *bp != '0') {
		n = getint();
		for (i = 1; i < n; i++) {
			fgets(bp=buf, 10, stdin);
			p = getint();
			if (!p) {
				for (jj = i + 1, j = 1; jj <= n && j <= 6; j++, jj++) {
					tbl[i].to[len[i]] = jj, tbl[i].one[len[i]++] = 1;
				}
			} else {
				jj = i + p;
//				if (jj < 1) jj = 1;
//				else if (jj > n) jj = n;
				tbl[i].to[len[i]] = jj, tbl[i].one[len[i]++] = 0;
			}
		}
		memset(dist, 0x33, sizeof(dist));
		printf("%d\n", dijkstra(1, n));
	}
	return 0;
}

Measured memory_bytes: 5756
///CommentaryAC

#include <iostream>
using namespace std;
int findSumOfDigits(int n){
    int sum = 0;
    while (n > 0){
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main(){ 
    int n, a, b;
    cin >> n >> a >> b;
    int total = 0;
    for (int i=1;i<=n;++i){
        int sum = findSumOfDigits(i);
        if (sum >= a && sum <=b){
            total +=i;
        }
    }
    cout << total << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MOD 1000000007

int N;
char S1[53], S2[53];

int main(void) {
	int i;
	long long int ans;
	scanf("%d%s%s", &N, S1, S2);

	if (S1[0] == S2[0]) {
		ans = 3;
		i = 1;
	}
	else {
		ans = 6;
		i = 2;
	}

	for (; i < N; i++) {
		if (S1[i] == S2[i] && S1[i - 1] == S2[i - 1])
			ans = ans * 2 % MOD;
		else if (S1[i] == S2[i] && S1[i - 1] != S2[i - 1])
			;
		else if (S1[i] != S2[i] && S1[i - 1] == S2[i - 1]) {
			ans = ans * 2 % MOD;
			i++;
		}
		else if (S1[i] != S2[i] && S1[i - 1] != S2[i - 1]) {
			ans = ans * 3 % MOD;
			i++;
		}
	}
	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{

    public static void main(String[] args) throws Exception{

        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String t = sc.next();

        if(t.equals(s + t.charAt(t.length() - 1))){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 39032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <set>
#include <utility>
#include <climits>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>

#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC";
	else cout << "ABC";
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans=0;
    for (int i=0;i<s.size()-2;i++){
        if (s[i] == 'A'){
            if (s[i+1] == 'B' && s[i+2] == 'C'){
                ans++;
            } 
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

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

    vector<ll> p(N);
    ALLIN1_NUMBER(p);
    sort(ALL(p));

    OUT0(accumulate(p.begin(),p.begin()+K,0LL));

    return 0;
}

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

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

  vector<vector<char>> s(h+2,vector<char>(w+2,'.'));
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
	cin >> s.at(i).at(j);
    }
  }

  bool flag = true;
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      if (s.at(i).at(j) == '#') {
	if (s.at(i).at(j+1)=='.'
	    && s.at(i+1).at(j)=='.'
	    && s.at(i).at(j-1)=='.'
	    && s.at(i-1).at(j)=='.')
	  flag = false;
      }
    }
  }

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

Measured memory_bytes: 256
#include <iostream>


int main()
{
	char x, y;
	std::cin >> x >> y;
	if (x < y) {
		std::cout << "<" << std::endl;
	}
	if (x > y) {
		std::cout << ">" << std::endl;
	}
	if (x == y) {
		std::cout << "=" << std::endl;
	}
    return 0;
}


Measured memory_bytes: 256
import sys
import collections

while True:
    N = int(sys.stdin.readline())
    if N == 0:
        break
    
    pos = {0:(0, 0)}
    
    for i in xrange(N - 1):
        n, d = map(int, sys.stdin.readline().split())
        if d == 0:
            pos[i + 1] = (pos[n][0] - 1, pos[n][1])
        elif d == 1:
            pos[i + 1] = (pos[n][0], pos[n][1] - 1)
        elif d == 2:
            pos[i + 1] = (pos[n][0] + 1, pos[n][1])
        elif d == 3:
            pos[i + 1] = (pos[n][0], pos[n][1] + 1)
    
    max_x = min_x = max_y = min_y = 0
    for x, y in pos.values():
        max_x = max(x, max_x)
        min_x = min(x, min_x)
        max_y = max(y, max_y)
        min_y = min(y, min_y)
    
    print max_x - min_x + 1, max_y - min_y + 1

Measured memory_bytes: 4628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<cmath>
#include<complex>
#define INF 10000000
#define pb push_back
using namespace std;
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
typedef complex<double> Point;
typedef pair<double ,int > P;
const double PI=4*atan(1);
vector<vector<Point> > p;
int n,s,g;
double dot(Point a, Point b){
    return real( conj(a) * b );
}
double cross(Point a, Point b){
    return imag( conj(a) * b );
}
double dlp(Point a, Point b, Point c) {
  if ( dot(b-a, c-a)<=0 ) return abs(c-a);
  if ( dot(a-b, c-b)<=0 ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}
int iil(Point a1, Point a2, Point b1, Point b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) <=0 ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) <=0 );
}
double dll(Point a1,Point a2,Point a3,Point a4){
    if(iil(a1,a2,a3,a4))
        return 0.0;
	return min(min(dlp(a1,a2,a3),dlp(a1,a2,a4)),min(dlp(a3,a4,a1),dlp(a3,a4,a2)));
}
double cal(int a,int b){
    double ret=INF;
    for(int i=0;i<5;i++){
        for(int j=2;j<4&&i+j<5;j++){
            for(int k=0;k<5;k++){
                for(int l=2;l<4&&k+l<5;l++){
                    double u=dll(p[a][i],p[a][i+j],p[b][k],p[b][k+l]);
                    if(ret>u)
                        ret=u;
                }
            }
        }
    }
    return ret;
}
int main(){
    while(cin>>n>>s>>g,n||s||g){
        p.clear();
        p.resize(n);
        for(int i=0;i<n;i++){
            double x,y,a,r;
            cin>>x>>y>>a>>r;
            Point c=Point(x,y);
            for(int j=0;j<5;j++){
            	p[i].pb(c+polar(r,(a+72.0*j+90)*PI/180.0));
            }
        }
        vector<vector<double> > cost(n,vector<double>(n,INF));
        for(int i=0;i<n;i++){
            for(int j=i;j<n;j++){
            	if(i==j){
            		cost[i][j]=0;
            		continue;
            	}
                double a=cal(i,j);
                cost[i][j]=cost[j][i]=a;
            }
        }
    	for(int k=0;k<n;k++){
    		for(int i=0;i<n;i++){
    			for(int j=0;j<n;j++){
    				cost[i][j]=min(cost[i][k]+cost[k][j],cost[i][j]);
    			}
    		}
    	}
    	printf("%.8lf\n",cost[s-1][g-1]);
    }
    return 0;
}

Measured memory_bytes: 1100
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 100005
#define ll long long
struct Edge{
    ll to;
    ll next;
    ll cost;
};
Edge edge[MAX*2];
ll head[MAX];
ll dis[MAX];
ll n,u,v,w,q,k,cnt;
void DFS(ll u,ll v,ll w)
{
    dis[u]=w;
    for(ll i=head[u];i!=-1;i=edge[i].next)
    {
        ll to=edge[i].to;
        if(to==v)
            continue;
        DFS(to,u,w+edge[i].cost);
    }
    return ;
}
int main()
{
    scanf("%lld",&n);
    memset(head,-1,sizeof(head));
    for(ll i=1;i<=n-1;i++)
    {
        scanf("%lld%lld%lld",&u,&v,&w);
        edge[cnt].to=v;
        edge[cnt].cost=w;
        edge[cnt].next=head[u];
        head[u]=cnt++;
        edge[cnt].to=u;
        edge[cnt].cost=w;
        edge[cnt].next=head[v];
        head[v]=cnt++;
    }
    scanf("%lld%lld",&q,&k);
    DFS(k,-1,0);
    while(q--)
    {
        scanf("%lld%lld",&u,&v);
        printf("%lld\n",dis[u]+dis[v]);
    }
    return 0;
}


Measured memory_bytes: 12800
#include<cstdio>
const int MAXN=1e5+5;
int fa[MAXN],a[MAXN],b[MAXN];
long long ans[MAXN],sum[MAXN];
void makeSet(int n)
{
	for(int i=1;i<=n;i++) fa[i]=i,sum[i]=1;
}
int findSet(int x)
{
	if(fa[x]!=x)
		fa[x]=findSet(fa[x]);
	return fa[x];
}
/*void unionSet(int x,int y)
{
	int u=findSet(x),v=findSet(y);
	if(u==v) return;
	fa[u]=v; 
}*/
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	makeSet(n);
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
	}
	ans[m+1]=(long long)n*(long long)(n-1)/2;
	for(int i=m;i>1;i--)
	{
		int x=findSet(a[i]),y=findSet(b[i]);
		if(x!=y)
		{
			ans[i]=ans[i+1]-sum[x]*sum[y];
			sum[x]+=sum[y];
			sum[y]=0;
			fa[y]=x;
		}
		else ans[i]=ans[i+1];
	}
	for(int i=2;i<=m+1;i++) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

void Main() {
  int N; cin >> N;
  string res = "No";
  rep(a, 1, 10){
    rep(b, 1, 10){
      if(a * b == N){
        res = "Yes";
      }
    }
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 8064
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2232

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;
 
int H,W,N;

bool isFalled;
vector< vector<char> > tmp;

bool win(vector< vector<char> > field)
{
	rep(y,H){
		rep(x,W){
			if(field[y][x] != '.'){ return false; }
		}
	}
	return true;
}

int fall()
{
	int cnt = 0;
	for(int y=H-1; y>0; y--){
		for(int x=W-1; x>=0; x--){
			if(tmp[y][x] == '.' && tmp[y-1][x] != '.'){
				swap(tmp[y][x],tmp[y-1][x]);
				cnt++;
			}
		}
	}
	return cnt;
}

void erase()
{
	vector< vector<bool> > del(H,vector<bool>(W,false));
	rep(y,H)
	{
		rep(x,W)
		{
			char self = tmp[y][x];
			if(self == '.'){ continue; }

			//横の処理
			int cnt=0;
			REP( i, x, W ){
				if( self == tmp[y][i] ){ cnt++; }
				else{ break; }
			}
			if(cnt >= N){
				REP( i, x, W ){					
					if( self == tmp[y][i] ){ del[y][i] = true; }
					else{ break; }
				}
			}
			
			//縦の処理
			cnt = 0;
			REP( i, y, H ){
				if( self == tmp[i][x] ){ cnt++; }
				else{ break; }
			}
			if(cnt >= N){
				REP( i, y, H ){					
					if( self == tmp[i][x] ){ del[i][x] = true; }
					else{ break; }
				}
			}
		}
	}

	rep(y,H){
		rep(x,W){
			if(del[y][x]){ tmp[y][x] = '.'; }
		}
	}
}

void show()
{
	rep(i,H){
		DUMP(tmp[i]);
	}
	cout << "-------------------" << endl;
}

int main()
{
	cin >> H >> W >> N;
	vector< vector<char> > field(H,vector<char>(W,'.'));

	rep(y,H){
		rep(x,W){
			cin >> field[y][x];
		}
	}

	rep(y,H){
		rep(x,W-1)
		{
			tmp = field;
			swap(tmp[y][x],tmp[y][x+1]);
			int cnt=1;
			while(true)
			{
				while(cnt){ cnt = fall(); }
				erase();
				cnt = fall();
				if(!cnt){ break; }
			}

			if(win(tmp)){ //クリアー判定
				cout << "YES" << endl; 
				goto end;
			}
		}
	}
	cout << "NO" << endl;
end:
	return 0;
}

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

int main()
{
   int n;
   cin >> n;
   vector<int> a;
   ll sum = 0;
   for(int i =1;i<=n;i++)
   {
      if(n>sum)
      sum+= i,a.push_back(i);
   }
   for(auto i:a)
   {
      if(sum-i==n)continue;
      cout<<i<<endl;
   }
}

Measured memory_bytes: 384
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main()
{
	unsigned int n, k, d, t;
	unsigned int ans = 0;
	char sunu[100] = { 0 };

	// input
	cin >> n >> k;
	for (unsigned int i = 0; i < k; i++) {
		cin >> d;
		for (unsigned int j = 0; j < d; j++) {
			cin >> t;
			sunu[t - 1] = 1;
		}
	}

	// calc
	for (unsigned int i = 0; i < n; i++) {
		if ( 0 == sunu[i] ) { ans++; }
	}

	// output
	cout << ans;
	cout << endl;

	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;

int main(){
	int K,S;
	cin >> K >> S;

	int cntr = 0;
	rep(X,K+1)
		rep(Y,K+1)
			if(0<=S-X-Y && S-X-Y<=K)
				cntr++;
	cout << cntr << endl;

}

Measured memory_bytes: 256