akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();

		int[] d=new int[N];

		for(int i=0;i<N;i++) d[i]=sc.nextInt();

		sc.close();

		Arrays.sort(d);

		System.out.println(d[N/2]-d[(N/2)-1]);
	}
}


Measured memory_bytes: 50368
#include <cstdio>

typedef long long ll;

const int MaxN = 3005;
const int cIz = 998244353;

inline int Pow(int a, int b) {
	int res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = (ll)res * a % cIz;
		a = (ll)a * a % cIz;
	}
	return res;
}
inline int Inv(int a) {
	return Pow(a, cIz - 2);
}

int f[MaxN][MaxN], g[MaxN][MaxN];

int main() {
	int w, h, W, H;
	scanf("%d%d%d%d", &w, &h, &W, &H);
	f[w][h] = 1;
	g[w][h] = 1;
	for (int i = w + 1; i <= W + 1; ++i) {
		for (int j = h; j <= H + 1; ++j) {
			f[i][j] = (ll)(i - 1) * (f[i][j - 1] + g[i - 1][j - 1]) % cIz;
			g[i][j] = ((ll)j * g[i - 1][j] + f[i][j]) % cIz;
		//	printf("%d, %d: %d %d\n", i, j, f[i][j], g[i][j]);
		}
	}
	int ans = (ll)f[W + 1][H + 1] * Inv(W) % cIz;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 73472
#include <stdio.h>

void getWeightOfAizuAndNormalChicken( int minWeight, int money, int aizuPrime, int normalPrime, int maxAizuWeight, int* weightOfAizu, int* weightOfNormal );

int main( void )
{
	char string[ 64 ];
	int min;					//最低限これ以上は買わなければならない
	int money;					//予算
	int AizuChickenPrice;		//会津地鶏の価格
	int NormalChickenPrice;		//普通の鶏肉の価格
	int max;					//買える会津地鶏の制限
	
	int weightOfAizu;
	int weightOfNormal;
	
	while( 1 )
	{
		fgets( string, 64, stdin );
		if( string[1] == '\n' )break;
		
		sscanf( string, "%d%d%d%d%d", &min, &money, &AizuChickenPrice, &NormalChickenPrice, &max );
		
		getWeightOfAizuAndNormalChicken( min, money, AizuChickenPrice, NormalChickenPrice, max, &weightOfAizu, &weightOfNormal );
		if( weightOfAizu == -1 && weightOfNormal == -1 )
		{
			printf( "NA\n" );
		}
		else
		{
			printf( "%d %d\n", weightOfAizu, weightOfNormal );
		}
	}
	
	return (0);
}

void getWeightOfAizuAndNormalChicken( int minWeight, int money, int aizuPrice, int normalPrice, int maxAizuWeight, int* weightOfAizu, int* weightOfNormal )
{
	int lackWeight;	//足りない重さ
	int addWeight;	//重さの合計
	int overWeight;	//多かった重さ
	int remainMoney;//現在のお金
	
	remainMoney = money;
	
	*weightOfAizu = remainMoney / aizuPrice; //とりあえず買えるだけ買ってみる
	remainMoney = money % aizuPrice;
	
	*weightOfNormal = remainMoney / normalPrice; //とりあえず買えるだけ買ってみる
	remainMoney = remainMoney % normalPrice;
	
	if( (*weightOfAizu) > maxAizuWeight ) //会津地鶏の重さが買える限界より多ければ実行
	{
		overWeight = (*weightOfAizu) - maxAizuWeight;
		
		*weightOfAizu = maxAizuWeight;
		remainMoney += (overWeight * aizuPrice);
		
		*weightOfNormal += remainMoney / normalPrice;
		remainMoney = remainMoney % normalPrice;
	}
	
	addWeight = (*weightOfAizu) + (*weightOfNormal);
	
	while( addWeight < minWeight )	//重さの下限より小さければ実行
	{
		(*weightOfAizu)--;
		if( *weightOfAizu <= 0 )
		{
			break;
		}
		remainMoney += aizuPrice;
		*weightOfNormal += remainMoney / normalPrice;
		remainMoney = remainMoney % normalPrice;
		
		addWeight =  (*weightOfAizu) + (*weightOfNormal);
	}
	
	if( *weightOfAizu <= 0 )
	{
		*weightOfAizu = -1;
		*weightOfNormal = -1;
		return;
	}
}

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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var arg = Console.ReadLine().Split(' ');
            var x = long.Parse(arg[0]);
            var y = long.Parse(arg[1]);

            int i = 0;
            while(x<=y)
            {
                i++;
                x *= 2;
            }
            Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<stdbool.h>

int main()
{
    int A,B,d1,d2,K,max;
    scanf("%d %d",&A,&B);
    _Bool hobe = 0;
    max = A<B?B:A;
    for(int i=0;i<=max;i++)
    {
        d1 = A-i;
        if(d1<0)
        {
            d1*=(-1);
        }
        d2 = B-i;
        if(d2<0)
        {
            d2*=(-1);
        }
        if(d1==d2)
        {
            K = i;
            hobe = 1;
            break;
        }
    }
    if(hobe==1)
    {
        printf("%d",K);
    }
    else
    {
        printf("IMPOSSIBLE");
    }

}


Measured memory_bytes: 128
#include <cstdio>
#include <bitset>
using namespace std;
const int SUMC = 4e6 + 5;
int N, A, sum;
bitset<SUMC> dp;
int main() {
	scanf("%d", &N);
	dp[0] = 1;
	for (int i = 1; i <= N; ++i) {
		scanf("%d", &A);
		dp |= dp << A;
		sum += A;
	}
	for (int i = (sum + 1) / 2; i <= sum; ++i)
		if (dp[i]) {
			printf("%d\n", i);
			break ;
		}
	return 0;
}

Measured memory_bytes: 4188
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define MOD 1e+7
#define inf 9.223372e+18
#define fi first
#define se second
using namespace std;

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

  int n;
  cin >> n;
  vector<int64_t> sum(n+1, 0);
  reps(i, 1, n+1) {
    int64_t a;
    cin >> a;
    sum[i] = sum[i-1] + a;
  }

  int64_t res = inf;
  reps(i, 1, n) {
    int64_t x = sum[i];
    int64_t y = sum[n] - x;
    res = min(res, abs(x-y));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e5 + 7;
const int MAX = 1e9 + 1;
//从北开始顺时针
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
//int exDx[] = {-1, -1, 0, 1, 1, 1, 0, -1}, exDy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main() {
    int i, j;
    int n;
    cin >> n;
    int cnt = 0;
    for (i = 0; i < n; ++i) {
        int t;
        cin >> t;
        if (t % 2 == 1)
            ++cnt;
    }
    cout << (cnt % 2 == 0 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

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

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  std::string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s[i]=='L'){
        cout<<"No"<<endl;
        return 0;
      }
    }else{
      if(s[i]=='R'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;





  return 0;
}


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

#define d 1000U

uint32_t f(uint32_t x)
{
    uint32_t q;
    q = x / d;

    uint32_t r;
    r = x % d;

    if (r == 0)
    {
        return x;
    }
    else
    {
        return (q + 1) * d;
    }
    
}

int main()
{
    uint32_t a;
    cin >> a;
    
    cout << f(a) - a << endl;
}

Measured memory_bytes: 3632
cardNum = int(input())
card = list(map(int, input().split()))
allSum = 0
for i in range(cardNum):
  allSum += card[i]
halfwaySum = 0
for i in range(cardNum - 1):
  halfwaySum += card[i]
  if i == 0:
    mindiff = abs(allSum - 2 * halfwaySum)
  elif mindiff > abs(allSum - 2 * halfwaySum):
    mindiff = abs(allSum - 2 * halfwaySum)
print(mindiff)


Measured memory_bytes: 24832
def resolve():
    N, Y = map(int, input().split())
 
    resx, resy, resz = (-1, -1, -1)
    for x in range(N+1):
        for y in range(N+1-x):
            z = N - x - y
            total = 10000*x + 5000*y + 1000*z
 
            if total == Y:
                resx, resy, resz = (x, y, z)
                break
    
    print(resx, resy, resz)
    
resolve()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 50;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
struct edge{
    int from, to; ll cost;
};

int main(){
    ll n, y;
    cin >> n >> y;
    if(y % 1000 || n * 10000 < y){
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    y /= 1000;
    for(int c = 0; c <= y; c++){
        if(c > n) break;
        for(int b = 0; b * 5 + c <= y; b++){
            if(b + c > n) break;
            for(int a = 0; a * 10 + b * 5 + c <= y; a++){
                if(a + b + c > n) break;
                if(a + b + c == n){
                    if(a * 10 + b * 5 + c == y){
                        cout << a << " " << b << " " << c << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 888
from itertools import accumulate

N = int(input())
A = [int(input()) for _ in range(N)]

if A[0] != 0:
    print(-1)
else:
    A.reverse()
    bef = A[0]
    c = 0
    ans = 0
    for i in A:
        if bef!=i:
            if bef-i > 1:
                print(-1)
                break
            ans += bef*c
            c = 1 if bef<i else 0
        else:
            c += 1
        bef = i
    else:
        print(ans)


Measured memory_bytes: 11172
N, M, X, Y = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

if max(xs) >= min(ys):
  war = "War"
elif max(xs) >= Y or min(ys) <= X:
  war = "War"
else:
  war = "No War"

print(war)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (a>0 && c>0) {
    a-=d;
    c-=b;
  }
  if(c>0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3612
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let prime_list = list_prime(55555);
    //println!("{:?}", prime_list);
    let mut list = Vec::new();
    for p in prime_list {
        if p % 5 == 1 {
            list.push(p);
        }
    }

    for i in 0..n {
        print!("{} ", list[i]);
    }
    println!("");
}


// n以下の素数を列挙する
// O(NloglogN)
fn list_prime(n: usize) -> Vec<usize> {
    let mut check = vec![true; n+1];
    let mut res = Vec::new();
    check[0] = false;
    check[1] = false;
    for i in 2..n+1 {
        if check[i] {
            res.push(i);
            for j in (2..n+1) {
                if i * j > n { break }
                check[j * i] = false;
            }
        }
    }

    res
}

Measured memory_bytes: 4352
l, r = map(int, input().split())

mod = 2019

if l//mod != r//mod:
    print(0)
    exit()

l = l%mod
r = r%mod

m = mod
for i in range(l, r+1):
    for j in range(i+1, r+1):
        t = (i*j)%mod
        if t < m:
            m = t

print(m)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        string s;
        cin >> s;
        if(s == "-") break;
        int m;
        cin >> m;
        while(m--) {
            int h;
            cin >> h;
            string sub1 = s.substr(0, h);
            string sub2 = s.substr(h, s.size() - h);
            s = sub2 + sub1;
        }
        cout << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  bool flag = false;
  for (int i = 0; i < a.size(); i++) {
    if (a == b) {
      flag = true;
      break;
    }
    a = a.back() + a.substr(0, a.size() - 1);
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));    // lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

int main(void)
{
    vector<pair<pair<string, int>, int> >v;
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        pair<string, int> p;
        cin >> p.first >> p.second;
        p.second *= -1;
        pair<pair<string, int>, int>pp;
        pp.first = p;
        pp.second = i+1;
        v.push_back(pp);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++){
        cout << v[i].second << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
d={}
m=0
for i in range(n):
  s=input()
  if s not in d:d[s]=1
  else:d[s]+=1
  m=max(m,d[s])
t=set()
for i in d:
  if d[i]==m:t.add(i)
x=[i for i in t]
x.sort()
for i in x:print(i)

Measured memory_bytes: 45588
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll dp[16][16],h,w,n,a,b,N;
void ini(void){
    ll ok=1;
    for(int i=0;i<h;i++){
        if(dp[i][0]==-1)ok=0;
        else dp[i][0]=ok;
    }
    ok=1;
    for(int j=0;j<w;j++){
        if(dp[0][j]==-1)ok=0;
        else dp[0][j]=ok;
    }
    return ;
}
int main(void){
    cin>>h>>w>>n;
    while(n>0){
        for(int i=0;i<n;i++){
            cin>>a>>b;
            a--,b--;
            dp[a][b]=-1;
        }
        ini();
        for(int i=1;i<h;i++){
            for(int j=1;j<w;j++){
                if(dp[i][j]==-1)continue;
                dp[i][j]=max(0LL,dp[i][j-1])+max(0LL,dp[i-1][j]);
            }
        }
        cout<<dp[h-1][w-1]<<endl;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                dp[i][j]=0;
            }
        }
        cin>>h>>w;
        if(h==0)break;
        cin>>n;
        //cout<<n<<endl;
    }
    //return 0;
    
}



Measured memory_bytes: 3084
import itertools
from math import *
n=int(input())
ps=[list(map(int,input().split())) for _ in range(n)]
perms = list(itertools.permutations(ps, n))
dists = []
for i in range(len(perms)):
  dist = 0
  cur = perms[i][0]
  for j in range(1,len(perms[i])):
    d = sqrt((perms[i][j][0]-cur[0]) ** 2 + (perms[i][j][1]-cur[1])**2)
    cur = perms[i][j]
    dist += d

  dists.append(dist)
print(sum(dists)/len(perms))

Measured memory_bytes: 9992
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
char w[100][11];
int main() {
	int n;
	bool isOK = true;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", w[i]);
	}
	for (int i = 1; i < n; i++) {
		if (w[i][0] != w[i - 1][strlen(w[i - 1]) - 1]) {
			isOK = false;
			break;
		}
		for (int j = 0; j < i; j++) {
			if (strcmp(w[i], w[j]) == 0) {
				isOK = false;
				break;
			}
		}
	}
	if (isOK) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;


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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

void solve(){
	ll t[2],a[2],b[2];
	rep(i,2)cin>>t[i];
	rep(i,2)cin>>a[i];
	rep(i,2)cin>>b[i];
	if(a[0]*t[0]+a[1]*t[1]==b[0]*t[0]+b[1]*t[1])cout<<"infinity\n";
	else if(a[0]*t[0]>b[0]*t[0]&&a[0]*t[0]+a[1]*t[1]>b[0]*t[0]+b[1]*t[1])cout<<0<<"\n";
	else if(a[0]*t[0]<b[0]*t[0]&&a[0]*t[0]+a[1]*t[1]<b[0]*t[0]+b[1]*t[1])cout<<0<<"\n";
	else{
		ll x=abs(a[0]-b[0])*t[0];
		ll y=abs(a[0]*t[0]+a[1]*t[1]-b[0]*t[0]-b[1]*t[1]);
		ll ans=x/y*2;
		if(x%y)ans++;
		cout<<ans<<"\n";
	}
}

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


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef struct point {
  int x;
  int y;
} City;

double distOfTwo(City *c1, City *c2)
{
  //cout << "c1(x,y)=" << c1.x << "," << c1.y << "    " << "c2(x,y)=" << c2.x << "," << c2.y << endl;
  //cout << sqrt(pow(c1.x - c2.x, 2) + pow(c1.y - c2.y, 2)) << endl;
  return sqrt(pow(c1->x - c2->x, 2) + pow(c1->y - c2->y, 2));
}

int fact(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
        sum *= i;
    return sum;
}

double printVector(const vector<int>& vec, City city[]) {
    double sum = 0;
    for (int i = 0; i < vec.size()-1; i++) {
        sum += distOfTwo(&city[vec[i]], &city[vec[i+1]]);
        //cout << "comb=" << vec[i] << "," << vec[i+1];
        //cout << ",  sum=" << sum << endl;
    }
        //cout << sum << endl;
    return sum;
}

int main() {
	int N;
  	City city[10];
  
  	cin >> N;
  	for (int i=0; i<N; i++) {
    	cin >> city[i].x >> city[i].y;
    }

    vector<int> nums(N);
    iota(nums.begin(), nums.end(), 0);

    double sum = 0;
    do {
        sum += printVector(nums, city);
    } while (next_permutation(nums.begin(), nums.end()));
  
    cout << std::fixed << std::setprecision(10) << sum / fact(N) << endl;
}




Measured memory_bytes: 256
def main():
    n = int(input())
    task = []
    for _ in range(n):
        task.append(list(map(int, input().split())))
    time = 0
    task.sort(key=lambda x: x[1])
    answer = True
    for i in range(n):
        required_time, deadline = task[i]
        if deadline < time + required_time:
            answer = False
        else:
            time += required_time
    print("Yes" if answer else "No")


if __name__ == '__main__':
    main()



Measured memory_bytes: 53664
#include<iostream>
#include<vector>
using namespace std;
int n,a[100001],b[100001],ma;
int main(){
  ma=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
    if(a[i]>a[ma]){
      ma=i;
    }
  }
  cout<<a[ma]+b[ma]<<endl;
  return 0;
}


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll v[N];

int main()
{
    ll n,m=INT_MAX,i,k=0;
    cin>>n;
    for0(i,n)
    {
        cin>>v[i];
    }
    for0(i,n)
    {
        if(v[i]<=m)
            m=v[i];

        if(v[i]<=m)
            k++;
    }
    cout<<k<<endl;
    //main();
    return 0;
}
































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

int K,S;
cin >>K >>S;

int ans = 0;
int c = 0;

for (int a = 0; a <= K; a++){
     for (int b = 0; b <= K; b++){
          c = S - (a + b);
          if(c <= K && c >= 0){
               ans ++;
          }
     }
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>

using namespace std;
 
int main() {
	double  a,b,c,d,e,f,x,y;
	while(cin >> a>>b>>c>>d>>e>>f){
		x = (c*e-f*b)/(a*e-d*b);
		y = (a*f-d*c)/(a*e-d*b);
		if(x==0) x=0;
		if(y==0) y=0;
		printf("%.3f %.3f\n",x,y);
	}
}


Measured memory_bytes: 3108
/**********************************************************************
File    .cpp
Author  Takahiro Yamazaki
**********************************************************************/
/**********************************************************************
Include Libraries
**********************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
/**********************************************************************
Declare variables
**********************************************************************/
/**********************************************************************
Declare instance
**********************************************************************/
/**********************************************************************
Proto_type_Declare functions
**********************************************************************/
/**********************************************************************
Main
**********************************************************************/
int main() {
  int n;
  cin >> n;
  int a[220000];
  a[0] = 0;
  repr(i, 1, n) cin >> a[i];
  int ans[220000];

  rep(i,n) ans[i] = 0;
  int counter = 0;
  // int tmp;
  // /* 数値を昇順にソート */
  // for (int i=0; i<n; ++i) {
  //   for (int j=i+1; j<n; ++j) {
  //     if (a[i] > a[j]) {
  //       tmp =  a[i];
  //       a[i] = a[j];
  //       a[j] = tmp;
  //     }
  //   }
  // }
  sort(a, a+n);
  rep(i,n){
    repr(j, 1 + counter, n){
      if (a[j] == i+1) {
        ans[i]++;
        counter++;
      }
      else if(a[j] != i+1) break;
    }
  }
  // int j = 0;
  // repr(i, 1, n){
  //   if (a[i] == j) {
  //     ans[i]++;
  //   }
  // }
  // printf("%d\n", n);
  // rep(i,n) a[i] = 0;
  rep(i,n) printf("%d\n", ans[i]);
}
/**********************************************************************
Functions
**********************************************************************/


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, x; cin >> n >> x;
  if(x == 1 || x == n + n - 1) return (cout << "No" << endl, 0);
  cout << "Yes" << endl;
  vector<int> ans(n + n);
  vector<int> used(n + n);
  ans[n] = x; used[x] = 1;
  ans[n-1] = x-1; used[x-1] = 1;
  ans[n+1] = x+1; used[x+1] = 1;
  if(n > 2) {
    if(x == 2) {
      ans[n - 2] = x + 2; used[x + 2] = 1;
    } else {
      ans[n + 2] = x - 2; used[x - 2] = 1;
    }
  }
  int c = 1;
  for(int i = 1; i <= n + n - 1; i++) {
    if(ans[i] != 0) continue;
    while(used[c]) c++;
    ans[i] = c;
    c++;
  }
  for(int i = 1; i <= n + n - 1; i++) cout << ans[i] << endl;
}


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

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

  string T = "ATCG";
  int ans = 0;
  int now = 0;
  for(int i = 0; i < S.size(); i++){
    bool isATCG = false;
    for(int j = 0; j < T.size(); j++){
      if(S[i] == T[j]){
        isATCG = true;
      }
    }
    if(isATCG){
      now++;
      ans = max(now,ans);
    }
    else{
      now = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <string.h>


int main() {
	int i, j, k;
	int	n, m, h, g, c, d, l, r;
	int f = 0;
	int w = 0;
	char s[11000000];

	scanf("%s", s);

	n =  strlen(s);

	f = n;

	if (s[n] == s[n - 1]) {
		if (s[n - 1] == s[n - 2]) {
			if (s[n - 2] == s[n - 3]) {
				if (s[n - 3] == s[n - 4]) {
					if (s[n - 4] == s[n]) {
						f = f - 2;
						n = n - 5;
					}
				}
			}
		}
	}



	for (i = 0;i < n-1;i++) {
		if (s[i] == s[i+1]) {
			f = f - 1;
			i = i + 2;
		}
	}





	printf("%d", f);

	return 0;
}

Measured memory_bytes: 384
import sys
N = int(input())
a = []
for i in range(N):
  line = sys.stdin.readline().split()
  if int(line[0]) == 0:
    a.append(int(line[1]))
  elif int(line[0]) == 1:
    print(a[int(line[1])])
  elif  int(line[0]) == 2:
    a.pop()


Measured memory_bytes: 13364
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int SIZEN = 500;
LL f[SIZEN][SIZEN];
int N,K;
LL H[SIZEN];
int main(){
    scanf("%d%d",&N,&K);
    for(int i = 1;i <= N;i++)scanf("%d",&H[i]);
    memset(f,0x3f,sizeof f);
    f[0][0] = 0;
    for(int i = 1;i <= N;i++){
        for(int j = 1;j <= min(N-K,i);j++){
            for(int k = 0;k < i;k++)f[i][j] = min(f[i][j],f[k][j-1] + max(0LL,H[i] - H[k]));
        }
    }
    // for(int i = 1;i <= N;i++){
    //     for(int j = 0;j <= N-K;j++)printf("f[%d][%d] = %lld\n",i,j,f[i][j]);
    // }
    LL ans = 0x3f3f3f3f3f3f3f3fLL;
    for(int i = N-K;i <= N;i++)ans = min(ans,f[i][N-K]);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3692
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			StringBuffer s = new StringBuffer(sc.next());
			
			int count;
			int t = 0;
			StringBuffer u = new StringBuffer();
			for(int k=0;k<n;k++){
				for(int i=0;i<s.length();i++){
					count=1;
					t = s.charAt(i);
					while(i<s.length()-1 && s.charAt(i+1)==t){
						i++;
						count++;
					}
					u.append(count);
					u.append((char)t);
				}
				s = new StringBuffer(u);
				u.delete(0, u.length());
			}
			System.out.println(s);			
			
		}
	}
}

Measured memory_bytes: 22880
#include<bits/stdc++.h>
#define mkp make_pair
#define all(a) a.begin(),a.end() 
using namespace std;
typedef long long ll;
typedef map<ll,ll>::iterator itll;
typedef pair<ll,ll> P; 
int main()
{
	int ma = 0;
	int n;
	string s;
	cin>>n>>s;
	vector<int> vi;
	for(int i=0;i<s.size();i++)
	{
		if(s[i] == 'I')
			ma++;
		else
		ma--;
		vi.push_back(ma);
	}
	sort(all(vi));
	cout<<max(0,vi[n-1])<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
L n;
string st;
set<string>S;
void ouch(string p1,string p2){

    string p=p1+p2,t1,t2;
    S.insert(p);
    t2=p2;
    reverse(t2.begin(),t2.end());
    p=p1+t2;
    S.insert(p);

    t1=p1;
    reverse(t1.begin(),t1.end());
    p=t1+p2;
    S.insert(p);

    t1=p1;t2=p2;
    reverse(t1.begin(),t1.end());reverse(t2.begin(),t2.end());
    p=t1+t2;
    S.insert(p);

    swap(p1,p2);

    p=p1+p2;
    S.insert(p);
    t2=p2;
    reverse(t2.begin(),t2.end());
    p=p1+t2;
    S.insert(p);

    t1=p1;
    reverse(t1.begin(),t1.end());
    p=t1+p2;
    S.insert(p);

    t1=p1;t2=p2;
    reverse(t1.begin(),t1.end());reverse(t2.begin(),t2.end());
    p=t1+t2;
    S.insert(p);

}
void solve(){
    L l=st.size(),r=1;
    string p1,p2;
    for(L i=0;i<l-1;i++){
        p1=st.substr (0,r);
        p2=st.substr(r,l-r);
        r++;
        ouch(p1,p2);
    }
}
int main(){
    scanf("%lld",&n);
    while(n--){
        cin>>st;
        solve();
        cout<<S.size()<<"\n";
        S.clear();
    }
    return 0;
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0;
	for(int i = 1; i < n - 1; i++){
		set<char> x;
		for(int j = 0; j < i; j++){
			x.insert(s[j]);
		}
		set<char> y;
		for(int j = i; j < n; j++){
			if(x.count(s[j])){
				y.insert(s[j]);
			}
		}
		int cnt = y.size();
		if(ans < cnt) ans = cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
*    created: 12.07.2020 02:45:14
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, k; cin >> n >> k;
    if (n == 1) {cout << k << endl; return 0;}
    else {
        int ans = k;
        rep(i,n-1) ans *= k-1;
        cout << ans << endl;
        return 0;
    }
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_M (100000)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  int N, M, ls[MAX_M], rs[MAX_M];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d %d", &ls[i], &rs[i]);
  }

  // solve
  int l = 1, r = N;
  for (int i = 0; i < M; i++) {
    const int li = ls[i], ri = rs[i];
    l = max(l, li);
    r = min(r, ri);
  }
  printf("%d\n", max(r - l + 1, 0));
  
  return 0;
}


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

int main() {
  double N;
  cin >> N;
  double Z;
  Z = 0;
  double H;
  int A;
  A = 0;
  int K;
  cin >> K;
  for (int i = 0; i < N; i++) {
    H = 1;
    A = A + 1;
    for (int j = 0; H * A < K; j++) {
      H = H * 2;
    }
    H = 1 / H;
    Z = Z + H;
  }
  Z = Z / N;
  printf("%.12f\n", Z);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
    int N;
    int D[101][2];
    cin >> N;
    for (int i=0; i<N; i++) cin >> D[i][0] >> D[i][1];

    for (int i=0; i<N-2; i++) {
        if (D[i][0] == D[i][1] && D[i+1][0] == D[i+1][1] && D[i+2][0] == D[i+2][1])
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    char n[5];
    int s=0,i;
    scanf("%s",n);
    for(i=0;i<4;i++)
    {
        if(n[i]=='+') s++;
        else if(n[i]=='-') s--;
    }
    printf("%d\n",s);
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;
#define N 100

int main(){
    int graph[N][N];
    int n;
    int c,l; 
    int arc; 
    cin >> n;

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            graph[i][j] = 0;
    
   for(int i=0;i<n;i++){
        cin >> c;
        cin >> arc;
        for(int j=0;j<arc;j++){
            cin>> l;
            graph[c-1][l-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j) cout<<" ";
            cout<< graph[i][j];
		}
    	cout<<endl;	
    }
    return 0;       
}


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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanLLInt(A);
    scanLLInt(B);
    scanLLInt(N);
    cout << floor(A * min(B - 1, N) / B) << endl;
}


Measured memory_bytes: 3848
n, m = gets.split.map(&:to_i)
candies = gets.split.map(&:to_i)
tmp = 0
cumulative_mods = []
hash = Hash.new{ |hash, key| hash[key] = [] }
candies.each_with_index do |c, i|
  mod = (tmp + c) % m
  cumulative_mods << mod
  hash[mod] << i
  tmp = mod
end
sum = 0
(0...n).each do |i|
  tmp_mod = cumulative_mods[i]
  deduction = i == 0 ? 0 : cumulative_mods[i - 1]
  tmp_mod -= deduction
  sum += 1 if tmp_mod == 0
  target = deduction
  target_array = hash[target]
  usable_index = target_array.bsearch_index { |e| e > i } || target_array.size
  usable = target_array.size - usable_index
  sum += usable
end
puts sum


Measured memory_bytes: 15620
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
const ll INF = 1ll << 60;
const int IINF = 1 << 30;
int n, m;
map<int, int> dist;
map<int, vector<pair<int, int>>> g;
map<int, bool> visited;

void update(int cur)
{
    if (visited[cur])
        return;
    visited[cur] = true;
    assert(dist[cur] != IINF);
    for (auto x : g[cur])
    {
        int to = x.first;
        int cost = x.second;
        int newdist = dist[cur] + cost;
        if (dist[to] != IINF && dist[to] != newdist)
        {
            cerr << cur << " " << to << endl;
            cout << "No" << endl;
            exit(0);
        }
        dist[to] = newdist;
        update(to);
    }
}

int main()
{
    cin >> n >> m;
    rep(i, n)
    {
        dist[i + 1] = IINF;
    }
    rep(i, m)
    {
        int a, b, c;
        cin >> a >> b >> c;
        g[a].push_back({b, c});
        g[b].push_back({a, -c});
    }
    rep(i, 1, n + 1)
    {
        if (dist[i] == IINF)
        {
            visited.clear();
            dist[i] = 0;
            update(i);
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int partition(int a[],int p,int r){
	int x=a[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(a[j]<=x){
			i++;
			swap(a[i],a[j]);
		}
	}
	i++;
	swap(a[i],a[r]);
	return i;
}

int main(){
	int n,a[100000];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int m=partition(a,0,n-1);
	for(int i=0;i<n;i++){
		if(i==m)
			cout<<'['<<a[i]<<']';
		else
			cout<<a[i];
		cout<<((i!=n-1)?' ':'\n');
	}
	return 0;
}

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


int main() {
    string s;
    cin>>s;
    rep(i,s.size()){
        if(i%2==1){
            if(s[i]=='R'){
                cout << "No" <<endl;
                return 0;
            }
        }else{
            if(s[i]=='L'){
                cout << "No" <<endl;
                return 0;
            }
        }
    }
    cout << "Yes" <<endl;
}


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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            l = gcd(i,j)
            res += gcd(k, l)
print(res)

Measured memory_bytes: 74032
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

#define MOD 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll dp[5050][5050];
ll wari[5050];

class Mod
{
//    static const int MOD = 1000000007;
    long long a;
public:
    Mod(){
        a = 0;
    }
    Mod(long long x){
        a = (x % MOD + MOD) % MOD;
    }
    const Mod operator+(const Mod& x) const{
        return Mod(a + x.a);
    }
    const Mod operator-(const Mod& x) const{
        return Mod(a - x.a);
    }
    const Mod operator*(const Mod& x) const{
        return Mod(a * x.a);
    }
    const Mod operator/(const Mod& x) const{ //フェルマーの小定理、aとMODが互いに素の時のみ
        if(x.a == 0)return 0;
		if(a % x.a == 0)return Mod(a/x.a);
		int b = MOD - 2;
        long long c = x.a;
        long long ret = 1;
        while(b > 0){
            if(b & 1){
                ret *= c;
                ret %= MOD;
            }
            c *= c;
            c %= MOD;
            b >>= 1;
        }
        return Mod(a * ret);
    }
    long long getValue(){
        return a;
    }
};


int main()
{
	int n;cin >> n;
	string str;cin >> str;
	wari[0] = 1;
	for(int i = 1;i < 5010;i++)wari[i] = (wari[i-1]*2)%MOD;
	
	dp[0][0] = 1;
	
	REP(i,n)
	{
		REP(j,5010)
		{
			if(j == 0)
			{
				if(j == 0)dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
			}
			else
			{
				dp[i+1][j-1] = (dp[i+1][j-1] + dp[i][j]) % MOD;
			}
			dp[i+1][j+1] = (dp[i+1][j+1] + 2*dp[i][j]) % MOD;
		}
	}
	
	//SHOW2d(dp,n+1,n+1);
	Mod ans(dp[n][str.size()]);
	ans = ans / wari[str.size()];
	
	cout << ans.getValue() << endl;
	
	
	return 0;
}

Measured memory_bytes: 198912
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ARC087C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var A = ss.Next(int.Parse, N);

            var dic = new Dictionary<int, int>();
            foreach (var a in A)
            {
                if (dic.ContainsKey(a))
                {
                    dic[a]++;
                }
                else
                {
                    dic.Add(a, 1);
                }
            }

            sw.WriteLine(dic.Sum(x => x.Value >= x.Key ? x.Value - x.Key : x.Value));
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 31324
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
    int N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    int cnt = 0;
    rep(i,N){
        char a = A.at(i),b = B.at(i), c = C.at(i);
        if(a==b && b==c);
        else if(a==b||b==c||c==a)cnt++;
        else {cnt++;cnt++;}
    }
    cout << cnt << endl;
}   

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

namespace Atcoder_0404
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = GetInput_int();
            int _contentCount = NM[0];
            int _goodCount = NM[1];
            List<int> _points = new List<int>(GetInput_int());

            float _limit = _points.Sum() / (float)(_goodCount * 4);

            _points.Sort();
            if (_points[_contentCount - _goodCount] >= _limit)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
        }

        #region input
        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        #endregion
    }
}

Measured memory_bytes: 13268
a,b,h,m=gets.split.map &:to_f
ax,ay=a*Math.sin((h+m/60)/12*2*Math::PI),a*Math.cos((h+m/60)/12*2*Math::PI)
bx,by=b*Math.sin(m/60*2*Math::PI),b*Math.cos(m/60*2*Math::PI)
p ((ax-bx)**2+(ay-by)**2)**0.5

Measured memory_bytes: 14792
from collections import deque


k = int(input())
num_deq = deque([i for i in range(1, 10)])
for i in range(k-1):
    x = num_deq.popleft()
    if x % 10 != 0:
        num_deq.append(10 * x + x % 10 - 1)
    num_deq.append(10 * x + x % 10)
    if x % 10 != 9:
        num_deq.append(10 * x + x % 10 + 1)
x = num_deq.popleft()
print(x)


Measured memory_bytes: 18652
X, Y = map(int, input().split())

def ctr(n):
    if n == 1:
        return 300000
    elif n == 2:
        return 200000
    elif n == 3:
        return 100000
    else:
        return 0

ans = ctr(X) + ctr(Y)
ans += 400000 if X == Y == 1 else 0
print(ans)


Measured memory_bytes: 38256