akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
lim = int(1e+9+7)


def pat(r,t = lim):
    ans = 1
    for i in range(r):
        ans = (ans*(i+1))%t
    return ans%t

a = pat(n)
b = pat(m)

if abs(n-m) < 1:
    print((a*b*2)%lim)
elif abs(n-m) == 1:
    print((a*b)%lim)
else:
    print(0)

Measured memory_bytes: 3064
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

flag = 1
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            if not i:
                if not j:
                    if s[i+1][j] == '.' and s[i][j+1] == '.':
                        flag = 0
                        break
                elif j == W - 1:
                    if s[i+1][j] == '.' and s[i][j-1] == '.':
                        flag = 0
                        break
                else:
                    if s[i+1][j] == '.' and s[i][j+1] == '.' and s[i][j-1] == '.':
                        flag = 0
                        break
            elif i == H - 1:
                if not j:
                    if s[i-1][j] == '.' and s[i][j+1] == '.':
                        flag = 0
                        break
                elif j == W - 1:
                    if s[i-1][j] == '.' and s[i][j-1] == '.':
                        flag = 0
                        break
                else:
                    if s[i-1][j] == '.' and s[i][j+1] == '.' and s[i][j-1] == '.':
                        flag = 0
                        break
            else:
                if not j:
                    if s[i+1][j] == '.' and s[i][j+1] == '.' and s[i-1][j] == '.':
                        flag = 0
                        break
                elif j == W - 1:
                    if s[i+1][j] == '.' and s[i][j-1] == '.' and s[i-1][j] == '.':
                        flag = 0
                        break
                else:
                    if s[i+1][j] == '.' and s[i][j+1] == '.' and s[i][j-1] == '.' and s[i-1][j] == '.':
                        flag = 0
                        break

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


Measured memory_bytes: 9336
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#include <complex>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, P> A;

llint n, Q;
vector<A> ans;
llint b[20005];

void add(llint i, llint j, llint k)
{
	ans.push_back(A(P(0, i), P(j, k)));
}
void comp(llint i, llint j, llint k)
{
	ans.push_back(A(P(1, i), P(j, k)));
}

void zero(llint x)
{
	comp(0, 3, x);
}

void And(llint p, llint q, llint d)
{
	llint m = 10000;
	zero(m);
	add(m, p, m);
	add(m, q, m);
	comp(10, m, d);
}

void madd(llint a, llint n, llint d)
{
	llint m = 20000;
	zero(m);
	add(a, m, m);
	for(int i = 1; i <= n; i++) add(m, m, m);
	add(d, m, d);
}

void getBinary(llint a, llint p)
{
	zero(4), zero(5);
	for(int i = 30; i >= 0; i--){
		add(4, 10+i, 5);
		comp(a, 5, 6);
		comp(6, 10, 6);
		add(p+i, 6, p+i);
		madd(p+i, i, 4);
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	n = Q = 200000;
	
	comp(2, 0, 10);
	for(int i = 1; i <= 60; i++) add(10+i-1, 10+i-1, 10+i);
	
	getBinary(0, 100);
	getBinary(1, 140);
	
	for(int i = 0; i <= 30; i++){
		for(int j = 0; j <= 30; j++){
			And(100+i, 140+j, 179);
			add(180+(i+j), 179, 180+(i+j));
		}
	}
	for(int i = 0; i <= 60; i++) madd(180+i, i, 2);
	
	cout << ans.size() << endl;
	for(int i = 0; i < ans.size(); i++){
		if(ans[i].first.first == 0) cout << "+ ";
		else cout << "< ";
		cout << ans[i].first.second << " " << ans[i].second.first << " " << ans[i].second.second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3856
import Data.Functor( (<$>))
import Data.ByteString.Lazy.Char8( readInt)
import qualified Data.ByteString.Lazy.Char8 as C8
import Data.Function( on)
import Data.Sequence(
	unstableSortBy, breakr, iterateN,
			(><),
			ViewL( (:<)), viewl,
			ViewR( (:>), EmptyR), viewr)
import qualified Data.Sequence as SQ
import Data.Foldable( toList, foldl')

main = do
    Just (n, body) <-  readInt <$> C8.getContents
    let
	indexSequence = iterateN n (+1) 0

	asc = unstableSortBy (compare `on` snd) $ SQ.zip indexSequence $
		SQ.unfoldr (readInt . C8.tail) body

	aProfit seq
	  | SQ.null seq = Nothing
	  | otherwise 
	    = let
		(ixmin,minv) :< remain = viewl seq
		(through, hit) = breakr ((ixmin<) . fst) remain
	    in
		case viewr hit		of
		rem :> (ixmax, maxv)	-> Just (maxv-minv, SQ.filter
						((ixmin>). fst) $ rem><through)
		EmptyR			-> Just (0,	    remain)

	answer = foldl' max 0  $ SQ.unfoldr aProfit asc

    print $ if answer > 0
	    then answer
	    else -- exceptional case: monotonically decreasing
		negate . minAdjacentDiff $ snd <$> toList asc
	      where
		minAdjacentDiff list@(_:xs) = minimum $ zipWith (-) xs list




Measured memory_bytes: 222516
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

template<int mod>
struct ModInt{
    int x;

    ModInt() : x(0) {}
    
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    
    ModInt &operator+=(const ModInt &p){
        if((x += p.x) >= mod)   x -= mod;
        return *this;
    }
    
    ModInt &operator-=(const ModInt &p){
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    
    ModInt operator-() const {return ModInt(-x);}

    ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}

    ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}

    ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}

    ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}

    bool operator==(const ModInt &p) const {return x == p.x;}

    bool operator!=(const ModInt &p) const {return x != p.x;}

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const{
        ModInt ret(1), mul(x);
        while(n > 0){
            if(n & 1)   ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p){
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a){
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() {return mod;}
};

using modint = ModInt<mod>;

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

    int n, k;
    cin >> n >> k;
    modint ans = modint(k).pow(n);
    vector<modint> x(k + 1);
    for(int g = k; g > 1; --g){
        int per = k / g;
        x[g] = modint(per).pow(n);
        for(int i = g * 2; i <= k; i += g){
            x[g] -= x[i];
        }
        ans -= x[g];
        ans += x[g] * g;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3736
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.exception, std.typecons, std.container;

  int h, w; rd(h, w);
  auto c=new char[][](h, w);
  foreach(i; 0..h) c[i]=readln.chomp.to!(char[]);

  alias pair=Tuple!(int, int);
  int[pair] map;
  foreach(i; 0..h)foreach(j; 0..w) map[pair(i, j)]=map.length.to!(int);
  auto n=h*w;
  struct Edge{int to, cost;}
  auto g=new Edge[][](n);
  auto dir=[[1, 0], [-1, 0], [0, 1], [0, -1]];
  foreach(i; 0..h)foreach(j; 0..w){
    if(c[i][j]=='#') continue;
    foreach(dd; dir){
      auto ai=i+dd[0], aj=j+dd[1];
      if(ai<0 || ai>=h || aj<0 || aj>=w) continue;
      if(c[ai][aj]=='.'){
        g[map[pair(i, j)]]~=Edge(map[pair(ai, aj)], 1);
        g[map[pair(ai, aj)]]~=Edge(map[pair(i, j)], 1);
      }
    }
  }

  alias T=int;
  const inf=1e9.to!(T);
  T[] dijkstra(Edge[][] g, int s){
    auto d=new T[](n);
    fill(d, inf);
    struct P{int v; T d;}
    import std.container;
    auto Q=new RedBlackTree!(P, "a.d<b.d", true);
    Q.insert(P(s, 0)); d[s]=0;
    while(Q.empty==false){
      auto cur=Q.front; Q.removeFront;
      foreach(e; g[cur.v]){
        if(d[e.to]<=d[cur.v]+e.cost) continue;
        d[e.to]=d[cur.v]+e.cost;
        Q.insert(P(e.to, d[e.to]));
      }
    }
    return d;
  }

  auto d=dijkstra(g, map[pair(0, 0)]);

  if(d[map[pair(h-1, w-1)]]==inf){writeln(-1); return;}

  int bk=0;
  foreach(i; 0..h) bk+=count(c[i], '#');
  auto res=n-bk-(d[map[pair(h-1, w-1)]]+1);
  enforce(res>=0);
  writeln(res);
}
void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}


Measured memory_bytes: 1276
from string import ascii_lowercase

s = list(input())
ans = 'AC'

if s[0] != 'A':
    ans = 'WA'

if s[2:-1].count('C') != 1:
    ans = 'WA'

if not s[1] in ascii_lowercase:
    ans = 'WA'

if not s[-1] in ascii_lowercase:
    ans = 'WA'

for c in s[2:-1]:
    if c == 'C':
        continue
    if not c in ascii_lowercase:
        ans = 'WA'
        
print(ans)

Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> cnt(N);
    rep(i,0,Q){
        int x;
        cin >> x;
        cnt[x-1]++;
    }
    rep(i,0,N){
        if(K > Q - cnt[i])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
//
// Created by HDawn on 2020/6/30.
//

#include <stdio.h>

int n, T;

int Binary_Search(int a[],int key) {
    int left = 0;
    int right = n;
    while (left < right) {
        int mid = (left + right) / 2;
        if (a[mid] == key) {
            return 1;
        } else if (key < a[mid]) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    return 0;
}

int main() {
    scanf("%d",&n);
    int a[n+1];
    for (int i = 0; i < n; ++i) {
        scanf("%d",&a[i]);
    }
    scanf("%d",&T);
    int b;
    int ans=0;
    for (int i = 0; i < T; ++i) {
        scanf("%d",&b);
        if (Binary_Search(a,b)) ans++;
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
using namespace std;
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  int flg[5]={0};
  char c;
  
  while (cin>>c){
    if(c=='N') flg[0]=1;
    if(c=='E') flg[1]=1;
    if(c=='W') flg[2]=1;
    if(c=='S') flg[3]=1;
  }
  cout << ((flg[0]^flg[3])||(flg[1]^flg[2])?"No":"Yes") << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    int f_x = 0;
    int X = N;
    while(N > 0) {
        f_x += N % 10;
        N /= 10;
    }
    if(X % f_x == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp
tsuyoi = false

def kaibun?(s)
  if s == s.reverse
    return true
  else
    return false
  end
end

len = s.length

tsuyoi = kaibun?(s) && kaibun?(s[0..((len-1)/2 - 1)]) && kaibun?(s[((len+3)/2 - 1)..-1])
puts tsuyoi ? "Yes" : "No"


Measured memory_bytes: 14224
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> x(N), y(N), z(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }

    ll c1[] = { 1, 1, 1, 1, -1, -1, -1, -1 };
    ll c2[] = { 1, 1, -1, -1, 1, 1, -1, -1 };
    ll c3[] = { 1, -1, 1, -1, 1, -1, 1, -1 };

    ll ans = 0;

    for (int k = 0; k < 8; k++) {
        vector<ll> score(N);
        for (int i = 0; i < N; i++) {
            score[i] = c1[k] * x[i] + c2[k] * y[i] + c3[k] * z[i];
        }
        sort(score.begin(), score.end(), greater<ll>());

        ans = max(ans, accumulate(score.begin(), score.begin() + M, (ll)0));
    }

    cout << ans << endl;
}


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

int main() {
  
  int G,R,N;
  cin >> G >> R >> N;
  
  int count=0;
  int sum=0;
  
  for(int i=0; i < N;i++){
    
    if(G >= R){
      sum += G;
        count++;
      if(sum >= N){
        break;
      }
    }
    
    else if(G < R){
      sum += R;
        count++;
      if(sum >= N){
        break;
      }
    }
    
  }
      cout << count << endl;
	return 0;
      
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//long long a[200005];
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N >= S.length())
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(0, N) << "..." << endl;
    }
}


Measured memory_bytes: 3636
import sys
def fceil(b):
    return   int( b / 10) + 1  if b % 10 else b // 10
aD=[int(_) for _ in sys.stdin.readlines()]
aDM =sorted(set(_%10 for _ in aD))
aD10=[ fceil(_) * 10 for _ in aD]
iM = aDM[0]
if iM == 0:
    if 1 < len(aDM):
        iM = aDM[1]
iD = 10 - iM
if iM == 0:
    iD = 0
print(sum(aD10) - iD)


Measured memory_bytes: 3064
N=int(input())
a=0
if N==1:
    print('a')
else:
    e=[0]
    t=0
    for l in range(1,15):
        t+=26**l
        e.append(t)
    for k in range(15):
        if e[k]+1<=N<=e[k+1]:
            a=k+1
            M=e[k]
            break


    ans=['a']*a
    
    b=N-M
    moji=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    if len(ans)==1:
        ans[0]=moji[b-1]
    else:
        for j in range(0,a-1):
            c=(b-1)//(26**(a-j-1))
            ans[j]=moji[c]
            b-=(26**(a-j-1))*c
        ans[a-1]=moji[b-1]
    ans1=''.join(ans)
    print(ans1)
    

Measured memory_bytes: 9140
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	priority_queue<double>que;
	double a;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		que.push(a);
	}
	for (int i = 0; i < m; ++i) {
		a = que.top();
		que.pop();
		a /= 2.0;
		que.push(a);
	}
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		sum += (int)que.top();
		que.pop();
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int cnt[N], sum[N];
int n, m, x, mx;
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d", &x);
        cnt[x % m]++;
        sum[x]++;
        mx = max(mx, x);
    }
    /*for(int i=0;i<m;i++) {
        cout << i << "->" << cnt[i] << endl;
    }*/
    long long ans = cnt[0]/2;
    cnt[0] = 0;
    for (int i = 1; i < m; i++) {
        if (!cnt[i]) continue;
        if(i == m-i) {
            //cout << "add " << cnt[i]/2 << " at " << i << endl;
            ans += cnt[i]/2;
            cnt[i] %= 2;
        } else {
            int res = min(cnt[i], cnt[m-i]);
            //cout << "add " << res << " at " << i << endl;
            ans += res;
            cnt[i] -= res, cnt[m-i] -= res;
        }
    }
    for(int i=0;i<=mx;i++) {
        int pair = min(sum[i], cnt[i%m]);
        //cout << "pair " << pair << " at " << i << endl;
        //cout << sum[i] << "," << cnt[i%m] << endl;
        if(pair < 2) continue;
        cnt[i%m] -= pair/2*2;
        sum[i] -= pair/2*2;
        ans += pair/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
function Main(input) {
	var data = input.split("\n")
	var req =  data[0].split(" ").map((n) => parseInt(n, 10));
	var answers =  data.map((n) => parseInt(n, 10));
	var border = req[1] - req[2];
	var ary = new Array(req[0]).fill(border);
	
	for(var i=1; i<=req[2]+1;i++){
		ary[answers[i]-1]++;
	}
	for(var i=0; i<ary.length;i++){
		if(ary[i]<=0){
			console.log("No")
		}else{
			console.log("Yes")
		}
	}
}
 
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30228
#include<iostream>
#include<string>
#include<iomanip>
#include<fstream>
#include <cstdlib>
#include<cmath>

using namespace std;

int main()
{
    int p[100010];
    int n,i,a,b=1000;
    double c;
    cin>>n;
    for(i=0; i<n; i++)
        cin>>p[i];
    for(i=1,a=p[0]; i<n; i++)
    {
        if(p[i]>a)
            a=p[i];
    }
    c=(double)a/2;
    for(i=0; i<n; i++)
    {
        if(p[i]>=a)
            continue;
        if(fabs(b-c)>fabs(p[i]-c))
            b=p[i];
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


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

int main(){
	int n;
	int a[100];
	int avg = 0, avg2 = 0;
	int cost = 0, cost2 = 0;
	
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		avg+=a[i];
	}
	avg2 = (avg+n)/n;
	avg = avg/n;
	for(int i = 0; i < n; i++){
		cost += pow(abs(a[i]-avg), 2);
		cost2 += pow(abs(a[i]-avg2), 2);
	}
	
	printf("%d\n", min(cost, cost2));
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int a[maxn];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int ans=-maxn;
	for(int i=1;i*i<=a[0];i++){
		int x=0;
		if(a[0]%i!=0) continue;
		for(int j=0;j<n;j++){
			if(a[j]%i!=0)
			x++;
			if(x==2)
			break;
		}
		if(x<2)
		ans=max(ans,i);
		int ii=a[0]/i;
		x=0;
		for(int j=0;j<n;j++){
			if(a[j]%ii!=0)
			x++;
			if(x==2)
			break;
		}
		if(x<2)
		ans=max(ans,ii);
	}
	for(int i=1;i*i<=a[1];i++){
		int x=0;
		if(a[1]%i!=0) continue;
		for(int j=0;j<n;j++){
			if(a[j]%i!=0)
			x++;
			if(x==2)
			break;
		}
		if(x<2)
		ans=max(ans,i);
		int ii=a[1]/i;
		x=0;
		for(int j=0;j<n;j++){
			if(a[j]%ii!=0)
			x++;
			if(x==2)
			break;
		}
		if(x<2)
		ans=max(ans,ii);
	}
	cout<<ans;
}

Measured memory_bytes: 640
def main():
    N, A, B, C, D = map(int, input().split())
    S = input()
    for i in range(A-1,D):
        if S[i] == '#' and S[i+1] == '#':
            print('No')
            exit()
    
    if C < D:
        print('Yes')
        exit()
    
    for i in range(B-1,D):
        if D != len(S):
            if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
                print('Yes')
                exit()

    print('No')


if __name__ == "__main__":
    main()


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

long int M = 1e+9+7;
int main(void){
    int N,W;
    cin >> N >> W;
    vi w(N),v(N);
    rep(i,N){
        cin >> w[i] >> v[i];
    }
    
    vi dp(100001,-1);
    dp[0] = 0;
    rep(i,N){
        for(int j = 100000; j>=0; j--){
            if(dp[j] != -1 && dp[j]+w[i] <= W){
                if(dp[j+v[i]] == -1) dp[j+v[i]] = dp[j]+w[i];
                else chmin(dp[j+v[i]], dp[j]+w[i]);
                //cout << dp[j+v[i]] << " " << j+v[i] << endl;
            }
        }
    }
    
    for(int i=100000; i>=0;i--){
        if(dp[i] != -1){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 768
object MainKt {
  @JvmStatic fun main(args:Array<String>) {
   val (N,M)=readLine()!!.split(" ").map {it.toInt()}
   val Ai:Array<String> =Array(N) {readLine()!!}
   val Bi:Array<String> =Array(M) {readLine()!!}
 

   println(if (when (N==M) {
     true ->(0..(M-1)).all { Ai[it]==Bi[it]}
     else ->{
         var isMatched=false;
        for( i in 0..(N-1-M))
        {
          for( j in 0..(N-1-M))
          {
              isMatched=(0..(M-1)).all {
                Ai[j+it].substring(i..(i+M-1))==Bi[it]
            }
            if (isMatched)
            {
                break 
            }
          }
          if(isMatched) break
        }
        isMatched
     }
   }) "Yes" else "No")
  }
}

Measured memory_bytes: 29964
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		
		// 計算
		int result = 0;
		for(int i = 1; i <= x; i++){
		    if(360*i%x == 0){
		        result = 360*i/x;
		        break;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 25304
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s,t;cin>>s>>t;
  if(s.size()-t.size()==0){
    REP(i,(int)s.size()){
      cout<<s[i]<<t[i];
    }
    cout<<"\n";
  }else{
    REP(i,(int)t.size()){
      cout<<s[i]<<t[i];
    }
    cout<<s[s.size()-1]<<"\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n;
    cin >> n;
    vector<int> cost(n);
    for(int i = 0; i < n; ++i){
        cin >> cost[i];
    }
    auto remove_duplicates = [&](){
        int i = 0;
        vector<int> cost2;
        while(i < n){
            cost2.push_back(cost[i]);
            int j = i + 1;
            while(j < n && cost[j] == cost[i]){
                j++;
            }
            i = j;
        }
        return cost2;
    };
    cost = remove_duplicates();
    n = (int)cost.size();
    int i = 0;
    vector<pair<int,int>>p;
    while(true){
        while(i + 1 < n && cost[i] >= cost[i + 1]){
            i++;
        }
        if(i + 1 >= n){
            break;
        }
        int j = i + 1;
        while(j < n && cost[j] > cost[j - 1]){
            j++;
        }
        p.push_back({cost[i], cost[j-1]});
        i = j;
    }
    ll money = 1000;
    for(auto e : p){
        ll count_low = (money/e.first);
        money = money - 1LL * ((money/e.first) * e.first);
        money = money + 1LL * count_low * e.second;
    }
    cout << money << endl;
}

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

    solve();
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
#define MOD 1000000007
#define MOD2 998244353

int flag[26];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    for(int i = 0; i<s.size(); i++) flag[s[i] - 'a']++;
    for(int i = 0; i < 26; i++){
        if(!flag[i]){
            cout << char('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
import io
import os

from collections import Counter, defaultdict, deque


from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 5)


def solve(N, A):
    @lru_cache(maxsize=None)
    def maxProfitAtEnd(i, money, stocks):
        if i == N - 1:
            # Sell all remaining
            return money + stocks * A[i]

        # no op
        best = maxProfitAtEnd(i + 1, money, stocks)
        # sell
        best = max(best, maxProfitAtEnd(i + 1, money + stocks * A[i], 0))
        # buy
        numStock = money // A[i]
        best = max(
            best, maxProfitAtEnd(i + 1, money - numStock * A[i], stocks + numStock)
        )

        return best

    return maxProfitAtEnd(0, 1000, 0)


def solve(N, A):
    money = 1000
    stock = 0
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            # Buy on i
            numStock = money // A[i]
            money -= numStock * A[i]
            stock += numStock
            # Sell on i + 1
            money += stock * A[i + 1]
            stock = 0
    assert stock == 0
    return money


if __name__ == "__main__":
    input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

    (N,) = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = solve(N, A)
    print(ans)


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

using namespace std;

typedef long long ll;

int main(){
  ll n,k;
  cin>>n>>k;
  
  ll ans=k;
  for(int i=1;i<n;i++){
     ans*=(k-1);
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string S;cin>>S;
    int N=S.size();
    bool b=true;
    for(int i=0;i<N;i++){
        if((i+1)%2==0){
            if(S[i]!='L'&&S[i]!='U'&&S[i]!='D'){
                b=false;
                break;
            }
        }
        else {
            if(S[i]!='R'&&S[i]!='U'&&S[i]!='D'){
                b=false;
                break;
            }
        }
    }
    if(b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define F(i,x,y) for(int i=x;i<=y;++i)
using namespace std;
int d[2010][2010],c[2015],n,x,y,l;
int main(){
	scanf("%d%d%d",&n,&x,&y);
	l=abs(x-y)-1;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			d[i][j]=abs(i-j);
		}
	}
	for(int i=1;i<n;++i){
		for(int j=i+1;j<=n;++j){
			if(d[i][j]>d[i][x]+d[y][j]+1)d[i][j]=d[i][x]+1+d[y][j];
			++c[d[i][j]];
		}
	}
	for(int i=1;i<n;++i){
		printf("%d\n",c[i]);
	}
	return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  cin >> n;

  vector<int> v(n);

  REP (i, n) {
    cin >> v[i];
  }

  sort(v.begin(), v.end());

  LL ans = 0;
  REP (i, n - 1) ans += v[i];

  ans += v[n - 1] / 2;

  cout << ans << endl;
}


Measured memory_bytes: 256
n, t = gets.split.map(&:to_i)
costs = []
times = []
n.times do
  cost, time = gets.split.map(&:to_i)
  costs.push(cost)
  times.push(time)
end

indexs = []
times.each_with_index do |time , i|
  if time <= t
    indexs.push(i)
  end
end

newCosts = []
indexs.each do |i|
  newCosts.push(costs[i])
end

if indexs.size < 1
  puts "TLE"
  exit
else
  puts newCosts.min
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main() {
  int n, s;
  while (cin >> n >> s) {
    if (n == 0 && s == 0) break;
    int ans = 0;
    for (int i = 0; i < 1024; i++) {
      int a = 0, b = 0;
      for (int j = 0; j < 10; j++)
        if ((i >> j) & 1) {
          a += j;
          b++;
        }
      if (a == s && b == n) ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define LL long long
using namespace std;
 
int main(){
    LL a, b;
    cin >> a >> b;
    if((a + b) % 2 == 0){
		cout << (a + b) / 2 << endl;
    }
    else{
		cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int res = 0;
    res += (A>B) ? B : A;
    res += (C>D) ? D : C;
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstring>
#include <chrono>
#include <cassert>

//#pragma GCC optimize("Ofast,unroll-loops,fast-math,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define pii pair<int, int>
#define mp make_pair
#define hash hash228
const int SZ = 2e5 + 4;
const int inf = 2e9;
int hashpow = 41;
int mod = 1e9 + 7;

int n;
int a[SZ];

int parse(string& s) {
    int p = -1;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '.') {
            p = i;
            break;
        }
    }
    if (p == -1) return stoll(s) * 10000000000;
    string a = s.substr(0, p);
    string b = s.substr(p + 1);
    while (b.size() < 10) {
        b.push_back('0');
    }
    int c = stoll(a) * 10000000000;
    int d = stoll(b);
    return c + d;
}

inline void read() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string b;
        cin >> b;
        a[i] = parse(b);
    }
}

inline void solve() {
    vector<vector<int>> suf(64, vector<int>(64));
    int ans = 0;
    vector<pii> t;
    for (int i = 0; i < n; ++i) {
        int p2 = 0, p5 = 0;
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            ++p2;
        }
        while (a[i] % 5 == 0) {
            a[i] /= 5;
            ++p5;
        }

        if (20 - p2 <= p2 && 20 - p5 <= p5) {
            --ans;
        }
        ++suf[p2][p5];
        t.emplace_back(p2, p5);
    }

    for (int i = 62; i >= 0; --i) {
        for (int j = 62; j >= 0; --j) {
            suf[i][j] = suf[i][j] + suf[i + 1][j] + suf[i][j + 1] - suf[i + 1][j + 1];
        }
    }

    for (int i = 0; i < n; ++i) {
        auto [u, v] = t[i];
        ans += suf[max(20 - u, 0ll)][max(0ll, 20 - v)];
    }

    cout << ans / 2 << "\n";
}

int32_t main() {
#ifdef _LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 8936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
#define allsort(X) sort(X.begin(),X.end())

typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;





ll i,j,k;


int main(){
    ll l,r,d;
    cin>>l>>r>>d;
    ll ans=0;
    for(ll i=l;i<=r;i++)if(i%d==0)ans++;
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main()
{
    char s[100];
    scanf("%s", s);
    if (strcmp(s, "AAA") == 0 || strcmp(s, "BBB") == 0) {
      printf("No");
    } else {
      printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n:usize,
        h:[i64;n],
    }
    let mut ans=0;
    let mut c=0;
    for i in h {
        if i > c {
            ans+=i-c;
        }
        c=i;
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int64_t N;
    cin >> N;
    map<int, int>d;
    for (int i = 1; i <= N; i++) {
        int n;
        cin >> n;
        d[n] = i;
    }

    for (int i=1; i <= N; i++) {
        cout << d[i];
        if (i < N) {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5504
#include<stdio.h>

#define Max 2000000

int h, A[Max + 1];

void maxHeapify(int i){
  int l, r, largest, n;
  l = 2 * i;
  r = 2 * i + 1;

  if(l <= h && A[l] > A[i]) largest = l;
  else largest = i;

  if(r <= h && A[r] > A[largest]) largest = r;

  if(largest != i){
    n = A[i];
    A[i] = A[largest];
    A[largest] = n;

    maxHeapify(largest);
  }
}


int main(){
  int i;
  
  scanf("%d", &h);

  for(i = 1 ; i <= h ; i++) scanf("%d", &A[i]);

  for(i = h / 2 ; i >= 1 ; i--) maxHeapify(i);

  for(i = 1 ; i <= h ; i++){
    printf(" %d", A[i]);
  }
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 3660
import sys
from collections import defaultdict
from copy import deepcopy

input = sys.stdin.readline
N, M = list(map(int, input().split()))

PY = []
for _ in range(M):
    PY.append(list(map(int, input().split())))

sorted_PY = deepcopy(PY)
sorted_PY.sort(key=lambda x: x[1])

p_count_dict = defaultdict(lambda: 0)
y_dict = {}

for py in sorted_PY:
    p_count_dict[py[0]] += 1
    y_dict[py[1]] = p_count_dict[py[0]]

for py in PY:
    # print(f'{py[0]:0>6}{y_dict[py[1]]:0>6}')
    print('{}{}'.format(str(py[0]).zfill(6), str(y_dict[py[1]]).zfill(6)))


Measured memory_bytes: 60792
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W = IL()
p = [[i for i in "#"*(W+2)] for i in range(H+2)]

for i in range(1,H+1):
  s = S()
  for j in range(W):
    p[i][j+1] = s[j]
    
for i in p:
  print("".join(i))

Measured memory_bytes: 21824
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int n, k;
	char s[51];
	scanf("%d %d", &n, &k);
	scanf("%s", s);
	s[k-1] += 'a' - 'A';
	printf("%s", s);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
  	string t;
  	cin>>s;
  	cin>>t;
  	int l1=s.length();
 	int l2=t.length();
  	string temp1=t.substr(0,l1);
  	if(temp1==s){
      cout<<"Yes"<<endl;
    }
  	else
      	cout<<"No"<<endl;
}

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

using namespace std;

typedef long long ll;

const int N = 200100;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    int k;
    cin >> s >> k;
    set<string> kek;
    for (size_t i = 0; i < s.length(); ++i) {
        string t = "";
        for (size_t j = i; j < min(s.length(), i + 6); ++j) {
            t += s[j];
            kek.insert(t);
        }
    }
    for (int i = 1; i < k; ++i) {
        kek.erase(kek.begin());
    }
    cout << *kek.begin();
    return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(((a+b)==c)||((a+c)==b)||((b+c)==a))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file(){
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
#else 
#endif
}
void fast(){
	std::ios_base::sync_with_stdio(0); cin.tie(NULL);
}
int main()
{

	fast();
	string x;
	cin >> x;
	for (int i = 0; i < x.size(); i++){
		if (i % 2 == 0)
			cout << x[i];
	}
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>

#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

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

int main() {
    fastio;
    int n;
    cin >> n;

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 2 == 1) {
            int cnt_ = div(i);
            if (cnt_ == 8)
                cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] arg)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    //String = データの型。主に文字列を扱う。
        String str = br.readLine();

        //今回はdouble型に変換
        double r = Double.parseDouble(str);

        double menseki	=(double)r * (double)r * 3.141592653589;	//menseki(半径[r]*半径[r]*π)
		double ensyu	=(double)2 * 3.141592653589 * (double)r;	//ensyu(2*π*半径[r])

		 /*今回は桁数出すためprintfを使用
		  * % = 文字表示用
		  * d = 10進数の整数
		  * %d = 10進数の整数を文字表示、みたいな使い方
		  * .6で小数点以下を6桁表示してる
		  * \nは改行用
		  */
		 System.out.printf("%.6f %.6f\n", menseki, ensyu);
    }
}

Measured memory_bytes: 16976
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N, M; cin >> N >> M;
    vector<ll> X(N), Y(N), Z(N);
    REP(i, 0, N) cin >> X[i] >> Y[i] >> Z[i];

    ll ans = 0;
    for (int bit = 0; bit < (1 << 3); bit++) {
        vector<ll> V(N);
        REP(i, 0, N) {
            V[i] += ((bit & 1) ? -X[i] : X[i]);
            V[i] += ((bit & 2) ? -Y[i] : Y[i]);
            V[i] += ((bit & 4) ? -Z[i] : Z[i]);
        }
        sort(ALL(V), greater<>());

        ll total = 0;
        REP(i, 0, M) total += V[i];
        ans = max(ans, total);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
N,M = map(int, input().split())

a_list = list(map(int, input().split()))
bc_list = []
for i in range(M):
    bc_list.append(list(map(int, input().split())))


bc_list

from collections import Counter
nums_dict = dict(Counter(a_list))

for bc in bc_list:
    b = bc[0]
    c = bc[1]
    if c in nums_dict:
        nums_dict[c] += b
    else:
        nums_dict[c] = b

cnt = N
goukei = 0
for k, v in sorted(nums_dict.items(), key=lambda x: -x[0]):
    if cnt >= v:
        goukei += k*v
        cnt -= v
    elif cnt < v:
        goukei += k*cnt
        cnt = 0
    if cnt == 0:
        break
print(goukei)

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

int main() {
int n;
cin >> n;
long ans = 0;
for(int i = 1; i<=n; i++){
  if(i%5 != 0 && i%3 != 0){
    ans += i;
  }
}
cout << ans << endl;

}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 1,  1, 0,  0, 0, -1, -1, -1};
const vector<int> dy = {1, 0, -1, 1, -1, 0,  1,  0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
int main(){
    int n;
    cin >> n;
    string s;
    rep(i, 0, n){
        s += 'A';
        s += 'C';
        s += 'L';
    }
    cout << s << endl;
}

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

int main(){
  int n,i,j,cur,ans;
  cin >> n;
  vector<int> edge(110,0);
  for(i=1; i<=min(n,9); i++){
    edge[i*11]++;
  }
  for(i=11; i<=min(n,99); i++){
    edge[(i/10)*10+i%10]++;
  }
  for(i=101; i<=min(n,999); i++){
    edge[(i/100)*10+i%10]++;
  }
  for(i=1001; i<=min(n,9999); i++){
    edge[(i/1000)*10+i%10]++;
  }
  for(i=10001; i<=min(n,99999); i++){
    edge[(i/10000)*10+i%10]++;
  }
  for(i=100001; i<=min(n,999999); i++){
    edge[(i/100000)*10+i%10]++;
  }
  
  ans=0;
  
  for(i=1; i<=9; i++){
    for(j=1; j<=9; j++){
      ans+=edge[i*10+j]*edge[j*10+i];
    }
  }
  cout << ans;

}

Measured memory_bytes: 256
a = int(input()) # 500
b = int(input()) # 100
c = int(input()) # 50
x = int(input())


ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      t = 500 * i + 100 * j + 50 * k
      if t == x:
        ans += 1
print(ans)

Measured memory_bytes: 39664
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<char>;
using vvec = vector<vec>;
// " ", ' '
// std::string str;
// str = std::to_string(int i);
// bitset<3> s(N);

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string S, ans; cin >> S;
	int lg = S.size();
	ans = "Yes";

	rep(i, lg) {
		int l = i * 2;
		if(l >= lg) break;
		if (S.at(l) != 'R' && S.at(l) != 'U' && S.at(l) != 'D')  ans = "No";

		int k = i * 2 + 1;
		if(k >= lg) break;
		if(S.at(k) != 'L' && S.at(k) != 'U' && S.at(k) != 'D')  ans = "No";
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct State{
    int at;
    ll cost;
    State(int a, ll c) : at(a), cost(c){}
    bool operator>(const State& s) const{
        return cost > s.cost;
    }
};

struct Edge{
    int to;
    ll cost;
    Edge(int t, ll c) : to(t), cost(c){}
};

using Graph = vector<vector<Edge> >;
const ll INF = 1e15;

vector<int> pre;

void dijkstra(int s, const Graph& G, vector<ll>& minc){
    minc.assign(G.size(), INF);
	pre.assign(G.size(), -1);
    priority_queue<State, vector<State>, greater<State> > pq;
    pq.emplace(s, 0);
    minc[s] = 0;
    while(!pq.empty()){
        State cur = pq.top();
        pq.pop();
        if(minc[cur.at] < cur.cost) continue;
        for(const Edge& e : G[cur.at]){
            ll cost = cur.cost + e.cost;
            if(minc[e.to] <= cost) continue;
            minc[e.to] = cost;
            pq.emplace(e.to, cost);
			pre[e.to] = cur.at;
        }
    }
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	Graph g(n);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].emplace_back(b, 1);
		g[b].emplace_back(a, 1);
	}
	vector<ll> dist;
	dijkstra(0, g, dist);
	cout << "Yes" << endl;
	for(int i = 1; i < n; ++i){
		cout << pre[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 19144