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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

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

//---------------------------------------------------------------
//---------------------------------------------------------------

int N;
int64 A[100000], B[100000], S[100000];

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

	cin >> N;
	REP(i, 0, N)	cin >> A[i];
	REP(i, 0, N)	cin >> B[i];

	int64 sub = 0;
	int64 wk;
	int64 mm = 0;
	int mc = 0;
	REP(i, 0, N) {
		wk = A[i] - B[i];
		sub += wk;
		if(wk > 0)		S[i] = wk;
		else if(wk < 0) {
			mc++;						// 足りないのケース数
			mm += (wk * -1);			// 足りない数量（プラス）
		}
	}
	if(sub <= 0) {						// 総数が足りないので不可能
		cout << -1 << endl;
		return 0;
	} else if(mc == 0) {				// 全部足りている
		cout << 0 << endl;
		return 0;
	}
	
	sort(S, S + N, greater<int>());		// 余っているものの大きい順

	int ans = mc;
	REP(i, 0, N) {
		mm -= S[i];
		ans++;
		if(mm <= 0)	break;
	}
	cout << ans << endl;

	return 0;
}


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

int main(){
  int H = 0,A = 0;
  int N = 0;
  bool j = false;
  cin >> H >> N;
  
  for(int i = 0;i < N;i ++){
    cin >> A;
    H -= A;
    if(H <= 0){
      j = true;
      break;
    }
  }
  if(j)cout << "Yes";
  else cout << "No";
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  string sd;
  cin >> sd;
  string t;
  cin >> t;
  
  if(t.length()>sd.length()){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  int isMatched = true;
  for(int i=sd.length()-t.length();i>=0;i--){
    isMatched = true;
    for(int j=0;j<t.length();j++){
      if(sd[j+i]=='?') continue;
      if(sd[j+i]==t[j]) continue;
      isMatched = false;
    }
    if(isMatched){
      sd.replace(i,t.length(),t);
      break;
    }
  }
  if(isMatched){
    for(auto s:sd){
      if(s=='?') cout << "a";
      else cout << s;
    }
    cout << endl;
  }
  else{
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmax(T& a,T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a,T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int n;
    cin >> n;
    int d = n % 10;
    if (d == 3) {
        cout << "bon" << '\n';
    } else if (d == 0 or d == 1 or d == 6 or d == 8) {
        cout << "pon" << '\n';
    } else {
        cout << "hon" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3636
a, b, c = gets.split(" ").map(&:to_i)

def f(a, b, c)
  return a*b*c
end

puts [f(a-a/2, b, c)-f(a/2, b, c),
      f(a, b-b/2, c)-f(a, b/2, c),
      f(a, b, c-c/2)-f(a, b, c/2)].min


Measured memory_bytes: 1916
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B;

int main()
{
  std::cin >> A >> B;

  if( A<= 9 && B <= 9 )
  {
    std::cout << A*B << std::endl;
  }
  else
  {
    std::cout << -1 << std::endl;
  }

  return 0;
}

Measured memory_bytes: 504
N, C, K = gets.split.map(&:to_i)
Ti = []
N.times { Ti << gets.to_i }
Ti.sort!
count = 0

while !Ti.size.zero? do
  bus = []
  bus << Ti.shift
  limit = bus.first + K

  while bus.size < C do
    current = Ti.first

    break unless current
    break if current > limit

    bus << Ti.shift
  end

  count += 1
end

p count

Measured memory_bytes: 4640
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>

using namespace std;

typedef long long int ll;
typedef vector<ll> vl;
typedef vector<string> vs;

#define MAX(a,b) ((a)>(b) ? (a) : (b))
#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define ABS(a) ((a)>0 ? (a) : (a * -1))


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

	if (a.length() > b.length()) {
		cout << "GREATER" << endl;
		return 0;
	}
	if (a.length() < b.length()) {
		cout << "LESS" << endl;
		return 0;
	}
	if (a.length() == b.length()) {
		for (int i = 0; i < a.length(); i++) {
			if(a[i] > b[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
			if(a[i] < b[i]) {
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/**CLICK ss---> ctrl+j**/
#define PI 2.0*acos(0.0)
#define ll              long long int
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define MOD             1000000007
#define mx              123456789
using namespace std;
void solve()
{
    ll n, m, i, j, k, l;
    cin>>n;
    ll a[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    ll cnt=0;
    for(i=0; i<n-2; i++)
    {
        for(j=i+1; j<n-1; j++)
        {
            for(k=j+1; k<n; k++)
            {
                if(((a[i]+a[j])>a[k] && (a[i]+a[k])>a[j] && (a[j]+a[k])>a[i]) && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
                    cnt++;
            }
        }

    }
    cout<<cnt<<endl;
}
int main()
{
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
    int a[26]={0};
    string s;
    cin>>s;
    
    int f=0;
    for(int i=0;i<s.length();i++)a[s[i]-'a']++;
    for(int i=0;i<26;i++){
        if(a[i]>1)f=1;
    }
    if(f==1)cout<<"no";
    else cout<<"yes";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  bool ok = false;
  for (int i = 0; i <= N - 3; i++){
    if (A[i] == B[i] && A[i + 1] == B[i + 1] && A[i + 2] == B[i + 2]){
      ok = true;
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include<stdio.h>
int main(void)
{
	int n,s;
	int i,j,sum,max,min,ave;

	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		sum=0;
		min=1001;
		max=-1;
		for(i=0;i<n;i++)	{
			scanf("%d",&s);
			sum+=s;
			if(max<s)	max=s;
			if(min>s)	min=s;
		}
		ave=(sum-max-min)/(n-2);
		printf("%d\n",ave);
	}

	return 0;
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  constexpr int inf = 1e7;

  int N, M, R; cin >> N >> M >> R;
  vector<int> r(R);
  REP(i, R){
    cin >> r[i];
    --r[i];
  }

  auto g = make_v(N, N, inf);
  REP(i, N) g[i][i] = 0;
      
  REP(i, M){
    int a, b, c; cin >> a >> b >> c;
    --a; --b;
    g[a][b] = g[b][a] = c;
  }

  REP(k, N)REP(i, N)REP(j, N){
    g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  }

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

  int ans = numeric_limits<int>::max();
  do{
    int dis = 0;
    REP(i, R-1) dis += g[r[i]][r[i+1]];

    ans = min(ans, dis);
  }while(next_permutation(r.begin(), r.end()));
  
  cout << ans << endl;

  return 0;
}


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

int main(){
    string s,t,l="";cin>>s>>t;l+=s+s;int ans=0;
    for(int i=0;i<s.size();i++){
        int count=0;
        for(int k=0;k<s.size();k++){
            if(l.at(k+i)==t.at(k)) count++;
        }
        if(count==s.size()){
            ans=count;
            break;
        }
    }
    if(ans==s.size()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  int q;
  cin >> q;
  vector<int> b(q),c(q);
  for(int i=0;i<q;i++) cin >> b[i] >> c[i];

  map<int,ll> mp;
  for(int i=0;i<n;i++){
    auto itr = mp.find(a[i]);
    if(itr == mp.end()){
      mp.insert(make_pair(a[i],1));
    }else{
      mp[a[i]]++;
    }
  }

  ll ans = 0;
  for(int i=0;i<n;i++){
    ans += a[i];
  }

  for(int i=0;i<q;i++){
    ans += (c[i]-b[i])*mp[b[i]];
    mp[c[i]] += mp[b[i]];
    mp[b[i]] = 0;
    cout << ans << endl;
  }
}


Measured memory_bytes: 10132
object Main extends App {
    val in = io.Source.stdin.getLines
    for (s <- in if s != "#") {
        val ss = s.map("hijklmnopuy".contains(_))
        println(ss.tail.foldLeft((0, ss.head)){
            case ((cnt, state), is_right) =>
                (if (is_right == state) cnt else cnt + 1, is_right)
        }._1)
    }
}

Measured memory_bytes: 44884
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
ll c,d,e,f,p,t,ans=0;
 
 
ll h,w,x,y;

void input(void){
    cin>>h>>w>>x>>y;
}
 
void solve(void){
    rep(i,h){
        rep(j,w){
            if((i<y&&j<x)||(i>=y&&j>=x)){
                cout<<0;
            }
            else cout<<1;
        }
        cout<<endl;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 1280
n=int(input())
S=list(map(int,input().split(" ")))
q=int(input())
T=list(map(int,input().split(" ")))

count=0

for i in range(q):
    for j in range(n):
        #print(S[i],T[j])
        if S[j]==T[i]:
            #print("--")
            count+=1
            break
print(count)


Measured memory_bytes: 6548
import statistics
N = int(input())
a = list(map(int, input().split()))
s = sorted(a)
ans = 10 ** 9 + 7
for i in range(s[0], s[-1] + 1):
    tmp = 0
    for j in range(len(a)):
        tmp += (a[j] - i) ** 2
    ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 5276
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

print(N**3)

Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, m, q;
	cin >> n >> m >> q;
	vi a(q), b(q), c(q), d(q);
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i];b[i];
	}

	int ans = 0;

	for (ll i = 0;i < (1LL << (n + m + 1));i++) {
		int hoge = 0;
		rep(j, n + m + 1)if (i >> j & 1)hoge++;
		if (hoge != m - 1)continue;
	

		vi A(n + 2);
		hoge = 0;
		int ai = 1;

		rep(j, n + m + 1) {
			if (i >> j & 1)ai++;
			else { A[hoge] = ai;hoge++; }
		}

		int score = 0;

		rep(j, q)if (A[b[j]] - A[a[j]] == c[j])score += d[j];
		
		ans = max(ans, score);

	}

	cout << ans << endl;

}

Measured memory_bytes: 3632
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();

        if (S.equals("Sunny")) {
            System.out.println("Cloudy");
        } else if (S.equals("Cloudy")) {
            System.out.println("Rainy");
        } else {
            System.out.println("Sunny");
        }
    }
}

Measured memory_bytes: 19796
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map> 
#include<bitset>
using namespace std;
#define int long long
#define re register int
inline int read(){
    int x=0,ff=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')ff=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return x*ff;
}
struct tt{
	int to,nt;
}a[500005];
int h[500005],n,tot,in[500005],f[500005],ss;
char c[500005];
bool b[500005];
inline void add(int x,int y){
	a[++tot].nt=h[x];a[tot].to=y;h[x]=tot;
}
signed main(){
	scanf("%s",c+1);n=strlen(c+1)+1;
	for(re i=1;i<n;i++){
		if(c[i]=='<'){
			add(i,i+1);in[i+1]++;
		}
		else add(i+1,i),in[i]++;
	}
	queue<int> dl;
	for(re i=1;i<=n;i++){
		if(!in[i]){
			dl.push(i);b[i]=1;
		}
	}
	for(re l=1;l<=n;l++){
		re i=dl.front();
		ss+=f[i];dl.pop();
		for(re j=h[i];j;j=a[j].nt){
			if(b[a[j].to])continue;
			in[a[j].to]--;
			if(!in[a[j].to]){
				f[a[j].to]=f[i]+1;
				dl.push(a[j].to);b[a[j].to]=1;
			}
		}
	}
	cout<<ss<<endl;
	return 0;
}


Measured memory_bytes: 22016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int k, n;
  cin >> k >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll mx = -1;
  for (int i = 1; i < n ; ++i) {
    mx = max(mx, a[i] - a[i - 1]);
  }
  mx = max(mx, k - a[n - 1] + a[0]);
  cout << k - mx << endl;
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

int par[100010];
int ran[100010];

void init(int N){
	for(int i = 0; i < N; i++){
		par[i] = i;
		ran[i] = 0;
	}
}

int find(int x){
	if(par[x] == x){
		return x;
	}
	else{
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	
	if(ran[x] < ran[y]){
		par[x] = y;
	}
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

int n, m, p[100010];

int main(){
	cin >> n >> m;
	init(n);
	for(int i = 1; i <= n; i++){
		cin >> p[i];
	}
	
	for(int i = 1; i <= m; i++){
		int a, b;
		cin >> a >> b;
		unite(a,b);
	}
	
	int c = 0;
	for(int i = 1; i <= n; i++){
		if(same(i, p[i])) c++;
	}
	
	cout << c << endl;
	
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0){
        c -= b;
        if (c < 1){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
def f(n):
    if n%2 == 0:
        return n//2
    else: return 3*n+1
    
s = int(input())
a=[s]
m = 1
for i in range(2,1000001):
    a.append(f(a[i-2]))
    m = i
    if len(set(a))!=len(a):
        break
print(m)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,l,r) for(ll i=l;i<(ll)(r);i++) //ll
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;
const int INF = (1<<30);
int upcmpii(const void *a, const void *b){return(*(int*)a==*(int*)b?0:(*(int*)a>*(int*)b?1:-1));}
void sort_ui(int*a, int n){qsort(a,n,sizeof(int),upcmpii);}

int H,W;
int sx,sy,gx,gy;
char s[1010][1010];
int cnt[1010][1010] = {0};
ll ans = 0;
const int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
int qxf = 0, qxb = 0, quex[101010101];
int qyf = 0, qyb = 0, quey[101010101];

void dfs(int cx,int cy){
    cnt[cx][cy] = ans+1;
    rep(i,4){
        int nx = cx+dx[i];
        int ny = cy+dy[i];
        if(nx >= 0 && nx < H && ny >= 0 && ny < W){
            if(cnt[nx][ny] <= 0 && s[nx][ny] == '.'){
                dfs(nx,ny);
            }
        }
    }
    rep(i,5) rep(j,5) {
        int nx = cx-2+i;
        int ny = cy-2+j;
        if(nx >= 0 && nx < H && ny >= 0 && ny < W){
            if(cnt[nx][ny] == 0 && s[nx][ny] == '.'){
                cnt[nx][ny] = -1;
                quex[qxb++] = nx;
                quey[qyb++] = ny;
            }
        }
    }
}

void solve(){
    dfs(sx,sy);
    while(cnt[gx][gy] <= 0){
        ans++;
        int m = qxb-qxf;
        int tmp = 0;
        rep(i,m){
            int nnx = quex[qxf++],nny = quey[qyf++];
            if(cnt[nnx][nny] == -1) { dfs(nnx,nny); tmp++; }
        }
        if(tmp == 0 && cnt[gx][gy] == 0){
            ans = -1;
            break;
        }
    }
}

int main(){
    scanf("%d%d", &H,&W);
    scanf("%d%d%d%d", &sx,&sy,&gx,&gy);
    sx--;sy--;gx--;gy--;
    rep(i, H) scanf("%s", s[i]);

    solve();

    printf("%lld", ans);
}

Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
const int inf = 1000000000; 

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n){
        if(i%3 != 0 && i%5 != 0){
            ans += i;
            //cout  << i  << endl;
        }
    }
    cout << ans << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll maxval = 10e5 + 100;
	int n, W; cin >> n >> W;
	vpi wv = vpi();
	rep(i, n){
		int w, v; cin >> w >> v;
		wv.pb({w, v});
	}
	vll dp = vll(maxval+1, LLINF);
	dp[0] = 0;
	for (const auto& [w, v] : wv){
		for(int i = maxval; i >= 0; i--){
			if (i - v < 0) continue;
			dp[i] = min(dp[i], dp[i-v] + w);
		}
	}
	for(int i = maxval; i >= 0; i--){
		if (dp[i] <= W){
			cout << i;
			break;
		}
	}
}

Measured memory_bytes: 11120
#include <stdio.h>
int main(void)
{
	long int a;
	int b[17];
	int i, j;
	int sum1 = 0, sum2 = 0;
	scanf("%ld", &a);
	for(i=0; i<17; i++){
		b[i] = a % 10;
		a /= 10;
		if(a==0) break;
	}
	
	sum2 = b[i] - 1;
	for(j=0; j<=i; j++){
		sum1+=b[j];
		sum2+=9;
	}
	sum2 -= 9;

	if(sum1 > sum2) printf("%d\n", sum1);
	else printf("%d\n", sum2);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7;
long long mod(long long a)
{
  return((a%M+M)%M);
}
long long add(long long x,long long y)
{
  return mod(mod(x)+mod(y));
}
long long multiply(long long x,long long y)
{
  return mod(mod(x)*mod(y));
}
long long subtract(long long x,long long y)
{
  return mod(mod(x)-mod(y));
}

int main()
{
  long long int N;
  cin>>N;
  long long int A=1,B=1,D=1;
  for(long long int i=0;i<N;i++)
  {
    A=multiply(A,10);
    B=multiply(B,9);
    D=multiply(D,8);
  }
  A=A-B;
  A=A-B;
  A=add(A,D);
  cout<<mod(A);
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int, int>;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while (1) {
        minv = INFTY;
        u = -1;
        for (int i = 0; i < n; i++) {
            if (minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++){
            if (color[v] != BLACK && M[u][v] != INFTY) {
                if (d[v] > M[u][v]) {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] != -1) sum += M[i][p[i]];
    }

    return sum;
}

int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int e; cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    cout << prim() << endl;

    return 0;
}


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

using namespace std;
#define BUF (105)
#define ll long long 

int a;
int b;
char A[BUF][BUF];

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

	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++) {
			if(j<50) A[i][j]='.';
			else A[i][j] ='#';
		}
	}

	a--;
	b--;
	int cnt = 0;
	while(b>cnt){
		A[ 2*(cnt%50)][2*(cnt/50) ] = '#';
		cnt++;
	}

	cnt=0;
	while(a>cnt){
		A[ 2*(cnt%50)][99-2*(cnt/50) ] = '.';
		cnt++;
	}
	
	cout << 100 << "  " << 100 << "\n";
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++) {
			cout << A[i][j];
		}
		cout << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

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

  cout << (n<1000 ? "ABC" : "ABD") << endl;
//  n<1000 ? printf("ABC%03d", n) : printf("ABD%03d", n-999);
  return 0;
} 

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  sort(A.rbegin(),A.rend());
  ll ans=0;
  priority_queue<vector<ll>> pq;
  pq.push({A[0],A[0]});
  rep2(i,1,N) {
    auto t = pq.top();
    pq.pop();
    ans += t[0];
    vector<ll> t1 = {t[0],A[i]}, t2 = {t[1],A[i]};
    sort(t1.begin(),t1.end());
    sort(t2.begin(),t2.end());
    pq.push(t1);
    pq.push(t2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 15840
import java.util.*;

class Main {
  public static void main(String[] args) {
         Scanner scanner = new Scanner(System.in);
         
         String S = scanner.next();
         
         if(S.charAt(5) == S.charAt(4) && S.charAt(3) == S.charAt(2)){
             System.out.println("Yes");
         }
         else{
             System.out.println("No");
         }
         scanner.close();
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <tuple>

using namespace std;

std::string to_binString(int val)
{
    if( !val )
        return std::string("0");
    std::string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  // val は偶数か？
            str.insert(str.begin(), '0');  //  偶数の場合
        else
            str.insert(str.begin(), '1');  //  奇数の場合
        val >>= 1;
    }
    return str;
}


int main(void)
{
    /*
    動的計画法に、セグメント木(Minimum Spanning Tree)を用いることで高速化を図る
    */
    int Score_Goal, tmp_i, tmp_i2;
    cin >>tmp_i >> Score_Goal;
    const int N_Problems = tmp_i; // max = 10

    pair<int, int> N_Bonus[N_Problems]; // [問題数, ボーナス]

    for(int i=0; i<N_Problems; i++)
    {
        cin >> tmp_i >> tmp_i2;
        N_Bonus[i] = make_pair(tmp_i, tmp_i2);
    }

    int N_itemsMin = 0;
    int StatesMax = 1<< N_Problems;

    int Score_withBonus[N_Problems];
    for(int i=0; i<N_Problems; i++)
    {
        Score_withBonus[i] = (i+1) * 100* N_Bonus[i].first + N_Bonus[i].second;
        N_itemsMin += N_Bonus[i].first; //到達可能な個数の最小値
    }
    // cout << StatesMax << endl;


    for(int State = StatesMax-1; State>=0; State--)
    {
        int Score =0, N_items=0; //最上位: 1つ目
        for(int j=0; j<N_Problems; j++)
        {
            if(State >>(N_Problems-1-j) & 1)
            {
                Score += Score_withBonus[j];
                N_items += N_Bonus[j].first;
            }
        }

        if(Score >= Score_Goal)
        {
            // cout << "G  " << to_binString(State) << "  " << N_items << endl;
            N_itemsMin = min(N_itemsMin, N_items);
        }
        else if(State < StatesMax-1)
        {
            int State_back = ~State;
            int Last = State_back & (-State_back);
            int pos = (int) ( N_Problems-1-log(1.0*Last)/log(2.0) );
            int count = ceil( 1.0*(Score_Goal-Score) / 100/(pos+1) );
            if(count < N_Bonus[pos].first)
            {
                N_items += count;
                N_itemsMin = min(N_itemsMin, N_items);
                // cout << "WW  " << State << "  " << to_binString(Last) << ", " << count << "::: " << N_items << endl;
            }
        }
    }
    cout << N_itemsMin << endl;

    return 0;
}


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

int N;

int digit_sum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    cin >> N;

    if (N % digit_sum(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;     

    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

ll gcd (ll a, ll b) {
    ll x = min(a, b);
    ll y = max(a, b);
    if (y % x == 0) {
        return x;
    }
    else {
        return gcd(y % x, x);
    }
}

ll lcm (ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main() {
    int N;
    cin >> N;
    ll ans = 1;
    for (int i = 0; i < N; i++) {
        ll num;
        cin >> num;
        ans = lcm(ans, num);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<list>
using namespace std;

int main()
{
	vector<char> s;
	char c;
	for(;cin>>c;)
	{
		s.push_back(c);
	}
	for(int i=0;i<8;i++)
	{
		s.pop_back();
	}
	for(vector<char>::iterator it=s.begin();it!=s.end();it++)
	{
		cout<<*it;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())
ab = np.array([list(map(int, input().split())) for _ in range(N)])

acou = 0
co_m = M
ab_s = ab[np.argsort(ab[:,0])]

for i in range(N):
    acou += ab_s[i][0] * min(co_m, ab_s[i][1])
    co_m -= min(co_m, ab_s[i][1])
    if co_m == 0:
        break

print(acou)

Measured memory_bytes: 37856
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    string o, e, ans;
    cin >> o >> e;
    vector<char> c;
    for (int i = 0; i < e.length(); ++i) {
        c.push_back(o[i]);
        c.push_back(e[i]);
    }
    if (o.length() - e.length() != 0) c.push_back(o[o.length()-1]);
    for (auto x : c) cout << x;
    cout << "" << std::endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())
while True:
    pf={}
    m=X
    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:pf[m]=1
    if (len(pf)==1)and(list(pf.values())[0]==1):
        break
    X += 1
print(X)

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

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

	map<string, int> mp;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		mp[s]++;
	}

	int mx = 0;
	for (auto p : mp) {
		mx = max(mx, p.second);
	}
	for (auto p : mp) {
		if (mx == p.second) {
			cout << p.first << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  
  cout <<setprecision(9)<< n * 2 * pi << endl;
  return 0;
}



Measured memory_bytes: 3752
require 'set'
N, *rest = $stdin.read.split.map(&:to_i)
EDGES = Hash.new{|h, k| h[k] = [] } 
rest.each_slice(2){|a, b| EDGES[a] << b; EDGES[b] << a}

def calc_dist(start)
  ret = Array.new(N+1)
  q = [[start, 0]]
  ret[start] = 0
  until q.empty?
    pos, dist = q.shift
    EDGES[pos].each do |newpos|
      next if ret[newpos]
      ret[newpos] = dist + 1
      q << [newpos, dist + 1]
    end
  end
  ret
end

d1 = calc_dist(1)
dn = calc_dist(N)

s1 = sn = 0
for i in 1..N
  if d1[i] <= dn[i]
    s1 += 1
  else
    sn += 1
  end
end
if s1 > sn
  puts 'Fennec'
else
  puts 'Snuke'
end


Measured memory_bytes: 29308
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    int N,K;string S;cin>>N>>K>>S;
    vector<int> info;
    int count=0;char a=S[0];
    for(int i=0;i<N;i++){
        if(a==S[i])count++;
        else{
            info.push_back(count);
            a=S[i];
            count=1;
        }
    }
    info.push_back(count);
    int count0,count1;
    if(S[0]=='0'){
        count1=info.size()/2;
        count0=info.size()-count1;
    }
    else{
        count0=info.size()/2;
        count1=info.size()-count0;
    }
    if(count0<=K)cout<<N<<endl;
    else{
        if(S[0]=='0')info.insert(info.begin(),0);
        int now=0,ans=0;
        rep(i,2*K+1)now+=info[i];
        ans=now;
        for(int i=0;i<info.size()-2*K+2;i+=2){
            now-=info[i]+info[i+1];
            if(i+2*K+1<info.size())now+=info[i+2*K+1];
            if(i+2*K+2<info.size())now+=info[i+2*K+2];
            ans=max(now,ans);
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

struct P {
  double x, y, z;
  P() {}
  P(double x, double y, double z) : x(x), y(y), z(z) {}
};

P operator * (const P &a, const double &b) {
  return P(a.x*b, a.y*b, a.z*b);
}
P operator / (const P &a, const double &b) {
  return P(a.x/b, a.y/b, a.z/b);
}

double dot(P a, P b) {
  return a.x*b.x + a.y*b.y + a.z*b.z;
}
double norm(P a) {
  return dot(a,a);
}
double abs(P a) {
  return sqrt(norm(a));
}

double toRad(double deg) {
  return deg/180.0 * M_PI;
}

P getP(double a, double b) {
  P res;
  res.z = sin(a);
  res.x = cos(a) * cos(b);
  res.y = cos(a) * sin(b);
  return res;
}

int main() {
    double a, b, c, d;
  while(cin >> a >> b >> c >> d) {
    if(a == -1 && b == -1 && c == -1 && d == -1) return 0;
    P s = getP(toRad(a),toRad(b));
    P t = getP(toRad(c),toRad(d));
    printf("%.0f\n", acos(dot(s,t)/abs(s)/abs(t))*6378.1);
  }
  return 0;
}

Measured memory_bytes: 1284
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  int c = n / 11 * 2;
  n %= 11;
  c += n == 0 ? 0 : 1 + (n > 6);
  cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;

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

template <typename X>
struct Number{
  X n;
  vector<bool> prime;
  
  Number(X _n)
  {
    n = _n;
  }
  
  
  //nを素因数分解
  int prime_factor()
  {
    X nn = n;
    int cnt = 0;
    map<X,int> res;
    for(X i=2;i*i<=nn;++i){
      if(nn%i==0) cnt++;
      while(nn%i==0){
	res[i]++;
	nn /= i;
      }
    }
    if(nn!=1){
     res[nn] = 1;
     cnt++;
    }
    return cnt;
  }

};

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

  Number<ll> nb(gcd(a,b));


  cout << nb.prime_factor()+1 << "\n";
  
  return 0;
}


Measured memory_bytes: 256
import fractions
a,b,c,d = map(int,input().split())

ans = b - a + 1
cd = c*d//fractions.gcd(c,d)
tmp = int(b // c) - int((a-1) // c)
tmp2 = int(b // d) - int((a-1) // d)
tmp3 = int(b //cd) - int((a-1) // cd)


print(ans - tmp - tmp2 + tmp3 )


Measured memory_bytes: 5048
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	a[0]=a[1]=0;
	for(int i=2; i<n+1; i++)
	{
		cin>>a[i];
	}
	sort(a,a+n+1);
	int j=1;
	int i=2;
	while(j<n+1)
	{
		int count=0;
		while(a[i]==j&&i<n+1)
		{
			count++;
			i++;
		}
		cout<<count<<"\n";
		j++;
	}
	return 0;
}

Measured memory_bytes: 4356
#Nを適当にとる
#各a[i](1<=i<=N)に順番に1回ずつ操作を行うことをK//N回繰り返す
#一周する完遂するごとにa[i]は１ずつ減っていく
#自身以外の操作に対して1だけ増加するので、a[i]は合計でK//N*(N-1)+だけ増える.
#したがって、a[i]の初期値はN-1+K//N


def main():
    K = int(input())
    N = 50
    loop, remain = divmod(K, N)
    a = [N-1+loop+N-remain+1 if i < remain else N-1+loop-remain for i in range(N)]
    print(N)
    print(*a)

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int X,Y,A,B,C;
MinHeap<LL> p1, p2;
MaxHeap<LL> p3;
vector<LL> AA,BB;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> X >> Y >> A >> B >> C;
    REP(i,A) {
        LL a;
        cin >> a;
        AA.push_back(a);
        p1.push(a);
    }

    REP(i,B) {
        LL a;
        cin >> a;
        BB.push_back(a);
        p2.push(a);
    }

    REP(i,C) {
        LL a;
        cin >> a;
        p3.push(a);
    }

    while(p1.size()>X) p1.pop();
    while(p2.size()>Y) p2.pop();
    


    while(p3.size()) {
        LL c=p3.top(); p3.pop();
        if( p1.top()==p2.top() ){
            LL x=p1.top();
            auto it1=upper_bound(ALL(AA),x);
            auto it2=upper_bound(ALL(BB),x);
            if( it1==AA.end() && it2==BB.end() ){
                p1.pop();
                p1.push(c);
            } else if( it1==AA.end() && it2!=BB.end() ){
                p1.pop();
                p1.push(c);
            } else if( it1!=AA.end() && it2==BB.end() ) {
                p2.pop();
                p2.push(c);
            } else if( *it1 < *it2 ){
                p1.pop();
                p1.push(c);                
            } else {
                p2.pop();
                p2.push(c);

            }
        }
        else if(p1.top()<p2.top()) {
            if(c>p1.top()) {
                p1.pop();
                p1.push(c);
            }
        }
        else if(p1.top()>p2.top()) {
            if(c>p2.top()) {
                p2.pop();
                p2.push(c);
            }
        }
    }
    LL ans=0;
    while(p1.size()) {
        // cout << p1.top();
        ans+=p1.top(); p1.pop();
    }
    while(p2.size()) {
        // cout << p2.top();
        ans+=p2.top(); p2.pop();
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 4884
//============================================================================
// Name        : JOI.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>

using namespace std;
typedef long long ll;

// 1. dpを書く
int dp[31][100001]={};
// 2. nを書く。
int n;
int c;

int main() {

	cin>>n>>c;


	// 4.入力
	int s,t,c1;
	for(int i=1; i<n+1; ++i){
		cin>>s>>t>>c1;
		for(int j=s-1; j<t; ++j){
			dp[c1][j]=1;
		}
	}

	// 6. 出力
	int total=0;
	for(int i=0; i<100001; ++i){
		int s1=0;
		for(int j=1; j<c+1; ++j){
			s1+=dp[j][i];
		}
		total=max(s1,total);
	}
	cout<<total<<endl;
	return 0;

}




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

int main() {
	long long n, m;
	cin >> n >> m;
	
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a.at(i);
	}
	
	for (int i = 0; i < m; i++) {
		n -= a.at(i);
	}
	
	if (n < 0) {
		n = -1;
	}
	cout << n << endl;
}

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

int main(){
  int A,B,sum;
  cin >> A >> B;
  while(A<=B){
    int a,b,c,d;
    a = A / 10000; //万の位
    b = A % 10; //1の位
    c = A / 1000 % 10; //千の位
    d = A / 10 % 10; //十の位
    if(a == b && c == d){
       sum+=1;
    }
    A+=1;
  }
  cout << sum << endl;
}
       


Measured memory_bytes: 256
//C - Special Trains: 
//Assunto: 
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    ll ans, aux;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    loop(i, 1, n) cin >> c[i] >> s[i] >> f[i];
    loop(j, 1, n+1) {
        ans = 0;
        loop(i, j, n) {
            if(ans <= s[i]) ans = s[i];
            else if(ans % f[i] == 0);
            else ans += f[i] - (ans % f[i]);
            ans += c[i];
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 256