akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){ T x; cin >> x; return (x); }
template<typename T=ll,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return x; }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

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

	auto D=in();
	auto C=vecin(26);
	vvll S(D,vll(26));
	REP(i,D){
		REP(j,26) S[i][j]=in();
	}
	vll L(26,0);
	vll H;

	ll A=0;
	REP(i,D){
		ll d=i+1;
		ll maxB=-(1ll<<60),index=-1;
		REP(t,26){
			ll B=0;
			B += S[i][t];
			//L[T[i]-1] = d;
			REP(j,26){
				if(t!=j){
					B -= C[j]*(d-L[j]);
				}
			}
			if(B>maxB){
				maxB = B;
				index=t;
			}
		}
		A+=maxB;
		H.push_back(index+1);
		//out(A);
	}

	for(auto& x:H) out(x);
	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
int main(){
	int a=0,b=0,c=0,d=0;
	std::cin>>a>>b>>c>>d;
	int n=a+b+c+d;
	int x=n/60;
	int y=n-x*60;
	std::cout<<x<<std::endl;
	std::cout<<y<<std::endl;
	return 0;
}

Measured memory_bytes: 3096
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;		

boost::optional<std::vector<std::set<index_t>>> run(std::string const& str)
{
	auto N = str.size();
	if (str.back() != '0' || str.front() != '1')
	{
		return boost::none;
	}
	std::vector<std::set<index_t>> ret(N);
	for (index_t i : boost::irange<index_t>(0, N - 1))
	{
		if (str[i] != str[N - 2 - i])
		{
			return boost::none;
		}
	}
	index_t last = 0;
	for (auto i : boost::irange<index_t>(1, N - 1))
	{
		if (str[i] == '1')
		{
			for (auto s : boost::irange(last, i))
			{
				ret[s].emplace(i);
			}
			last = i;
		}
	}
	ret[N - 2].emplace(N - 1);
	return ret;
}

void Main()
{
	std::string str;
	std::cin >> str;
	auto result = run(str);
	if (result)
	{
		for (auto i : boost::irange<index_t>(0, str.size()))
		{
			for (auto n : result->at(i))
			{
				std::cout << i + 1 << " " << n + 1 << std::endl;
			}
		}
	}
	else
	{
		std::cout << -1 << std::endl;
	}
}

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

Measured memory_bytes: 10960
N = int(input())
List = [0 for i in range(N)]
for i in range(N):
    List[i] = [x for x in input().split()]

ans = 0
for i in range(N):
    if List[i][1] == "JPY":
        ans += int(List[i][0])
    else:
        ans += float(List[i][0])*380000

print(ans)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	c := n / (a + b)
	d := n % (a + b)
	if d <= a {
		fmt.Println(c*a + d)
	} else {
		fmt.Println(c*a + a)
	}

}


Measured memory_bytes: 512
#!/usr/bin/env python3

import decimal
import math


def prod_floor(a, b):
    return math.floor(a * b)


def main():
    decimal.getcontext().prec = 26
    a, b = (decimal.Decimal(x) for x in input().split())
    res = prod_floor(a, b)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 10072
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define  ll long long
int main(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    ll arr[n];
    for (int i = 0; i < n; ++i) {
        cin>>arr[i];
    }
    ll cur=arr[0],x=0;
    vector<ll>v;
    for (int j = 1; j < n; ++j) {
        if(!x){
            if(arr[j]>arr[j-1])
                v.push_back(cur),cur=arr[j],x=1;
            else
                cur=min(cur,arr[j]);
        }
        else{
            if(arr[j]<arr[j-1])
                v.push_back(cur),cur=arr[j],x=0;
            else
                cur=max(cur,arr[j]);
        }
    }
    v.push_back(cur);
    long long res=1000,mx=1000,st=0;
    for (int k = 0; k < v.size(); ++k) {
        if(k%2==0){
            st=res/v[k];
            res%=v[k];
        }
        else{
            res+=st*v[k];
            st=0;
            mx=max(res,mx);
        }
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N;
    cin >> N;
    ll a[N];
    for(ll i = 0; i < N; i++) cin >> a[i];
    ll ans = 1145148931919810;
    for(ll hugou = 0; hugou < 2; hugou++){
        ll sum = a[0];
        ll tmp = 0;
        if(hugou && a[0] <= 0){
            tmp += -a[0] + 1;
            sum = 1;
        }
        if(!hugou && 0 <= a[0]){
            tmp += a[0] + 1;
            sum = -1;
        }
        for(ll i = 1; i < N; i++){
            if(sum > 0 && sum + a[i] >= 0){
                tmp += abs(-sum - 1 - a[i]);
                sum = -1;
            }else if(sum < 0 && sum + a[i] <= 0){
                tmp += abs(-sum + 1 - a[i]);
                sum = 1;
            }else{
                sum += a[i];
            }
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma warning(disable: 4996)
#include <stdio.h>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;
using ll = long long;

int N, M;



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

	cin >> N >> M;
	int left = 0;
	int right = 100001;
	int l, r;
	for(int i = 1; i <= M; i++) {
		cin >> l >> r;
		left = max(l, left);
		right = min(r, right);
	}

	if(right - left + 1 >= 0)
		cout << (right - left + 1);
	else
		cout << 0;


}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int ans=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            if((j*a[i])+1 <= d){
                ans++;
            }else{
                break;
            }
        }
    }
    cout << ans+x << endl;
}

Measured memory_bytes: 256
//http://drken1215.hatenablog.com/entry/2019/03/21/234900

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    // 入力
    int n, m; cin >> n >> m;
    vector<int> P(m), Y(m);
    for (int i = 0; i < m; ++i) cin >> P[i] >> Y[i], --P[i];
    
    // vals[v] := P[i] = v であるような i についての Y[i] の値を集めたもの
    vector<vector<int> > vals(n);
    for (int i = 0; i < m; ++i) vals[P[i]].push_back(Y[i]);
    
    // 各 p の値に対して
    for (int v = 0; v < n; ++v) {
        sort(vals[v].begin(), vals[v].end());
        
        // 今回は不要だが、通常は数のダブりをなくす
        vals[v].erase(unique(vals[v].begin(), vals[v].end()), vals[v].end());
    }

    // 答え
    for (int i = 0; i < m; ++i) {
        int v = P[i];
        printf("%06d", v + 1);
        
        // 座標圧縮して導いた答え
        int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
    }
}

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


// Modint
struct Mint {
	static const ll mod = (ll)(1e9 + 7);
	ll val;

	Mint() { val = 0; }
	Mint(ll a) { val = a; verify_value(); }

	void verify_value() {
		if (val >= mod) val %= mod;
		if (val < 0) val %= mod, val += mod;
	}

	Mint pow(ll p) const {
		Mint cur = Mint(val), ret = 1;
		while (p > 0) {
			if (p & 1) ret *= cur;
			cur *= cur;
			p >>= 1LL;
		}
		return ret;
	}
	Mint inv() const {
		if (val == 0) cerr << "WARNING: inv() is called with 0." << endl;
		return pow(mod - 2);
	}

	Mint operator+() const { return *this; }
	Mint operator-() const { return Mint(mod - val); }

	Mint operator+=(const Mint &a) {
		val += a.val;
		if (val >= mod) val -= mod;
		return Mint(val);
	}
	Mint operator*=(const Mint &a) {
		val *= a.val;
		if (val >= mod) val %= mod;
		return Mint(val);
	}
	Mint operator-=(const Mint &a) { return *this += -a; }
	Mint operator/=(const Mint &a) { return *this *= a.inv(); }

	Mint operator++() { return *this += Mint(1); }
	Mint operator--() { return *this -= Mint(1); }
	Mint operator++(int) {
		Mint ret = *this;
		++(*this);
		return ret;
	}
	Mint operator--(int) {
		Mint ret = *this;
		--(*this);
		return ret;
	}

	operator ll() const { return val; }
};

Mint operator+(const Mint &a, const Mint &b) {
	ll ret = a.val + b.val;
	if (ret >= Mint::mod) ret -= Mint::mod;
	return Mint(ret);
}
Mint operator*(const Mint &a, const Mint &b) {
	ll ret = a.val * b.val;
	if (ret >= Mint::mod) ret %= Mint::mod;
	return Mint(ret);
}
Mint operator-(const Mint &a, const Mint &b) { return a + (-b); }
Mint operator/(const Mint &a, const Mint &b) { return a * b.inv(); }

ostream &operator<<(ostream &out, const Mint &a) { return out << a.val; }
istream &operator>>(istream &in, Mint &a) {
	in >> a.val;
	a.verify_value();
	return in;
}

Mint pow(Mint a, ll b) {
	return a.pow(b);
}

int main() {
	int n, m; cin >> n >> m;
	set<int> s;
	for (int i = 0; i < m; i++) {
		int a; cin >> a;
		s.insert(a);
	}
	vector<Mint> dp(n + 3);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		if (s.count(i)) continue;
		dp[i + 1] += dp[i];
		dp[i + 2] += dp[i];
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 5760
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	 	// 整数の入力
	 	int A = sc.nextInt();
		int P = sc.nextInt();
      	
      int res = (3 * A + P) / 2;
      System.out.println(res);
	}
}

Measured memory_bytes: 25172
import string
from itertools import permutations
S = input()

#%%
def next_permutation(a):
    """Generate the lexicographically next permutation inplace.

    https://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order
    Return false if there is no next permutation.
    """
    # Find the largest index i such that a[i] < a[i + 1]. If no such
    # index exists, the permutation is the last permutation
    for i in reversed(range(len(a) - 1)):
     if a[i] < a[i + 1]:
      break # found
    else: # no break: not found
     return False # no next permutation

    # Find the largest index j greater than i such that a[i] < a[j]
    j = next(j for j in reversed(range(i + 1, len(a))) if a[i] < a[j])

    # Swap the value of a[i] with that of a[j]
    a[i], a[j] = a[j], a[i]

    # Reverse sequence from a[i + 1] up to and including the final element a[n]
    a[i + 1:] = reversed(a[i + 1:])
    return True

#%%
alphabet = set(string.ascii_lowercase)

if len(S) < 26:
    s_diff = alphabet.difference(set(S))
    ans = S + min(s_diff)
elif S == "zyxwvutsrqponmlkjihgfedcba":
    ans = -1
else:
    T = list(S)
    next_permutation(T)
    ans = ''
    for i in range(len(S)):
        ans += T[i]
        if S[i] < T[i]:
            break

print(ans)


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

int main(){
    FAST
    string s; cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        cout << "x";
    }
    return 0;
}


Measured memory_bytes: 3644
while True:
    n,k = map(int, input().split())
    if n==0 and k==0:
        break

    a = [0]*n
    for i in range(n):
        a[i] = int(input())

    s = [0]*(n+1)
    for i in range(n):
        s[i+1] = s[i] + a[i]
    
    ans = -float('inf')
    for i in range(n-k+1):
        ans = max(ans,s[k+i]-s[i])
    print(ans)


Measured memory_bytes: 13324
#include <stdio.h>
int main(void)
{
	int i, m, f, r;
	for (;;)
	{
		scanf("%d%d%d", &m, &f, &r);

		if (m==f && f==r && r==-1)
		{
			break ;
		}
		else if (m==-1 || f==-1)
		{
			printf("F\n");
		}
		else if (m+f>=80)
		{
			printf("A\n");
		}
		else if (m+f>=65 && m+f<80)
		{
			printf("B\n");
		}
		else if (m+f>=50 && m+f<65)
		{
			printf("C\n");
		}
		else if (m+f>=30 && m+f<50)
		{
			if (r>=50)
			{
				printf("C\n");
			}
			else
				printf("D\n");
		}
		else printf("F\n");

	}
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    vi v(n);
    rep(i,n)cin>>v[i];
    rep(i,n){
        ll l=0,r=0;
        for(int j=i;j<n;j++){
            if(v[i]>v[j])l++;
        }
        for(int j=0;j<n;j++){
            if(v[i]>v[j])r++;
        }
        ans+=l*k;
        ans%=MOD;
        ans+=r*((k*k%MOD-k*(k+1)/2%MOD+MOD)%MOD)%MOD;
        ans%=MOD;
    }
    fin(ans);
}

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

int main(){
    long N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    long pass_sum=0;
    long pass_f_sum=0;
    for(int i=0; i<N; i++){
        if(S[i]=='a'){
            if(pass_sum<(A+B)){
                cout << "Yes" << endl;
                pass_sum++;
            }
            else{
                cout << "No" << endl;
            }
        }
        else if(S[i]=='b'){
            if(pass_sum<(A+B)){
                if(pass_f_sum<B){
                    cout << "Yes" << endl;
                    pass_f_sum++;
                    pass_sum++;
                }
                else{
                    cout << "No" << endl;
                }
            }
            else{
                cout << "No" << endl;
            }
        }
        else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 896
n,t = map(int,input().split())
list1 = [list(map(int,input().split())) for i in range(n) ]
mintime = 10**9
for i in range(n):
    if list1[i][1] <= t:
        mintime = min(mintime,list1[i][0])

if mintime == 10**9:
    print("TLE")
else:
    print(mintime)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define N 500003
#define MOD 1000000007
#define int long long
using namespace std;




signed main()
{
    int n,m;
    cin>>n>>m;
    char a[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    int dp[n][m];
    int f=0;
    for(int i=0;i<n;i++){
        if(a[i][0]=='#'){
            f=1;
        }
        if(f==1){
            dp[i][0]=0;
        }
        else{
            dp[i][0]=1;
        }
    }
    f=0;
     for(int i=0;i<m;i++){
        if(a[0][i]=='#'){
            f=1;
        }
        if(f==1){
            dp[0][i]=0;
        }
        else{
            dp[0][i]=1;
        }
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(a[i][j]!='#')
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
            else{
                dp[i][j]=0;
            }
          //  cout<<dp[i][j]<<" ";
        }
       // cout<<endl;
    }

    cout<<dp[n-1][m-1];

}


Measured memory_bytes: 9088
import bisect
N, Q = map(int, input().split())
S = input()
lis = []
for i in range(len(S) - 1):
  if S[i] == "A" and S[i + 1] == "C":
    lis.append(i + 1)
for _ in range(Q):
  l, r = map(int, input().split())
  ko = bisect.bisect_left(lis, l)
  kk = bisect.bisect_left(lis, r)
  print(kk - ko)

Measured memory_bytes: 5724
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,c,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,sub;
    ll h,w;
    cin>>str;
    string key="keyence";
    for(ll i=1;i<7;i++){
        sub=str.substr(0,i);
        sub+=str.substr(str.length()-7+i);
        //cout<<sub<<endl;
        if(sub==key){
            cout<<"YES"<<endl;
            return 0;
            }
    }
    sub=str.substr(str.length()-7);
    if(sub==key) cout<<"YES"<<endl;

    else cout<<"NO"<<endl;


    


    return 0;
}


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

int n,m,a,b,d[200200];
vector<int> G[200200];

void pr(int a, int b){ printf("%d %d\n", a, b); }
void dfs(int v, int p){
    d[v]++;
    for(int nv : G[v]){
        if(nv == p) continue;
        if(d[nv]){
            if(v < nv) pr(v,nv), d[v]++;
        }
        else dfs(nv,v);
    }
    if(p){
        if(d[v]%2) pr(p,v), d[p]++;
        else pr(v,p), d[v]++;
    }
}

int main(){
    scanf("%d %d", &n, &m);
    if(m%2) printf("%d\n", -1);
    else{
        while(m--){
            scanf("%d %d", &a, &b);
            G[a].pb(b); G[b].pb(a);
        }
    dfs(1,0);
    }
}

Measured memory_bytes: 18272
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#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__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

double DegreesToRadians( double degrees )
{ 
    return degrees * M_PI / 180; 
} 

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

	int a,b,h,m;

	cin >> a >> b >> h >> m;
	h += m / 60;
	m = m % 60;

	double posA = ((h%12) * 5 + 1.0*m / 12);
	double posB = 1.0*m;

	double grad1 = DegreesToRadians(1.0*posA * 6);
	double grad2 = DegreesToRadians(1.0*posB * 6);

	double cs = cos(1.0*grad1 - grad2);

	double res = sqrt(1.0*a*a + b*b - 2*a*b*cs);

	cout << fixed << setprecision(12) << res;


    return 0;
}


Measured memory_bytes: 4060
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#define f first
#define s second
#define fore(i,a,b) for(lli i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
    string a; cin >> a;
    lli sum=0;
    fore(i,0,sz(a))
    {
      sum+=a[i]-'0';
    }
    if(sum%9==0)
    {
      cout << "Yes" <<ENDL;
    }
    else
    {
      cout << "No" <<ENDL;
    }
    return 0;
}


Measured memory_bytes: 3724
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
# a < b < c とすると、2式は必ず成立し、c < a + b のみ考慮すれば良い
# つまり　b < c < a + b
# c < a + b の境界部の発見に2分探索を利用する
for i in range(n - 1):
    for j in range(i + 1, n):
        k = bisect.bisect_left(l, l[i] + l[j])
        ans += k - (j + 1)
print(ans)

Measured memory_bytes: 3188
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def do():
    ans=0
    n=INT()
    s=factorization(n)
    for a,b in s:
        temp=0
        for i in range(10):
            temp+=(i+1)
            #print(a,b,temp,ans)
            if temp<=b:
                ans+=1
            else:
                break
    if n==1:
        ans=0
    
    print(ans)

                
if __name__ == '__main__':
    do()

Measured memory_bytes: 9516
{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [n, m] <- readInts
  as <- readInts
  putStrLn $ solve n m as

solve n m as = if foldl' (\a x -> if 4 * m * x >= totalvotes then a + 1 else a) 0 as >= m
  then "Yes"
  else "No"
  where
    totalvotes = sum as

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

Measured memory_bytes: 508
#
# abc088 a
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2018
218"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2763
0"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """37
514"""
        output = """Yes"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = int(input())
    if N % 500 <= A:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16232
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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;
}
int main(){
    ll n;cin >> n;
    vl v(n),check;
    rep(i,n)cin >> v[i];
    rep(bit,1<<n){
        ll sum=0;
        rep(i,n){
            if(bit&(1<<i))sum+=v[i];
        }
        check.pb(sum);
    }
    sort(all(check));
    ll m;cin >> m;
    rep(i,m){
        ll key;cin >> key;
        if(binary_search(all(check),key))cout << "yes" <<endl;
        else cout << "no" <<endl;
    }
}



Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <cstdio>

using namespace std;

int main()
{
    int n, x[110], y[110], h[110], ax, ay, ah, num, h1;
    cin>>n;
    for (int i=0; i<n; i++) cin>>x[i]>>y[i]>>h[i];
    for (int i=0; i<=100; i++) //cx
    {
        for (int j=0; j<=100; j++) //cy
        {
            for (int k=0; k<n; k++) if (h[k]>0) num=k;
            h1=h[num]+abs(x[num]-i)+abs(y[num]-j);
            bool ans=true;
            for (int k=0; k<n; k++)
            {
                if (max(0, h1-abs(x[k]-i)-abs(y[k]-j))!=h[k]) ans=false;
            }
            if (ans) { ax=i; ay=j; ah=h1; }
        }
    }
    cout<<ax<<' '<<ay<<' '<<ah<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}
map<char,int> a;

void solve() {
    ll n;
    cin >> n;
    ll p = n;
    ll dig = 0;
    while(p != 0){
        dig+=p%10;
        p/=10;
    }
    if(n%dig == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int H, W, N;
  cin >> H >> W >> N;
  int count;
  if (N % max(H, W) == 0) {
    count = N / max(H, W);  
  }
  else {
    count = N / max(H, W) + 1;
  }
  cout << count;
}

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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
    IOS;

    int n,x,t;
    cin >> n >> x >> t;
    cout << ((n/x)+(n%x>0))*t << endl;
    return 0;    
}

Measured memory_bytes: 3608
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

a,b=map(int, input().split())

print(int((((a * 3) + b )/ 2)))

Measured memory_bytes: 21576
from sys import stdin
n, m = map(int, stdin.readline().split())
G = [-1] * n
def root(x):
    if G[x] < 0: return x
    G[x] = root(G[x])
    return G[x]
def uniteSet(x, y):
    x = root(x)
    y = root(y)
    if x == y : return
    if G[x] > G[y] : x, y = y, x
    G[y] = x
findSet = lambda x, y: root(x) == root(y)
for i in range(0, m):
    s, t = map(int, stdin.readline().split())
    uniteSet(s, t)
q = int(stdin.readline())
for i in range(0, q):
    s, t = map(int, stdin.readline().split())
    print("yes" if findSet(s, t) else "no")

Measured memory_bytes: 9912
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
bool check(ll d, vector<ll> &a, ll k, ll n){

    vector<ll> md(n);
    rep(i, n){
        md[i] = a[i] % d;
    }

    sort(all(md));

    vector<ll> suml(n + 1, 0);
    vector<ll> sumr(n + 1, 0);

    rep(i, n){
        suml[i + 1] = suml[i] + md[i];
    }

    reverse(all(md));

    rep(i, n){
        sumr[i + 1] = sumr[i] + (d - md[i]);
    }

    reverse(all(sumr));

    ll best = 1e9;

    rep(i, n + 1){
        if(suml[i] != sumr[i]) continue;
        best = min(best, suml[i]);
    }

    return best <= k;
}
int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll total = 0;
    rep(i, n){
        cin >> a[i];
        total += a[i];
    }
    ll ans = 0;
    for(ll i = 1; i * i <= total; i++){
        if(total % i == 0){
            if(check(i, a, k, n)){
                ans = max(ans, i);
            }
            if(check(total / i, a, k, n)){
                ans = max(ans, total / i);
            }
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
p1 = list(map(int, input().split()))
p2 = list(map(int, input().split()))
p3 = list(map(int, input().split()))


len1 = ((p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2) ** 0.5
len2 = ((p2[0] - p3[0]) ** 2 + (p2[1] - p3[1]) ** 2) ** 0.5
len3 = ((p3[0] - p1[0]) ** 2 + (p3[1] - p1[1]) ** 2) ** 0.5

l = (len1 + len2 + len3) / 2
s = (l * (l - len1) * (l - len2) * (l - len3)) ** 0.5
r = 2 * s /(len1 + len2 + len3)

def solve(mid):
    return (1 - mid / r) * max(len1, len2, len3) >= 2 * mid

ok = 0
ng = 10 ** 9
cnt = 0
while True:
    mid = (ok + ng) / 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
    cnt += 1
    if cnt > 60:
        break
print(ok)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using p = pair<int, int>;

vector<string> t[4];
vector<string> s;
vector<p> memo[4];
vector<int> h, w;
int n;

bool solve();
bool isblock(p now, int id) {
  return now.fi >= 0 && now.fi < h[id] && now.se >= 0 &&
         now.se < w[id] && t[id][now.fi][now.se] == '#';
}
bool isvalid(p now) {
  return now.fi >= 0 && now.fi < 4 && now.se >= 0 &&
         now.se < 10 && s[now.fi][now.se] == '.';
}
void prepair();

int main() {
  h.resize(4);
  w.resize(4);
  for(int i = 0; i < 4; ++i) {
    cin >> h[i] >> w[i];
    t[i].resize(h[i]);
    for(int j = 0; j < h[i]; ++j) cin >> t[i][j];
  }
  prepair();
  cin >> n;
  for(int i = 0; i < n; ++i) {
    s.resize(4);
    for(int j = 0; j < 4; ++j) cin >> s[j];
    if(solve())
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

void prepair() {
  int d[4] = {0, 1, 0, -1};
  for(int i = 0; i < 4; ++i) {
    for(int y = 0; y < w[i]; ++y)
      if(t[i][0][y] == '#') {
        queue<p> qu;
        qu.push({0, y});
        t[i][0][y] = '.';
        while(!qu.empty()) {
          p now = qu.front();
          qu.pop();
          memo[i].push_back({now.fi, now.se - y});
          for(int j = 0; j < 4; ++j) {
            p nextp = now;
            nextp.fi += d[j];
            nextp.se += d[j ^ 1];
            if(isblock(nextp, i)) {
              t[i][nextp.fi][nextp.se] = '.';
              qu.push(nextp);
            }
          }
        }
        break;
      }
  }
}

bool solve() {
  vector<int> perm(4);
  for(int i = 0; i < 4; ++i) perm[i] = i;
  do {
    vector<p> lst;
    int id = 0;
    bool ch = 1;
    for(int i = 0; i < 4; ++i)
      if(ch)
        for(int j = 0; j < 10; ++j)
          if(ch)
            if(s[i][j] == '.') {
              for(int k = 0; k < 4; ++k) {
                p nowb = {i + memo[perm[id]][k].fi,
                          j + memo[perm[id]][k].se};
                if(isvalid(nowb)) {
                  lst.push_back(nowb);
                  s[nowb.fi][nowb.se] = '#';
                }
                else
                  ch = 0;
              }
              ++id;
            }
    if(id == 3 && ch)
      return 1;
    else
      for(int i = 0; i < lst.size(); ++i)
        s[lst[i].fi][lst[i].se] = '.';
  } while(next_permutation(perm.begin(), perm.end()));
  return 0;
}


Measured memory_bytes: 3220
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};


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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define MAX_COUNT 1000000 + 1

vector<bool> prime_number(LL n){
	vector<bool> res(n + 1);
	for(LL i = 2; n >=  i * i; i++){
		if(res[i]  == false){
			for(LL j = i + i; n >= j; j += i){
				res[j] = true;
			}
		}
	}
	return res;
}


int main(int argc, char const *argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, x;
	vector<bool> primes = prime_number(1000000);
	while(true){
		cin >> n >> x;
		if(n == 0 && x == 0) break;
		vector<vector<bool> >  dp(n + 1, vector<bool>(x + 1));
		VI items(n);
		REP(i, n){
			cin >> items[i];
		}
		dp[0][0] = true;
		REP(i, n){
			REP(j, x + 1){
				int item_value = items[i];
				int v = item_value + j;

				if(dp[i][j]){
					dp[i + 1][j] = true;
					if(v < x + 1)
						dp[i][v] = true;
				}
			}
		}
		int ans = -1;

		for(int i = x; i >= 0; i--){
			if(dp[n][i] && !primes[i]){
				ans = i;
				break;
			}
		}
		if(ans > 0){
			cout <<ans << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  char a[n][m];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      int c=0;
      int d=0;
      for(int k=0;k<m;k++){
        if(a[i][k]=='#'){
          c++;
        }
      }
      for(int l=0;l<n;l++){
        if(a[l][j]=='#'){
          d++;
        }
      }
      if(c==0||d==0){
        a[i][j]='2';
      }
    }
  }
  for(int i=0;i<n;i++){
    int count=0;
    for(int j=0;j<m;j++){
      if(a[i][j]!='2'){
        cout << a[i][j];
        count++;
      }
    }
    if(count!=0){
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
from math import pi, sin, cos, sqrt

a, b, h, m = map(int, input().split())

hour = h + m / 60
long_rad = -(2 * pi * m / 60) + pi / 2
short_rad = -(2 * pi * hour / 12) + pi / 2

long_pos = [b * cos(long_rad), b * sin(long_rad)]
short_pos = [a * cos(short_rad), a * sin(short_rad)]
distance = sqrt(((long_pos[0] - short_pos[0])**2 + (long_pos[1] - short_pos[1])**2))
print(distance)


Measured memory_bytes: 62464
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, n, k, x,l,r;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> va;
    vector<ll> co;

    cin  >> s;

    rep(i,s.size()) {
        if(i%2==0){
            if(s[i] != 'h') sans = "No";
        }
        else{
            if(s[i] != 'i') sans = "No";
        }
    }

    if(s.size()%2 == 1) sans = "No";


    // std::cout << ans << endl; 
    std::cout << sans << endl; 
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    solve();
    // stop
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	long long int a, b, k;
	scanf("%lld%lld%lld", &a, &b, &k);
	if (k <= a) {
		printf("%lld %lld", a - k, b);
	}
	else if (k <= a + b) {
		printf("%d %lld", 0, b - (k - a));
	}
	else {
		printf("%d %d", 0, 0);
	}
	return 0;
}

Measured memory_bytes: 128
A = input()
st = [(0, 0, -1)]
cur = 0; ma = 0
for i, a in enumerate(A):
    if a == '/':
        cur += 1
        s = 0
        while st and st[-1][0] == cur-1 and cur <= ma:
            lev, su, j = st.pop()
            s += su
        if st and st[-1][0] == cur:
            s += i - st[-1][2] - 1
        ma = max(ma, cur)
        st.append((cur, s, i))
    elif a == '\\':
        cur -= 1
        st.append((cur, 0, i))
    elif a == '_':
        st.append((cur, 0, i))
ans = []
for lev, su, j in st:
    if su > 0:
        ans.append(su)
print(sum(ans))
print(len(ans), *ans)


Measured memory_bytes: 8284
Manhattan(a,b,c,d) = abs(a-c)+abs(b-d)

function main()
  
  (N,M) = map(x -> parse(Int,x), split(readline()))
  
  a = zeros(Int,N)
  b = zeros(Int,N)
  c = zeros(Int,M)
  d = zeros(Int,M)
  
  for i in 1:N
    (a[i],b[i]) = map(x -> parse(Int,x), split(readline()))
  end
  
  for i in 1:M
    (c[i],d[i]) = map(x -> parse(Int,x), split(readline()))
  end
  
  for i in 1:N
    
    point = 10^10
    ans = 10^10
    
    for j in 1:M
      if point > Manhattan(a[i],b[i],c[j],d[j])
        point = Manhattan(a[i],b[i],c[j],d[j])
        ans = j
      end
    end
    
    println(ans)
  
  end
  
end

main()

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

int main() {
  long double n;
  cin >>n;
  n=2.0*n*3.141592653589;
  cout << n;
}

Measured memory_bytes: 3796
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<cstring>
#define For(i,j,k)	for(ll i=j;i<=k;++i)
#define Dow(i,j,k)	for(ll i=k;i>=j;--i)
#define maxm 10011
#define maxn 511
#define pb push_back
#define ll unsigned long long
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9')	{c=getchar();}
	while(c<='9'&&c>='0')	t=t*10+c-48,c=getchar();
	return t*f;
}
int a[15],f[15][3],n;
int main(){
	n=read();
	For(i,1,n)
		a[i]=read();
	f[0][1]=1;
	For(i,1,n)
		for (int j=a[i]-1;j<=a[i]+1;j++)
			for (int k=0;k<2;k++)
				f[i][k&j&1]+=f[i-1][k];
	printf("%d\n",f[n][0]);
}

Measured memory_bytes: 256