akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int X;
    cin >> X;
    vector<bool> prime(200000,true);
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i < 200000; i++)
    {
        for (int j = i+i; j < 200000; j+=i)
        {
            prime[j] = false;
        }
    }
    while(!prime[X])
    {
        ++X;
    }
    cout << X << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int D,T,S;
    cin>>D>>T>>S;
    int d=D/S+(D%S!=0);
    if(d<=T) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


int main(){
    string S;
    cin>>S;
    long K;
    cin>>K;
    long tmp=K;
    REP(i,SZ(S)){
        if(S[i]=='a')continue;
        long gap=(long)('z'-S[i])+1L;
        if(gap<=tmp){
            S[i]='a';
            tmp-=gap;
        }
    }
    int np=SZ(S)-1;
    int gap=tmp%26;//26以上はどっかが吸収する
    if((int)('z'-S[np])>=gap)S[np]=(char)(S[np]+gap);
    else{
        int t=(int)('z'-S[np])+1;
        S[np]=(char)('a'+gap-t);
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 640
import math

# 0以上整数x「未満」の素数をリストに格納して返す
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


# 整数xが素数かどうかを判定する
def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


if __name__ == '__main__':
    x = int(input())
    
    while(not is_prime(x)):
        x += 1
        
    print(x)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter pw=new PrintWriter(System.out);
		int t=scan.nextInt();
		Set<String> set=new HashSet<String>();
		while((t--)!=0){
			String s=scan.next();
			String ch=scan.next();
			if(s.charAt(0)=='i'){
				set.add(ch);
			}else{
				if(set.contains(ch))
					pw.println("yes");
				else
					pw.println("no");
			}
		}
		pw.close();
	}


}

Measured memory_bytes: 229560
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=200005;
int n,ans;
int dp[maxn],f[maxn];
vector<int>edge[maxn];

void dfs(int x,int p){
	rep(i,edge[x].size()){
		int y=edge[x][i];
		if(y==p)continue;
		dfs(y,x);
		ans=max(ans,dp[x]+dp[y]+1);
		dp[x]=max(dp[x],dp[y]+1);
	}
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	f[1]=1;
	f[2]=0;
	for(int i=3;i<=n+1;i++){
		if(!f[i-1]||!f[i-2])f[i]=1;
		else f[i]=0;
	}
	REP(i,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs(1,0);
	puts(f[ans+1]?"First":"Second");
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 24704
#include <stdio.h>
int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    int d, r;
    double f;
    r = a % b;
    d = (a - r) / b;
    f = (double) a / (double) b;
    printf("%d %d %lf\n", d, r, f);
    return 0;
}


Measured memory_bytes: 2756
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let d = read::<usize>();
    let d = d * 2 + 1;
    println!("{}", (n + d - 1) / d);
}


Measured memory_bytes: 4352
import scala.io.StdIn._
object Main extends App{
  val N = readLine().toInt

  var sum = 0L
  (1 to N).foreach(i =>{
    if(i % 3 == 0 || i % 5 == 0){
    }else{
      sum = sum + i
    }
  })
  println(sum)
}


Measured memory_bytes: 54636
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stack>
#include <deque>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pii pair<pi,int>
#define sqr(x) ((x)*(x))
#define FOR for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int q[1010000][2],head,tail,d[810][810];
int n,m,k,sx,sy;
char p[810][810];
void ins(int x,int y,int cr){
	if(d[x][y]<=cr||p[x][y]!='.')return;
	d[x][y]=cr;
	tail++;
	q[tail][0]=x,q[tail][1]=y;}

int main()
{
	int i,j,x,y;
	cin>>n>>m>>k;
	for(i=1;i<=n;i++){
		scanf("%s",p[i]+1);
		for(j=1;j<=m;j++){
			if(p[i][j]=='S')

			sx=i,sy=j,p[i][j]='.';
			d[i][j]=1e9;}}
	ins(sx,sy,0);
	while (head<tail){
		head++;
		x=q[head][0],y=q[head][1];
		ins(x+1,y,d[x][y]+1);
		ins(x,y+1,d[x][y]+1);
		ins(x-1,y,d[x][y]+1);
		ins(x,y-1,d[x][y]+1);}
	int res=1e9;
	FOR{
		if(d[i][j]<=k)res=min(res,1+(min(min(i-1,n-i),min(j-1,m-j))+k-1)/k);}
	cout<<res<<endl;
    //system("pause");
    return 0;
}


Measured memory_bytes: 8448
mod = 10 ** 9 + 7

N, M = map(int, input().split())
S = input().split()
T = input().split()

dp = [[0] * (M + 2) for _ in range(N + 2)]
for i in range(N+1):
    dp[i][0] = 1
for j in range(M+1):
    dp[0][j] = 1

for i, s in enumerate(S, 1):
    for j, t in enumerate(T, 1):
        dp[i][j] += dp[i - 1][j]
        dp[i][j] += dp[i][j - 1]
        if s == t:
            dp[i][j] += dp[i - 1][j - 1]
        dp[i][j] -= dp[i - 1][j - 1]
        dp[i][j] += mod
        dp[i][j] %= mod

print(dp[N][M])

Measured memory_bytes: 73564
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int gcd(int x, int y)
{
    if (x < y)
        swap(x, y);
    if (x % y != 0)
        gcd(y, x % y);
    else
        return y;
}

int main()
{
    int x, y;
    cin >> x >> y;
    printf("%d\n", gcd(x, y));
}


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

int main() {
  string S;
  cin >> S;

  int ans = (int)pow(10, 9);
  for (int i = 0; i < S.size() - 2; i++) {
    int n = stoi(S.substr(i, 3));
    ans = min(abs(753 - n), ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define TRUE 1
#define FALSE 0

int n=0;
int A[2000];
int calc(int , int);

int main(){
  int i=0;
  int q=0;
  int m[2000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }

  for(i=0;i<q;i++){
    if(calc(0,m[i])==TRUE)printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int calc(int i,int M){
  if(M==0){
    return TRUE;
  }
  if(i>=n){
      return FALSE;
    }
  int res = calc(i+1,M) || calc(i+1,M-A[i]);
  return res;
}



Measured memory_bytes: 2104
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>

#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define LL long long
#define INF (2147483647)
#define sqr(x)	((x)*(x))

using namespace std;

inline void read(int &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(int x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

inline void read(LL &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(LL x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

int d[1000005],b[1000005],t[1000005],a[1000005];

int main(){	
	int n,dis;
	read(n),read(dis);
	rep(i,1,n){
		read(d[i]);
		a[i]=dis;
		dis=min(dis,abs(dis-d[i]));
	}
	int q;read(q);
	rep(i,1,q)	read(t[i]);
	b[n+1]=1;
	per(i,n,1)	
		if (b[i+1]<=d[i]/2)
			b[i]=b[i+1];
		else b[i]=b[i+1]+d[i];
	rep(i,1,q)
		if (b[t[i]+1]<=a[t[i]])
			puts("YES");
		else puts("NO");
} 

Measured memory_bytes: 16128
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int[] count = new int[4];
        for (int i = 0; i < 6; i++) {
            count[scanner.nextInt() - 1]++;
        }
        Arrays.sort(count);
        System.out.println(Arrays.equals(count, new int[]{1, 1, 2, 2}) ? "YES" : "NO");
    }
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for (int i = 0; i < X; ++i) cin >> A[i];
    for (int i = 0; i < Y; ++i) cin >> B[i];
    for (int i = 0; i < Z; ++i) cin >> C[i];
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    priority_queue<tuple<ll, int, int, int>> pq;
    set<tuple<int, int, int>> used;
    pq.emplace(A[0] + B[0] + C[0], 0, 0, 0);
    used.emplace(0, 0, 0);
    for (int i = 0; i < K; ++i) {
        auto e = pq.top();
        pq.pop();
        ll ans = get<0>(e);
        int a = get<1>(e);
        int b = get<2>(e);
        int c = get<3>(e);
        cout << ans << endl;
        int da[3] = {1, 0, 0};
        int db[3] = {0, 1, 0};
        int dc[3] = {0, 0, 1};
        for (int j = 0; j < 3; ++j) {
            int x = a + da[j];
            int y = b + db[j];
            int z = c + dc[j];
            if (!(x < X && y < Y && z < Z)) continue;
            if (used.find(make_tuple(x, y, z)) == used.end()) {
                ll sum = A[x] + B[y] + C[z];
                pq.emplace(sum, x, y, z);
                used.emplace(x, y, z);
            }
        }
    }
}

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

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().Int();
            var l = new int[n];
            var r = ReadSplit();
            for (int i = 0; i < n; i++)
            {
                l[i] = r[i].Int();
            }

            long x = 0;
            for (int i = n - 1; i >= 0; i--)
            {
                if (i % 2 == 0)
                {
                    x += l[i];
                }
                else
                {
                    x -= l[i];
                }
            }
            x /= 2;

            var ans = new long[n];
            ans[0] = x * 2;
            for (int i = 1; i < n; i++)
            {
                ans[i] = 2 * l[i - 1] - ans[i - 1];
            }
            var sb = new StringBuilder();
            for (int i = 0; i < n; i++)
            {
                sb.Append(ans[i]);
                sb.Append(" ");
            }
            WriteRead(sb);
        }
        
        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int nums[3];
    rep(0, 3) cin >> nums[i];

    sort(nums, nums + 3);

    cout << (nums[0] == nums[1] ? nums[2] : nums[0]) << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
class program{
  static void Main(){
    string[] s = Console.ReadLine().Split(' ');
    int a=int.Parse(s[0]);
    int b=int.Parse(s[1]);
    int c=int.Parse(s[2]);
    int d=c-(a-b);
    if(d<0){d=0;}
    Console.WriteLine(d);
  }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(void){
    int n, x;
    int a[100+5];
    scanf("%d %d", &n, &x);
    for(int i=0; i<n; i++)scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), compare_int);
    
    int ans=0;
    for(int i=0; i<n; i++){
        if(a[i]<=x){
            x-=a[i];
            ans++;
        }else{
            break;
        }
    }
    
    if(ans==n && x!=0)printf("%d\n", ans-1);
    else printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1728
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;

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

    string s;
    cin >> s;
    int l = 0, r = 0, n = s.size();
    int i = 0;
    while (s[i] == 'B')
        ++l, ++i, ++r;
    while(i < n)
    {
        if ((s[i] == '0' || s[i] == '1'))
            s[l] = s[i], ++l;
        else if (s[i] == 'B')
            if(l != 0)
                --l;
        ++i;
    }
    for (int i = r; i < l; ++i)
        cout << s[i];
}



Measured memory_bytes: 3616
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    if(a * b % 2 == 0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 22612
from collections import Counter
from collections import deque
import math
import bisect
import sys
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

mod=1000000007
n,m=sorted(mp())
if m-n>1:
    ans=0
elif m-n==1:
    ans=m
    for i in range(1,n+1):
        ans*=i**2
        ans%=mod
else:
    ans=2
    for i in range(1,n+1):
        ans*=(i**2)
        ans%=mod
print(ans%mod)


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;i++)
#define rep2(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][13];

void Main() {
    int n;
    cin >> n;
    vector<double> a(n);
    double ans =0;
    for (int i = 0; i < n ; ++i) {
        cin >> a[i];
        ans += 1/a[i];
    }
    cout << 1/ans << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 384
#include<stdio.h>

#define LEN 100010
#define STABLE 1
#define NOTSTABLE 0
 
typedef struct{
  char c;
  int n;
}Card;
 
void quicksort(Card *A, int p, int r){
  int q;
  if(p<r){
    q = partion(A, p, r);
    quicksort(A, p, q-1);
    quicksort(A, q+1, r);
  }
}
 
int partion(Card *A, int p, int r){
  int x=A[r].n;
  int i=p-1;
  int j, n;
  Card k;
   
  for(j=p; j<=r-1; j++){
    if(A[j].n<=x){
      i++;
      k=A[i];
      A[i]=A[j];
      A[j]=k;
    }
  }
   
  k=A[i+1];
  A[i+1]=A[r];
  A[r]=k;
  return i+1;
}
 
 
void merge(Card *S, int left, int mid, int right){
  int i, j, k;
  int n1=mid-left;
  int n2=right-mid;
  Card L[LEN], R[LEN];
   
  for(i=0; i<n1; i++)L[i]=S[left+i];
  for(i=0; i<n2; i++)R[i]=S[mid+i];
 
  L[n1].n=1000000001;
  R[n2].n=1000000001;
  i=0;
  j=0;
  for(k=left; k<right; k++){
    if(L[i].n<=R[j].n){
      S[k]=L[i];
      i++;
    }
    else{
    S[k]=R[j];
    j++;
    }
  }
}
 
void merge_sort(Card *S, int left, int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    merge_sort(S, left, mid);
    merge_sort(S, mid, right);
    merge(S, left, mid, right);
  }
}
 
int main(){
  int n;
  Card A[LEN], M[LEN], card;
  int p, r;
  int flag=STABLE;
  int i;
  char c;
   
  scanf("%d", &n);
  scanf("%c", &c);
  for(i=0; i<n; i++){
    scanf("%c %d", &A[i].c, &A[i].n);
    scanf("%c", &c);
    M[i]=A[i];
  }
   
  merge_sort(&M[0], 0, n);
  p=0;
  r=n-1;
  quicksort(&A[0], p, r);
   
  for(i=0; i<n-1; i++){
    if(A[i].c!=M[i].c){
      flag=NOTSTABLE;
      break;
    }
  }
   
  if(flag==STABLE)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0; i<n; i++)printf("%c %d\n", A[i].c, A[i].n);
   
  return 0;
}

Measured memory_bytes: 2956
import static java.lang.Math.sqrt;
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = kaijo(n);
        int[][] point = new int[n][2];
        double div[][] = new double[n][n];
        for(int i = 0;i < n;i++){
            point[i][0] = sc.nextInt();
            point[i][1] = sc.nextInt();
        }
        double ans = 0;
        for(int i = 0;i<n;i++){
            for(int j = 0; j < n;j++){
                ans +=divs(point[i][0],point[j][0],point[i][1],point[j][1]);
            }
        }
        
        System.out.print((ans/m)*m/n);
    }
    
    static int kaijo(int n){
        if(n == 1)return 1;
        int k = n * kaijo(n-1);
        return k;
    }
    
    static double divs(int i1 ,int i2,int j1,int j2){
        return sqrt((i1-i2)*(i1-i2)+(j1-j2)*(j1-j2));
    }
    
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    string S;
    cin >> S;
    int K;
    cin >> K;
    int n = S.length();
    for ( char c = 'a'; c <= 'z'; c++ ) {
        vector<string> s;
        
        for ( int i = 0; i < n; i++ ) {
            if ( S[i] == c ) {
                for ( int j = 1; j <= 5; j++ ) {
                    s.push_back( S.substr( i, j ) ); 
                }
            }
        }
        sort( s.begin(), s.end() );
        for ( int i = 0; i < s.size(); i++ ) {
            if ( i && s[i] == s[i-1] ) { continue; }
            K--;
            if ( K == 0 ) { cout << s[i] << endl; return 0; }            
        }
    }
    return 0;
}

Measured memory_bytes: 1660
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o C.exe C.cpp 
Execute: ./C
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

/* 
Notes: 
	result = 10^n - 2 * 9^n + 8^n
	a = 10^n
	b = 9^n
	c = 8^n
	result = a - 2*b + c
*/ 

int main() { 
	long long mod = 1000000007; 
	int n; 
	long long a=1ull, b=1ull, c=1ull, result=0ull;
	
	cin >> n; 
	for(int i = 0; i < n; i++) {
		a *= 10; a %= mod; 
		b *=  9; b %= mod; 
		c *=  8; c %= mod; 
	}
	
	result += a; result %= mod; 
	result += 2*mod - 2*b; result %= mod; 
	result += c; result %= mod; 
	
	cout << result << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3564
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 5000
using namespace std;
typedef pair<int,int> ii;

// flow --- start
struct edge
{
  int to,cap,rev;
  edge(int to=inf,int cap=inf,int rev=inf):to(to),cap(cap),rev(rev){}
};

int V;
vector<edge> G[MAX];
int level[MAX];
int iter[MAX];

void add_edge(int from,int to,int cap)
{
  G[from].push_back(edge(to,cap,G[to].size()));
  G[to].push_back(edge(from,0,G[from].size()-1));
}

void bfs(int s)
{
  rep(i,MAX)level[i] = -1;
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(!que.empty())
    {
      int v = que.front(); que.pop();
      rep(i,G[v].size())
	{
	  edge &e = G[v][i];
	  if(e.cap > 0 && level[e.to] < 0)
	    {
	      level[e.to] = level[v] + 1;
	      que.push(e.to);
	    }
	}
    }
} 

int dfs(int v,int t,int f)
{
  if(v == t)return f;
  for(int &i = iter[v]; i < G[v].size() ; i++)
    {
      edge &e = G[v][i];
      if(e.cap > 0 && level[v] < level[e.to])
	{
	  int d = dfs(e.to,t,min(f,e.cap));
	  if(d > 0)
	    {
	      e.cap -= d;
	      G[e.to][e.rev].cap += d;
	      return d;
	    }
	}
    }
  return 0;
}

int max_flow(int s,int t)
{
  int flow = 0;
  for(;;)
    {
      bfs(s);
      if(level[t] < 0)return flow;
      rep(i,MAX)iter[i] = 0;
      int f;
      while((f = dfs(s,t,inf)) > 0)
	flow += f;
    }
}

// flow --- end


int N,M,L;
int mincost[MAX][MAX];
vector<ii> ps;

int main()
{
  while(cin >> N >> M >> L,N|M|L)
    {
      rep(i,MAX)G[i].clear();
      rep(i,N)rep(j,N)mincost[j][i] = inf;
      rep(i,N)        mincost[i][i] = 0;

      	int u,v,d;
	rep(i,M)
	  {
	    cin >> u >> v >> d;
	    mincost[u][v] = mincost[v][u] = d;
	  }
	rep(i,N)rep(j,N)rep(k,N)mincost[j][k] = min(mincost[j][k],mincost[j][i]+mincost[i][k]);

	ps.clear();
	ps.resize(L);
	rep(i,L)cin >> ps[i].first >> ps[i].second;
	V = L;

	int st = 2*V,ed = 2*V+1;
	rep(i,V)        add_edge(st,i,1);
	rep(i,V)rep(j,V)if(i != j && ps[i].second+mincost[ps[i].first][ps[j].first] <= ps[j].second)add_edge(i,V+j,1);
	rep(i,V)        add_edge(V+i,ed,1);

	cout << V-max_flow(st,ed) << endl;

      }

    
  return 0;
}

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

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

int mp[25][21];

int main(){
  while(true){
    int n;
    cin>>n;
    if(!n)break;
    REP(i,n+1)REP(j,n+1)mp[i][j]=0;
    REP(i,n)REP(j,n)cin>>mp[i][j];
    REP(i,n)REP(j,n)mp[i][n] += mp[i][j];
    REP(i,n)REP(j,n+1)mp[n][j] += mp[i][j];
    REP(i,n+1){
      REP(j,n+1)printf("%5d",mp[i][j]);
      printf("\n");
    }
  }
  return 0;
}

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

typedef long long s64;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 200000;
const int INF = 0x3f3f3f3f;
const int M = 1000000007;

inline int modpow(int a, const int &n)
{
	int res = 1;
	for (int i = n; i; i >>= 1)
	{
		if (i & 1)
			res = (s64)res * a % M;
		a = (s64)a * a % M;
	}
	return res;
}

int n, lx, ly;
int c[MaxN + 1], w[MaxN + 1];

int le[MaxN + 1];

int cnt[MaxN + 1];

int fact[MaxN + 1];
int rfact[MaxN + 1];

inline void init_fact(int n)
{
	fact[0] = 1;
	for (int i = 1; i <= n; ++i)
		fact[i] = (s64)fact[i - 1] * i % M;

	rfact[n] = modpow(fact[n], M - 2);
	for (int i = n; i; --i)
		rfact[i - 1] = (s64)rfact[i] * i % M;
}

int main()
{
	cin >> n >> lx >> ly;
	for (int i = 1; i <= n; ++i)
		c[i] = getint(), w[i] = getint();

	init_fact(n);

	for (int i = 1; i <= n; ++i)
		le[i] = INF;
	for (int i = 1; i <= n; ++i)
		le[c[i]] = min(le[c[i]], w[i]);

	int c1 = 0, c2 = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (!c1 || le[i] < le[c1])
			c2 = c1, c1 = i;
		else if (!c2 || le[i] < le[c2])
			c2 = i;
	}

	int all = 0;
	for (int i = 1; i <= n; ++i)
	{
		int delta = 0;
		if (c[i] == c1)
			delta = w[i] + le[c1] <= lx || (c2 && w[i] + le[c2] <= ly);
		else
			delta = w[i] + le[c1] <= ly || (w[i] + le[c[i]] <= lx && le[c1] + le[c[i]] <= ly);

		all += delta, cnt[c[i]] += delta;
	}

	int res = fact[all];
	for (int i = 1; i <= n; ++i)
		res = (s64)res * rfact[cnt[i]] % M;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  string o,e,s;  cin>>o>>e;
  for(int i=0; i<e.size(); i++){
    s+=o.substr(i,1)+e.substr(i,1);
  }
  int O=o.size(),E=e.size();
  if(O-E==0) cout<<s<<endl;
  else cout<<s+o.substr(O-1,1)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;


static const int INF = (int)1e9;
static const int N=(int)1e5;


int main()
{
	int n;
    long long ans=0;
    int A[N];
    int cnt0min=0;
    int temp;
    long long sum=0;
    int minA=INF;

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


    for(int i=0;i<n;i++){
        temp=abs(A[i]);
        if(A[i]<0)cnt0min++;
        minA=min(minA,temp);
        sum+=temp;
        
    }

    if(cnt0min%2==0){ans=sum;}
    else{ans=sum-minA*2;}

    cout << ans << endl;


	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 200011;
const int bts = 28;

int n, i;
int A[maxN], B[maxN];

int act;
vector<int> aux;
int ans, here;

int get(int act, int l, int r) {
    auto it1 = lower_bound(aux.begin(), aux.end(), l - act);
    auto it2 = lower_bound(aux.begin(), aux.end(), r - act);
    return it2 - it1;
}

int main()
{
   // freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i <= n; i++) cin >> A[i];
    for (i = 1; i <= n; i++) cin >> B[i];

    for (int cnt = 0; cnt <= bts; cnt++) {
        aux.clear();
        for (i = 1; i <= n; i++)
            aux.pb(B[i] & ((1 << (cnt + 1)) - 1));
        sort(aux.begin(), aux.end());

        for (i = 1; i <= n; i++) {
            act = A[i] & ((1 << (cnt + 1)) - 1);
            here = get(act, 1 << cnt, 1 << (cnt + 1));
            here += get(act, (1 << cnt) + (1 << (cnt + 1)), 1 << (cnt + 2));
            ans ^= (here & 1) << cnt;
        }
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	vector<int> T(N);
	for (int i = 0; i < N; ++ i) cin >> S[i] >> T[i];
	string X;
	cin >> X;
	int r = 0;
	for (int i = 0; i < N; ++ i) {
		if (X == S[i]) X = "";
		else if (X == "") r += T[i];
	}
	cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;


ll power(ll a,ll b)
{
 ll res=1;
    while(b)
    {
     if(b&1)res=res*a;
        a=a*a;
        b/=2;
    }
    return res;
}

void solve()
{
 int n,i;
    cin>>n;
    vector<pair<int,int>>a(n);
    for(i=0;i<n;i++)
    {
     cin>>a[i].first>>a[i].second;   
    }
    int cnt=0;
    int ans=0;
    
    for(i=0;i<n;i++)
    {
     if(a[i].first==a[i].second)cnt++;
     else
     {
      if(cnt>=3)ans=1;
         cnt=0;
     }
    }
     if(cnt>=3)ans=1;
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
}


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

Measured memory_bytes: 3652
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

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

  vector<ll> lst(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> lst[i];
  }

  vector<ll> ord(N + 1);
  for (int i = 1; i <= N; i++) {
    ord[lst[i]] = i;
  }

  multiset<ll> st;
  st.insert(0);
  st.insert(0);
  st.insert(N+1);
  st.insert(N+1);
  ll ans = 0;
  for (ll i = N; i >= 1; i--) {
    st.insert(ord[i]);
    auto itr = st.find(ord[i]);
    itr--;
    ll l0 = (*itr);
    itr--;
    ll l1 = (*itr);
    itr++;
    itr++;
    itr++;
    ll r0 = (*itr);
    itr++;
    ll r1 = (*itr);
    ans += i * (l0 - l1) * (r0 - ord[i]);
    ans += i * (r1 - r0) * (ord[i] - l0);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6528
// ABC146B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>
#include<string>
using namespace std;
int main()
{
	int N;
	cin >> N;
	string S;
	cin >>S;
	int m;
	for (int i = 0; i < S.length(); i++)
	{
		m=(int)S.at(i) + N;
		if (m>90)
		{
			m = m - 26;
		}
		printf("%c", m);
	}
	cout << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))
a=[0]*n
a[0]=1
nxt=A[0]-1
i=2
while 1:
  a[nxt]=i
  nxt=A[nxt]-1
  i+=1
  if a[nxt]!=0:
    g=i-a[nxt]
    t=a[nxt]-1
    break
if t>=k:
  print(a.index(k+1)+1)
else:
  k-=t
  u=k%g
  print(a.index(t+u+1)+1)

Measured memory_bytes: 32380
#include<iostream>
using namespace std;
     
int main()
{
        int n,k,d,l,ans;
        cin >> n >> k;
        int a[n+1]={0};
       	ans = k;
       	while(ans--)
       	{
       		cin >> d;
       		while(d--){
       			cin >> l;
       			//printf("%d\n",a[l]);
       			a[l]=a[l] + 1;
       			//printf("%d\n",a[l]); 
       		}

       	}
       	int count=0;
       	for(int i=1;i<=n;i++){
       		if(a[i]==0)
       			count=count+1;
       	}
       	printf("%d\n",count);
    	return 0;
}


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

int main()
{
    int N;
    cin>>N;
    long long A, B;
    cin>>A>>B;

    vector<int> p(N);
    for (int &t: p)
    {
        cin>>t;
        t--;
    }

    vector<int> R(N);
    for (int i=0; i<N; i++)
        R[p[i]] = i;

    vector<long long> T(2*N+1);
    for (int i=0; i<N; i++)
    {
        vector<long long> P = T;
        T = vector<long long>(2*N+1);
        for (int j=1; j<2*N+1; j++)
            P[j] = min(P[j], P[j-1]);
        for (int j=0; j<2*N+1; j++)
        {
            long long c;
            if (j<R[i]*2+1)
                c = B;
            else if (j>R[i]*2+1)
                c = A;
            else
                c = 0;
            T[j] = P[j/2*2]+c;
        }
    }

    cout<<*min_element(T.begin(), T.end())<<endl;
}


Measured memory_bytes: 640
package main

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

func main() {
	var n, k, q int
	fmt.Scan(&n, &k, &q)

	sc := bufio.NewScanner(os.Stdin)
	ans := make([]int, n)
	for i := 0; i < q; i++ {
		sc.Scan()
		a, _ := strconv.Atoi(sc.Text())
		ans[a-1]++
	}

	wr := bufio.NewWriter(os.Stdout)
	for _, v := range ans {
		if k-(q-v) > 0 {
			wr.WriteString("Yes\n")
			continue
		}
		wr.WriteString("No\n")
	}
	wr.Flush()
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll n, i, s = 0, j, k;
	cin >> n;
	ll a[n];
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < i; j++)
		{
			for (k = 0; k < j; k++)
			{
				if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k] && (a[k] + a[j]) > a[i])
				{
					s++;
				}

			}
		}
	}
	cout<<s<<endl;
	return;



}





int main()
{
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;

	while (t--)
	{
		solve();
	}


	return 0;
}


Measured memory_bytes: 3644
{
  const main = (input: string): void | string | number => {
    const r = _reader(input)
    const A = r.n()
    const B = r.n()

    return 6 - A - B
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
}


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

using namespace std;

int main() {
	int n;
	while (cin >> n, n) {
		int d[6] = { 1, 2, 3, 4, 5, 6 };
		string s;
		int sum = 1;
		for (int i = 0; i < n; i++) {
			cin >> s;
			int t;
			if (s == "North") {
				t=d[0], d[0]=d[1], d[1]=d[5], d[5]=d[4], d[4]=t;
			} else if (s == "South") {
				t=d[0], d[0]=d[4], d[4]=d[5], d[5]=d[1], d[1]=t;
			} else if (s == "East") {
				t=d[0], d[0]=d[3], d[3]=d[5], d[5]=d[2], d[2]=t;
			} else if (s == "West") {
				t=d[0], d[0]=d[2], d[2]=d[5], d[5]=d[3], d[3]=t;
			} else if (s == "Right") {
				t=d[1], d[1]=d[2], d[2]=d[4], d[4]=d[3], d[3]=t;
			} else if (s == "Left") {
				t=d[1], d[1]=d[3], d[3]=d[4], d[4]=d[2], d[2]=t;
			}
			sum += d[0];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <complex>

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

using namespace std;

typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-9, pi = acos(ld(-1.0));

#define EQ(a,b) (abs((a)-(b))<eps)

ld dot (P a, P b) { return real(conj(a) * b); }
ld cross (P a, P b) { return imag(conj(a) * b); }

namespace std {
  bool operator<(const P &lhs, const P &rhs) {
    return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag() : lhs.real() < rhs.real();
  }
}

// Line
class L{
public:
  P a, b;
  L (P aa, P bb) { a = aa; b = bb; }
  L (ld ax, ld ay, ld bx, ld by) { a = P(ax, ay); b = P(bx, by); }
};

// counter clockwise
int ccw (P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > eps) return 1;   // counter clockwise
  if (cross(b, c) < -eps) return -1; // clockwise
  if (dot(b, c) < 0) return 2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line
  return 0;                          // a--c--b on line
}

// 点pから直線lに下ろした垂線の足
P proj(L l, P p) {
  ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}

// 直線lと線分mが交点を持つか
bool isis_ss(L s, L t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
    ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

// 点pが線分s上に存在するか
bool isis_sp(L s, P p) {
  return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}

// 線分sと点pの距離
ld dist_sp(L s, P p) {
  P r = proj(s, p);
  if (isis_sp(s, r)) return abs(r - p);
  return min(abs(s.a - p), abs(s.b - p));
}

// 線分sと線分tの距離
ld dist_ss(L s, L t) {
  if (isis_ss(s, t)) return 0;
  return min(min(dist_sp(s, t.a), dist_sp(s, t.b)), min(dist_sp(t, s.a), dist_sp(t, s.b)));
}

struct Star {
  vector<L> lines;
};

ld d(Star s1, Star s2) {
  ld mind = 1000000000.0;
  REP(i,5)REP(j,5){
    mind = min(mind,dist_ss(s1.lines[i],s2.lines[j]));
  }
  return mind;
}

int main() {
  while(1){
    int n,m,l;
    cin>>n>>m>>l;
    --m;--l;
    vector<Star> s;
    if(!n)break;
    REP(i,n){
      ld x,y,a,r;
      cin>>x>>y>>a>>r;
      P p = polar<ld>(r, a/180.0*pi+pi/2.0);
      P c(x,y);
      Star st;
      REP(j,5){
        st.lines.emplace_back(p*polar<ld>(1.0,2.0*j*pi/2.5)+c,p*polar<ld>(1.0,2.0*(j+1)*pi/2.5)+c);
      }
      s.push_back(st);
    }
    vector<vector<ld>> dist(n,vector<ld>(n));
    REP(i,n)REP(j,n){
      if(i==j){
        dist[i][j]=0.0;
      }else{
        dist[i][j] = d(s[i],s[j]);
      }
    }
    REP(k,n)REP(i,n)REP(j,n)
      dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
    cout << setprecision(15) << fixed << dist[m][l] << endl;
  }
  return 0;
}

Measured memory_bytes: 1524
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    S=ST()
    ans = [0]*N #True -> W
    for mask in range(4):
        ans[0] = bool(mask&1)
        ans[1] = bool(mask&2)
        for i in range(2,N):
            if (S[i-1]=="o") ^ ans[i-1]:
                ans[i] = ans[i-2]
            else:
                ans[i] = ans[i-2] ^ True
        ok = True
        for i in range(N):
            if ((S[i] == "o") ^ ans[i]) ^ (ans[(i+1)%N] == ans[i-1]):
                ok = False
        if ok:
            print(*["W" if a else "S" for a in ans ],sep="")
            return 
    print(-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9408
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {
	ll n;
	cin>>n;
	if(n>=30)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define         rep(i,n)       for (int i = 0;i<(int)(n);i++)
#define         rep1(i,n)      for (int i = 1;i<=(int)(n);i++)
#define         sajo(str)      sort(str.begin(),str.end())
#define         pi             3.14159265359
#define         neli            printf("\n")
#define         gcd(a,b)       __gcd(a,b)
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pf             printf
#define         sf             scanf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
typedef long long int ll;

int main()
{

    FIO;
    int i,j,k,q,temp,n,x,f=0;
    int a[N];
    cin>>n;
    n--;

    rep1(i,n)
        cin>>a[i];

    int ans=a[1];
    for(i=2;i<=n;i++)
        ans=ans+min(a[i],a[i-1]);
    ans=ans+a[n];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
s = tuple(sorted(P))
if tuple(P) == s:
  print('YES')
  exit()
for i in range(N):
  for j in range(i+1, N):
    if tuple(P[:i] + [P[j]] + P[i+1:j] + [P[i]] + P[j+1:]) == s:
      print('YES')
      exit()
print('NO')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
const int BLACK = 0;
const int WHITE = 1;
typedef pair<int,int>P;
vector<P>node[100005];
int color[100005]={0};

void dfs(int from,int pos,int state);
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n-1;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    node[a].push_back(P(b,c));
    node[b].push_back(P(a,c));
  }
  
  dfs(0,0,BLACK);
  for(int i=0;i<n;i++){
    cout<<color[i]<<endl;
  }
  return(0);
}

void dfs(int from,int pos,int state){
  color[pos]=state;
  for(int i=0;i<node[pos].size();i++){
    int next=node[pos][i].first;
    int cost=node[pos][i].second;
    if(next!=from){
      if(cost%2==1){
	if(state==BLACK){
	  dfs(pos,next,WHITE);
	}else{
	  dfs(pos,next,BLACK);
	}
      }else{
	dfs(pos,next,state);
      }
    }
  }
  return;
}


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


int main(){
  string s, t;

  cin >> s >> t;

  string s2;
  for(int i=0; i<s.size(); ++i){
    s2 = s.substr(s.size()-i, i) + s.substr(0, s.size()-i);

    if(s2 == t){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	vector<set<int>> s(m);
	rep(i, m)
	{
		int k; cin >> k;
		rep(j, k)
		{
			int x; cin >> x;
			s[i].insert(x);
		}
	}
	vector<int> p(m); rep(i, m)cin >> p[i];
	int res = 0;
	rep(i, pow(2, n))
	{
		bool ok = true;
		rep(j, m)
		{
			int cnt = 0;
			rep(l, n)
			{
				if (i&(1 << l) && s[j].count(l + 1))++cnt;
			}
			if (cnt % 2 != p[j])
			{
				ok = false;
				break;
			}
		}
		if (ok)++res;
	}
	cout << res << endl;
}

Measured memory_bytes: 256