akhauriyash/Code-Regression huggingface dataset:
# 奇数文字目→R U D　偶数文字目→L U D
S = ' ' + input()  
flag = True 

for i in range(1,len(S)): 
    if i % 2 == 1:  
        if S[i] == 'L':    
            flag = False   
            break
    else:   
        if S[i] =='R':     
            flag = False
            break

print('Yes' if flag else 'No')


Measured memory_bytes: 2940
n,k,q=map(int,input().split())
l=[]
p=[]
for i in range(n):
   p.append(k)
for i in range(q):
   num=int(input())
   l.append(num)
for ep in l:
     p[ep-1]+=1
for ep in p:
     if ep<=q:
        print('No')
     else:
        print('Yes')
     
    


Measured memory_bytes: 10460
using System;

namespace ITP1_4_A
{
    class Program
    {
        static void Main(string[] args)
        {
            double a, b, f;
            string[] str = Console.ReadLine().Split(' ');
            a = double.Parse(str[0]);
            b = double.Parse(str[1]);

            int d = (int)(a / b);
            int r = (int)(a % b);
            f = a / b;
            

            Console.WriteLine("{0} {1} {2:f8}", d, r, f);
        }
    }
}

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

using namespace std;

using ll = long long;

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

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

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

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

static const double pi = acos(-1.0);

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

class Query
{
    public:
    ll B,C;
};

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

    map<ll,ll> A_map;
    for(ll i=0;i<N;i++)
    {
        ll a;
        cin >> a;
        A_map[a]++;
    }

    ll acc_A = 0;
    for(auto x : A_map)
    {
        acc_A += x.first * x.second;
    }

    ll Q;
    cin >> Q;

    vector<Query> queries(Q);
    for(ll i=0;i<Q;i++)
    {
        cin >> queries[i].B >> queries[i].C;
    }

    for(ll i=0;i<Q;i++)
    {
        acc_A += A_map[queries[i].B]*(queries[i].C-queries[i].B);
        A_map[queries[i].C] += A_map[queries[i].B];
        A_map[queries[i].B] = 0;
        OUT0(acc_A);
    }

    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int i, t;
  t = 700;
  for(i = 0; i < 3; i++)
  {
    if(s.at(i) == 'o')
    {
      t += 100;
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 768
n = int(input());p = [int(_) for _ in input().split()]
cnt = 0
for i in range(1,n-1):
    if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
        cnt += 1
    else:
        continue
print(cnt)

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!

from collections import deque


h,w = map(int,input().split(" "))


ls = eval("input(),"*h)

kuro = 0
for i in range(h):
    kuro += ls[i].count("#")


done = [[0]*w for _ in range(h)]

s = deque()
yone =(0,0,1,-1)
xone =(1,-1,0,0)

s.append((0,0))
while s:
    y, x = s.popleft()
    for i,j in zip(yone,xone):
        ny = y+i
        nx = x+j
        if (0 <= ny < h) and (0 <= nx < w):
            if (ls[ny][nx]==".") and (done[ny][nx]==0):
                s.append([ny,nx])
                done[ny][nx] = done[y][x] + 1
               
 
if done[h-1][w-1]:
    print(h*w -kuro -done[h-1][w-1]-1)
else:
    print(-1)
    
    



Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

bool data[10];

bool isInclude(int i){
	stringstream ss;
	ss<<i;
	string s = ss.str();
	rep(i,s.size()){
		if(data[s[i]-'0']==true)return true;
	}
	return false;
}

int main(){
	rep(i,10)data[i] = false;
	int n,k;
	cin>>n>>k;
	rep(i,k){
		int d;
		cin>>d;
		data[d] = true;
	}
	
	for(int i = n;;i++){
		if( isInclude(i) == false ){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    long int a,b,c,d;
    scanf("%ld %ld %ld %ld", &a, &b, &c, &d);
    long int ac = a * c;
    long int ad = a * d;
    long int bc = b * c;
    long int bd = b * d;
    if (ac > ad)
    // ad
    {
        if (ac > bc)
        // ad bc
        {
            if (ac > bd)
            // ad bc bd
            {
                printf("%ld", ac);
            }
            else
            // ad bc ac
            {
                printf("%ld" ,bd);
            }
        }
        else
        // ad ac
        {
            if (bc > bd)
            // ad ac bd
            {
                printf("%ld", bc);
            }
            else
            // ad ac bc
            {
                printf("%ld", bd);
            }
        }
    }
    else
    // ac
    {
        if (ad > bc)
        // ac bc
        {
            if (ad > bd)
            // ac bc bd
            {
                printf("%ld", ad);
            }
            else
            // ac bc ad
            {
                printf("%ld", bd);
            }
        }
        else
        // ac ad
        {
            if (bc > bd)
            // ac ad bd
            {
                printf("%ld", bc);
            }
            else
            // ac ad bc
            {
                printf("%ld", bd);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1692
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int n, m; cin >> n >> m;
	string s; cin >> s;
	vector<int> ok;
	int cnt = 0;
	for (int i = 0; i < n + 1; i++) {
		if (s[i] == '0') {
			ok.push_back(1 + cnt);
			cnt = 0;
		}
		else cnt++;
	}
	for (int i = 0; i < (int)ok.size() - 1; i++) {
		ok[i + 1] += ok[i];
	}
	for (int i = 0; i < (int)ok.size(); i++) {
		ok[i]--;
	}
	for (int i = 0; i < (int)ok.size(); i++) ok[i] = n - ok[i];
	reverse(ok.begin(), ok.end());
	int pos = 0;
	cnt = 0;
	vector<int> ans;
	while (pos < ok.size() && ok[pos] < n) {
		int lo = pos, hi = (int)ok.size();
		while (hi - lo > 1) {
			int mid = lo + (hi - lo) / 2;
			if (ok[mid] <= ok[pos] + m) {
				lo = mid;
			}
			else {
				hi = mid;
			}
		}
		ans.push_back(ok[lo] - ok[pos]);
		if (pos == lo) break;
		pos = lo;

		cnt++;
	}
	if (pos < ok.size() && ok[pos] == n) {
		reverse(ans.begin(), ans.end());
		for (int i = 0; i < (int)ans.size(); i++) {
			cout << ans[i] << " \n"[i == (int)ans.size() - 1];
		}
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll sum = 0;
	int n; cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) sum+=a[i];
	ll best = ll(1e18); ll mn = -1;
	for(int i=0;i<n;i++)
	{
		if(abs(a[i]*n-sum)<best)
		{
			best=abs(a[i]*n-sum);
			mn=i;
		}
	}
	cout<<mn<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string a, b, c;
	cin >> a >> b >> c;
	a[0] = a[0] - 'a' + 'A';
	b[0] = b[0] - 'a' + 'A';
	c[0] = c[0] - 'a' + 'A';
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;


int main(){
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n)std::cin >> a[i];
	sort(all(a));
	int counter=0;
	rep(i,n-1)if(a[i]==a[i+1])counter++;
	if(counter%2==0)std::cout << n-counter << std::endl;
	else std::cout << n-counter-1 << std::endl;
}

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

int main() {
	int n;
	cin >> n;
	map<string, int>mp;
	for (int i = 0;i < n;++i) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	ll ans = 0;
	for (auto& p : mp) {
		int s = p.second;
		ans += (ll)s * (s - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Data.Char
import Data.IORef

inter it a b
    | a == 1 = VUM.write it b True
    | b == 1 = VUM.write it a True
    | otherwise = return ()

dest ds a b n
    | a == n = VUM.write ds b True
    | b == n = VUM.write ds a True
    | otherwise = return ()

main = do
    [n, m] <- Prelude.map read . Prelude.words <$> Prelude.getLine :: IO [Int]
    it <- VUM.replicate (n+1) False
    ds <- VUM.replicate (n+1) False
    res <- newIORef False
    forM_ [1..m] $ \_ -> do
        bs <- B.getLine
        let Just (a, bs') = B.readInt bs
            Just (b, _) = B.readInt $ B.dropWhile isSpace bs'
        inter it a b
        dest ds a b n
    forM_ [1..n] $ \i -> do
        r <- VUM.read it i
        when r $ do
            r' <- VUM.read ds i 
            when r' $ modifyIORef' res (||True)
    
    readIORef res >>= \r -> putStrLn $ if r then "POSSIBLE" else "IMPOSSIBLE"

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

int main(){
  int N,n[100001],s,t,min,sum=0;
  cin>>N>>s;
  t=0;
  min=100001;
  for(int i=0;i<N;i++){
    cin>>n[i];
    sum+=n[i];

    if(sum>=s){
      while(sum>=s){
	sum-=n[t];
	t++;
      }
      t--;
      sum+=n[t];
      if(min>i-t+1)min=i-t+1;
      sum-=n[t];
      t++;
    }
  }
  if(min==100001)cout<<"0"<<endl;
  else cout<<min<<endl;
  return 0;
}

Measured memory_bytes: 3464
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a + b, min(b + c, c + a)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <limits>
#include <set>
//std::numeric_limits<int>::max(), min()

template <class T> class UnionFind {

  private:
    struct subset  {
      T parent;
      T rank;
      T diff_weight;
      T sizes;
    };
    std::vector<subset> subsets;

  public:
    UnionFind (T N) {
      subsets.reserve(N);
      for(T i=0; i<N; i++){
        subsets.push_back( { i, 0, 0, 1 } );
      }
    }

    T Find (T x) {
      if (subsets[x].parent == x) return x;
      subsets[x].diff_weight += subsets[subsets[x].parent].diff_weight;
      return subsets[x].parent = Find(subsets[x].parent);
    }

    T weight(T x) {
      Find(x);
      return subsets[x].diff_weight;
    }

    bool Same (T x, T y) {
        return Find(x) == Find(y);
    }

    bool Union (T x, T y, T w) {
      w += weight(x); w -= weight(y);

      T xroot = Find(x);
      T yroot = Find(y);
      if ( xroot == yroot ) return false;

      if (subsets[xroot].rank < subsets[yroot].rank) {
        subsets[xroot].parent = yroot;
        w = -w;
        subsets[yroot].sizes += subsets[xroot].sizes;
      }
      else if (subsets[xroot].rank > subsets[yroot].rank) {
        subsets[yroot].parent = xroot;
        subsets[xroot].sizes += subsets[yroot].sizes;
      }
      else {
        subsets[yroot].parent = xroot;
        subsets[xroot].rank++;
        subsets[xroot].sizes += subsets[yroot].sizes;
      }
      subsets[yroot].diff_weight = w;
      return true;
    }

    T diff(T x, T y) {
      return weight(y) - weight(x);
    }

    T size (T x) {
      return subsets[Find(x)].sizes;
    }
};


int main (void) {

  int N, M;
  std::cin >> N >> M;

  UnionFind<int> uf(N);

  for(int i=0; i<M; i++){
    int x, y, z;
    std::cin >> x >> y >> z;
    uf.Union(x-1, y-1, 0.);
  }

  std::set<int> s;
  for(int i=0; i<N; i++) s.insert(uf.Find(i));
  std::cout << s.size() << std::endl;

  return 0;
}

Measured memory_bytes: 6528
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int H = 1005;
	        int[] m = new int[H];
	        int[] p = new int[H];
	        int k=0;
		m[1]=1;
	        for(int i=2;i<H;i++) {
	        	if(m[i]==0) {
	        		m[i]=1;
	        		p[k]=i;
	        		k++;
	        		for(int j=i+i;j<H;j=j+i) {
	        			m[j]=i;
	        		}
	        	}
	        }	        

	        
	        int N = sc.nextInt();
	        int[][] dp = new int[100][100];
	        int[] m1 = new int[105];
	        dp[0][1]=1;
	        for(int i=1;i<=N;i++) {
	        	int t=i;
	        	while(t!=1) {
        			if(m[t]==1) {
    	        		for(int j=0;j<25;j++) {
    	        			if(t==p[j]) {
    	        				m1[j]++;
    	        			}
    	        		}        				
        				break;
        			} else {
    	        		for(int j=0;j<25;j++) {
    	        			if(m[t]==p[j]) {
    	        				m1[j]++;
    	        			}
    	        		}
    	        		t=t/m[t];        				
        			}
	        	}
	        }
	        dp[0][1]=1;
	        for(int i=0;i<=25;i++) {
	        	for(int j=1;j<=m1[i]+1;j++) {
	        		for(int l=0;l<80;l++) {
	        			if(l*j<80)dp[i+1][l*j]=dp[i+1][l*j]+dp[i][l];	   
	        		}     		
	        	}
	        	
	        }
	        System.out.println(dp[25][75]);
		 }
	}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
using namespace std;
typedef struct
{
    int a;
    int b;
}ab;
ab s[200100];
int com(ab t1,ab t2)
{
    return t1.b<t2.b;
}
int main()
{
    int n,flag=1,ti=0;
    cin>>n;
    for(int i=0;i<n;i++) scanf("%d%d",&s[i].a,&s[i].b);
    sort(s,s+n,com);
    for(int i=0;i<n;i++)
    {
        ti+=s[i].a;
        if(ti>s[i].b)
        {
            flag=0;
            break;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1792
from functools import lru_cache
import sys
sys.setrecursionlimit(10**7)

MODULO = 10**9 + 7


@lru_cache(maxsize=None)
def ways(n):
    if n < 0:
        return 0

    if n == 0:
        return 1

    if n < 3:
        return 0

    total = 0
    for num in range(3, n + 1):
        total = (total + ways(n - num)) % MODULO

    return total


s = int(input())
print(ways(s))


Measured memory_bytes: 10144
x,n = map(int,input().split())

p_list = list(map(int,input().split()))

import sys
if n == 0:
    print(x)
else:
    sa_min = 1000000
    for i in range(-110, 210):
        if i not in p_list:
            if sa_min > abs(i - x):
                sa_min = abs(i - x)
                ans = i
    print(ans)

Measured memory_bytes: 9192
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int n,i,z;
string s1,s2,s;
int main ()
{
	cin>>s1>>s2;
	for(i=0;i<s1.size();i++)
	{
		s+=s1[i];
		if(i<s2.size())
		{
		    s+=s2[i];
		}
		}
	cout<<s;
	return 0;
}

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

int main(){
  char **c;
  int n,i,j,k,min=0,max=0,num;
  int *h;

  scanf("%d",&n);

  h=(int *)malloc(n*sizeof(int));
  c=(char **)malloc(n*sizeof(char *));
  for(i=0;i<n;i++){
    c[i] = (char *)malloc(10*sizeof(char));
  }
  
  for(i=0;i<n;i++){
    scanf("%s",c[i]);
    
    if(c[i][0] == 'i'){
      scanf("%d",&num);
      h[max]=num;
      max++;
    }
      
    else  if(c[i][6]=='F'){
      max--;
    }

    else if(c[i][6]=='L'){
      min++;
    }

    else {
      scanf("%d",&num);
      for(j=max-1;j>=min;j--){
	if(h[j]==num){
	  for(k=j;k>0;k--) h[k]=h[k-1];
	  min++;
	  break;
	}
      }
    }
  }

  for(i=max-1;i>=min;i--) {
    if(i!=min){
      printf("%d ",h[i]);
    }
    else if(i==min){
      printf("%d\n",h[i]);
    }
  }

  return 0;
  
}

Measured memory_bytes: 83916
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

template<typename T>
class prime {
    T n;
public:
    prime(T n):n(n) {}
    map<int,int> factorlist() {
        if(n == 1) return {};
        T nn = n;
        map<int,int> ret;
        for(int i = 2; (ll)i*i <= n; i++) {
            if(nn%i != 0) continue;
            int cnt = 0;
            while(nn%i == 0) {
                cnt++;
                nn /= i;
            }
            ret[i] = cnt;
        }
        if(nn != 1) ret[nn]++;
        return ret;
    }
    vi unique_factor() {
        map<int,int> m = factorlist();
        vi ret;
        for(P p : m) ret.pb(p.first);
        return ret;
    };
    bool isprime() {
        auto v = factorlist();
        return v.size() == 1 && v[0].second == 1;
    }
    int count_divisor() {
        int ret = 1;
        map<int,int> fl = factorlist(n);
        for(auto p : fl) ret *= p.second+1;
        return ret;
    };
    vector<T> enum_divisors() {
        vector<T> res;
        for(T i = 1; i*i <= n; i++) {
            if(n%i == 0) {
                res.pb(i);
                if(n/i != i) res.pb(n/i);
            }
        }
        sort(all(res));
        return res;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    int ans = 0;
    map<int,int> mp;
    rep(i,n) mp[a[i]]++;
    rep(i,n) {
        mp[a[i]]--;
        prime<int> p(a[i]);
        auto v = p.enum_divisors();
        bool ok = true;
        for(int j : v) {
            if(mp[j] > 0) ok = false;
        }
        if(ok) ans++;
        mp[a[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 32972
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define __builtin_ctz __builtin_ctzll
#define __builtin_clz __builtin_clzll
#define __builtin_popcount __builtin_popcountll
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',') { cerr<<*sdbg++; } cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }


int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  

  int x;
  cin>>x;
  RE (i, 2000) {
    if (i * x% 360 == 0) {
      cout<<i<<endl;
      return 0;
    }
  }
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  int n;
  int flg,cnt,tmp;
  cin >> n;
  a.resize(n);
  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }

  flg = 1;
  cnt = 0;
  while(flg){
    flg = 0;

    for(jj=n-1;jj>=1;jj--){
      if(a[jj] < a[jj-1]){

        tmp = a[jj];
        a[jj] = a[jj-1];
        a[jj-1] = tmp;
        
        flg = 1;
        cnt++;
      }
    }

  }

  vector<int>::iterator it;
  it = a.begin();

  while(it != a.end()){
    cout << *it ;
    it++;
    if(it != a.end()){
      cout << " ";
    }
  }
  cout << endl;

  cout << cnt <<endl;
  
  return 0;
}



Measured memory_bytes: 3096
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double m = Math.PI * r * r;
        double s = Math.PI * 2 * r;
        
        System.out.printf("%.6f %.6f\n", m, s);
    }
}



Measured memory_bytes: 28292
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int n; cin >> n;
    vector<ll> x(n), y(n);
    rep(i,n) {
        ll a, b; cin >> a >> b;
        x[i] = a + b;
        y[i] = a - b;
    }
    ll ans = 0;

    chmax(ans, *max_element(all(x)) - *min_element(all(x)));
    chmax(ans, *max_element(all(y)) - *min_element(all(y)));
    cout << ans << endl;
    return 0;

    
}

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

int main() {
  int a,b;
  cin>>a>>b;

  if (a>0&&b>0) cout<<"Positive"<<endl;
  else if (a<=0&&b>=0) cout<<"Zero"<<endl;
  else {
    if ((abs(a)-abs(b)+1)%2==0) cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
  }
  
  return 0;
}

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

const int N = 21;
const int mod = 1000000007;

int arr[N+5][N+5];
int dp[(1<<21)+10];
int n;

int rec(int p,int ms)
{
    if(p==n) return (ms==(1<<n)-1);
    int &ret=dp[ms];
    if(ret!=-1) return ret;
    ret=0;
    for(int i=0; i<n; i++)
    {
        if(!(ms&(1<<i)) && arr[p][i])
        {
            ret+=rec(p+1,ms|(1<<i));
            ret%=mod;
        }
    }
    return ret;
}

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++) scanf("%d",&arr[i][j]);
    }
    memset(dp,-1,sizeof dp);
    printf("%d\n",rec(0,0));


}


Measured memory_bytes: 8448
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] c = s.toCharArray();
		int l = c.length-1;
		long ans = 0L;
		for(int i = 0; i < (1<<l); i++) {
			StringBuilder sb =new StringBuilder();
			for(int j = l-1, k = 0; j >= 0; j--, k++) {
				sb.append(c[k]);
				if(((i>>j) & 1) == 1) {
					sb.append('+');
				}
			}
			sb.append(c[l]);
			String[] arr = sb.toString().split("\\+");
			for(int j = 0; j < arr.length; j++) {
				ans += Long.valueOf(arr[j]);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
n = int(input())
li = list(map(int, input().split()))
mid_id = (len(li)//2)
temp = li.copy()
temp.sort()
mid1 = temp[mid_id-1]
mid2 = temp[mid_id]
for i in li:
    if i <= mid1:
        print(mid2)
    else:
        print(mid1)

Measured memory_bytes: 25220
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        X.append(x)
        Y.append(y)
        H.append(h)
    else:
        X.insert(0, x)
        Y.insert(0, y)
        H.insert(0, h)
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(min(X), max(X) + 1):
    for Cy in range(min(Y), max(Y) + 1):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and H[i] == max(h - abs(X[i]-Cx) - abs(Y[i]-Cy), 0):
            i += 1
        if i == N:
            print(Cx, Cy, h)


Measured memory_bytes: 3064
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define mp make_pair
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " -> " << a << endl;
	err(++it, args...);
}

void testcase(){
	int n;
	char a[200005];
	cin >> n;
	for(int i{0};i < n;i++){
		cin >> a[i];
	}
	int cnt = 0,ans = 0;
	for(int i{0};i < n;i++){
		if(a[i] == 'R'){
			cnt++;
		}
	}
	for(int i{0};i < cnt;i++){
		ans += a[i] == 'W';
	}
	cout << ans;
}

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


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

int yinzi(int x)
{
	int cnt = 0;
	for(int i = 1; i <= x; i ++)
		if(x % i == 0) cnt ++;
	return cnt;
}

int main()
{
	int n;
	scanf("%d", &n);
	int ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		if(yinzi(i) == 8 && i & 1) ans ++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math

a, d = map(int, input().split())
sum = 0

for i in range(a):
    #print(i)
    x, y = map(int, input().split())
    D = math.sqrt((x ** 2) + (y ** 2))

    if (D <= d):
        sum = sum + 1

print(sum)

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

using namespace std;
typedef long long ll;

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

int main()
{
    int n;
    cin >> n;
    if (n == 1)
    {
        cout << "Hello World" << '\n';
    }
    else
    {
        int a, b;
        cin >> a >> b;
        cout << a + b << '\n';
    }
    return 0;
}


Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8 + 7;
const ll mod = 1e9L + 7;
const int nax = 2e5 + 5;

ll fact[nax], rfact[nax];

ll power(ll x, ll y) {
    if(y == 0) {
        return 1;
    } else if(y % 2 == 1) {
        return power(x, y-1) * x % mod;
    } else {
        ll tmp = power(x, y / 2);
        return tmp * tmp % mod;
    }
}

ll mult(ll a, ll b) {
    return a * b % mod;
}

ll numPaths(int a, int b) {
    a += b;
    return mult(fact[a], mult(rfact[b], rfact[a-b]));
}

ll sub(ll a, ll b) {
    return (a - b + mod) % mod;
}


int main() {
    
    int h, w, n;
    scanf("%d%d%d",&h,&w,&n);
    
    vector<pair<int,pair<int,int>>> walls(n);
    
    for(int i = 0; i < n; ++i) {
        scanf("%d%d",&walls[i].second.first,&walls[i].second.second);
        walls[i].first = walls[i].second.first + walls[i].second.second;
    }
    
    // compute factorials
    fact[0] = rfact[0] = 1;
    for(int i = 1; i < nax; ++i) {
        fact[i] = fact[i-1] * i % mod;
        rfact[i] = power(fact[i], mod-2);
    }
    
    sort(walls.begin(), walls.end());
    
    walls.push_back(make_pair(-1, ii(h, w)));
    
    vector<ll> dp(n+1);
    
    for(int i = 0; i <= n; ++i) {
        int r1 = walls[i].second.first, c1 = walls[i].second.second;
        ll ans = numPaths(r1-1, c1-1);
        
        for(int j = 0; j < i; ++j) {
            int r2 = walls[j].second.first, c2 = walls[j].second.second;
            if(r2 > r1 || c2 > c1) continue;
            ans = sub(ans, mult(dp[j], numPaths(r1-r2, c1-c2)));
        }
        
        dp[i] = ans;
    }
    
    printf("%lld\n", dp[n]);
    
    return 0;
}




Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <cmath>
 
int state_circles(const std::vector<double> &a, const std::vector<double> &b){
    double d;
    d = sqrt(pow(a[0] - b[0], 2) + pow(a[1] - b[1], 2));
    if((a[2] + b[2]) < d)
        return 0;
        if(std::abs(a[2] - b[2]) > d){
        if(a[2] > b[2])
            return 2;
        else
            return -2;
    }
     
    else
        return 1;
}
 
int main(){
    std::vector<double> a(3), b(3);
    int data_num;
    std::cin >> data_num;
    for(int i = 0; i < data_num; ++i){ 
        std::cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2];
        std::cout << state_circles(a, b) << std::endl;
    }
     
    return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
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;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int D,T,S;cin>>D>>T>>S;
	if(T*S>=D)cout<<"Yes\n";
	else cout<<"No\n";
}

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

int main(){
  int N, X, M;
  int m = 10000;
  cin >> N >> X;
  for(int i = 0; i < N; i++){
    cin >> M;
    X -= M;
    m = min(M, m);
  }
  cout << N + X/m << endl;
  return 0;
}


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

vector<int> to[200005]; //木の構造
vector<int> done;
vector<ll> memo;
ll dp(ll v)
{
    if (done[v] != 0)
    {
        return memo[v];
    }
    ll res = 0;
    priority_queue<ll> que;
    for (ll u : to[v])
    {

        que.push(dp(u));
    }
    if (que.empty() != 1)
    {
        res = que.top();
        res += 1;
    }
    else
    {
        res = 0;
    }
    memo[v] = res;
    done[v] = 1;
    return res;

}
int main()
{
    ll n, m;
    cin >> n >> m;
    done.resize(n);
    memo.resize(n);
    rep(i, m)
    {
        ll x, y;
        cin >> x >> y;
        x--;
        y--;
        to[x].push_back(y);
    }
    priority_queue<ll> que;
    rep(i, n)
    {
        que.push(dp(i));
    }
    cout << que.top() << endl;
}

Measured memory_bytes: 13816
#include <cmath>
#include <chrono>
#include <random>
#include <ctime>
#include <algorithm>
#include <iosfwd>
#include <iostream>
#include <list>
#include <ostream>
#include <streambuf>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define fori(i, n) for(ll i = 0; i < (n); ++i)
#define forI(i, n) for(ll i = 1; i <= (n); ++i)
#define pll pair<ll, ll>
#define ff first
#define ss second

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#define pt pair<ll, ll>
#define x first
#define y second

pll operator+ (pll a, pll b){ return {a.x + b.x, a.y + b.y}; }

ll rand0m() {
    return (ull(rand()) << 15ull | ull(rand()));
}                   //[0 ... n)
ll rand0m(ll x) {
    return rand0m() % x;
}               //[0 ... n)
ll rand0m(ll minn, ll maxx) {
    return rand0m(maxx - minn + 1) + minn;
}   //[minn ... maxx]

const ll MAXN = 1e5 + 1;
const ll mod = 1e9 + 7;
const ll INF = 2e9 + 1000;

ll n, m;
ll w[101];
ll v[101];
ll bp[101][MAXN];

void solve() {
    ll W;
    cin >> n >> W;
    forI(i, n) cin >> w[i] >> v[i];
    forI(i, MAXN - 1) bp[0][i] = INF;
    forI(i, n){
        fori(j, MAXN){
            bp[i][j] = bp[i - 1][j];
            if(j - v[i] >= 0) bp[i][j] = min(bp[i][j], bp[i - 1][j - v[i]] + w[i]);
        }
    }
    ll ans = 0;
    fori(i, MAXN){
        if(bp[n][i] <= W) ans = i;
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
}

Measured memory_bytes: 79104
//ええなにそれ・・・割り算ってllよりdoubleの方が速いとでも？
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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

int tmp[200001];
void pakuri_sort(int N, int A[]) {
	const int b = 10;
	rep(k, 2) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}
void pakuri_sort2(int N, int A[]) {
	const int b = 10;
	rep(k, 2) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		for (int i = (1 << b) - 2; i >= 0; i--) kazu[i] += kazu[i + 1];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		for (int i = (1 << b) - 2; i >= 0; i--) kazu2[i] += kazu2[i + 1];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	ll N = getint(), K = getll();
	int A[200000], F[200000];
	rep(i, N) A[i] = getint();
	rep(i, N) F[i] = getint();
	pakuri_sort(N, A);
	pakuri_sort2(N, F);

	ll L = -1, R = 1e12;
	while (L + 1 < R) {
		ll M = (L + R) / 2;

		ll kazu = 0;
		rep(i, N) {
			kazu += max(0, A[i] - (int)((double)M / F[i]));
			if (kazu > K) break;
		}
		if (kazu > K) L = M;
		else R = M;
	}

	printf("%lld", R);

	Would you please return 0;
}

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

int n;

void f(string s, int i) {
  if(s.size() == n) {
    cout << s << endl;
    return;
  }
  rep2(j, 1, i + 2) {
    string ns = s + (char)('a' + j - 1);
    f(ns, max(i, j));
  }
}

int main() {
  cin >> n;
  f("a", 1);
}

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

int main() {
  int K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i < X + K; i++) {
    printf("%d%c", i, (i == X + K - 1) ? '\n' : ' ');
  }
}

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

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n; cin >> n;

    long long num, tot = 0, cur = 0;

    for(int i = 0; i < n; ++i){
        cin >> num;
        if(num > 2){
            tot += num - 1 >> 1;
            num = 1 + (num + 1) % 2;
        }
        if(num == 0){
            tot += cur >> 1;
            cur = 0;
        } else {
            cur += num;
        }
    }

    cout << tot + (cur >> 1) << "\n";

    return 0;

}


Measured memory_bytes: 256
from math import sqrt
q = int(input())
for _ in range(q):
    a, b = map(int, input().split(" "))
    c = a * b
    d = int(sqrt(c))
    answer = 2 * d - 2
    if d**2 == c:
        answer -= 1
    if d * (d + 1) < c:
        answer += 1
    if a == b:
        answer += 1
    print(answer)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int ans = 0;
	int i = 0;
	while (i < 3) {
		if (s[i] == '1')
			ans++;
		i++;
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3552
from fractions import gcd

N=int(input())
A=list(map(int, input().split()))

p=10**9+7
n = 10 ** 6  # N は必要分だけ用意する
#fact = [1, 1]  # fact[n] = (n! mod p)
#factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用 逆元

for i in range(2, n + 1):
    #fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    #factinv.append((factinv[-1] * inv[-1]) % p)
#a//gcd(a,b)*b

def lcm(a,b):
    g=gcd(a,b)
    #return ((a*b)*pow(g,p-2,p))%p
    return a//gcd(a,b)*b

LCM=1
for x in A:
    LCM=lcm(LCM,x)



#print(LCM)
ans=0
LCM%=p
for i in range(N):
    ans+=(LCM*inv[A[i]])%p
    #ans+=(LCM*pow(A[i],p-2,p))%p
    ans%=p
print(ans)

Measured memory_bytes: 114664
from collections import deque

N,M=map(int,input().split())
m=[[] for _ in range(N)]
n=[-1]*N
n[0]=0
for _ in range(M):
	a,b=map(int,input().split())
	m[a-1].append(b-1)
	m[b-1].append(a-1)

def bfs():
	que=deque([])
	que.append(0)
	while que:
		p=que.popleft()
		for i in m[p]:
			if n[i]==-1:
				que.append(i)
				n[i]=p+1

bfs()

print('Yes')
for j in range(1,N):
	print(n[j])

Measured memory_bytes: 36864
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repn(a,b,c) for(int a=b;a<=c;a++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;
//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0){
        return a;
    }    
    else{
        return gcd(b,a%b);
    }
}

//LCM
ll lcm(ll a,ll b){
    if(a==0 || b==0){
        return 0;
    }
    else{
        return((ll)((a*b)/gcd(a,b)));
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}

//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

//All Non-Empty SubSequences(O(2*n))
vvi SubSeq;
void allSub(vector<int> arr, int index,vector<int> subarr){
    if (index == arr.size()){ 
        int l = subarr.size(); 
        if (l != 0){
            SubSeq.pb(subarr); 
        }
    } 
    else{ 
        allSub(arr, index + 1, subarr); 
        subarr.push_back(arr[index]); 
        allSub(arr, index + 1, subarr); 
    } 
    return; 
} 

int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    double a,b;
    cin>>a>>b;
    double h,m;
    cin>>h>>m;
    double h1= h+(m/60);
    double a1= 30*(h1);
    double a2= 6 * m;
    double ang=0;
    if(abs(a1-a2)>180){
        ang= 360 - abs(a1-a2);
    }
    else{
        ang=abs(a1-a2);
    }
    //cout<<a1<<" "<<a2<<" "<<ang<<endl;
    //cout<<cos(ang*PI/180);
    double val = a*a+ b*b - 2 * a * b * cos((ang*(double)PI)/180);
    //cout<<val<<endl;
    cout<<setprecision(20)<<sqrt(val)<<endl;
    


    return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)

ll n,a[100005],dp[100005],k;

ll f(int i)
{
    if(i==n)return dp[i]=0;
    if(dp[i]!=-1)return dp[i];

    ll j,m=inf;
    for(j=1;j<=k&&(i+j)<=n;j++)
    {
        m=min(abs(a[i]-a[i+j])+f(i+j),m);
    }
    return dp[i]=m;
}

int main()
{
    fastio;

    ll i;
    cin >> n >> k;
    for(i=1;i<=n;i++)cin >> a[i];
    memset(dp,-1,sizeof(dp));
    cout << f(1);

    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<string>
using namespace std ;
int main(){
    int n,d; cin>>n>>d ; 
    if(n%(2*d+1)==0) cout<<n/(2*d+1)<<endl ;
    else cout<<n/(2*d+1)+1<<endl ;
    return 0 ;
}


Measured memory_bytes: 256
'use strict';

const fs = require('fs');

const repeatString = (s, n) => {
  let r = '';
  for (let i = 0; i < n; i++) {
    r += s;
  }
  return r;
};

const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
const numbers = input[0].split(' ').map(n => parseInt(n, 10));

const h = numbers[0];
const w = numbers[1];

console.log(repeatString('#', w + 2));

for (let i = 1; i < h + 1; i++) {
  const line = input[i];
  console.log('#' + line + '#');
}

console.log(repeatString('#', w + 2));

Measured memory_bytes: 21064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
int main()
{
	int n;cin>>n;
	if(n>=1000)cout<<"ABD"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
struct Edge{
    int u,v,cost;
};
vector<P> graph[110000];
int dist[110000];
int dist2[110000];
const int INF = 1001001001001LL;
signed main()
{
    int n,m,k;cin >> n >> m >> k;
    rep(i,m){
        int a,b,l;cin >> a >> b >> l;
        a--;b--;
        graph[a].push_back(P(b,l));
        graph[b].push_back(P(a,l));
    }
    priority_queue<P,vector<P>,greater<P>> q;
    rep(i,110000){
        dist[i] = INF;
        dist2[i] = INF;
    }
    rep(i,k){
        int s;cin >> s;
        s--;
        dist[s] = 0;
        dist2[s] = 0;
        q.emplace(0,s);
    }
  
    while(q.size()){
        auto p = q.top();q.pop();
        int v = p.second,d = p.first;
        if(dist2[v] < d)continue;
        for(auto next:graph[v]){
            int d2 = d+next.second;
            if(dist[next.first] > d2){
                swap(dist[next.first],d2);
                q.push(P(dist[next.first],next.first));
            }
            if(dist2[next.first] > d2 && dist[next.first] < d2){
                dist2[next.first] = d2;
                q.push(P(dist2[next.first],next.first));
            }

            
        }
    }

    int ans = 0;
    rep(i,n)rep(j,graph[i].size()){
        auto hoge = graph[i][j];
        int res = (dist[i]  + dist[hoge.first]+1 + hoge.second)/2;
        ans = max(ans,res);

    }
    cout << ans << endl;




    return 0;
}


Measured memory_bytes: 10196