akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
vector<double>data(3000);//globalで宣言するときには大きさも入れとかないといけない
vector<vector<int>>done(3000,vector<int>(3000));
vector<vector<double>>memo(3000,vector<double>(3000));

double dp(int p,int q){
  if (p<q){
    done.at(p).at(q)=1;
    memo.at(p).at(q)=0;
    return memo.at(p).at(q);
  }
  else{
  if (done.at(p).at(q)){
  return memo.at(p).at(q);
  }
  else{
  double r;
  r=dp(p-1,q-1)*data.at(p-1)+dp(p-1,q)*(1-data.at(p-1));
 memo.at(p).at(q)=r;//こいつをどこにメモするか問題があるな
 done.at(p).at(q)=1;
  return r;
  }
  }
}
int main (){
  int n;
  cin >>n;
  for (int i=0;i<n;i++){
  cin >>data.at(i);
  } 
  //dataはi番目のデータはdata.at(i)にある。
  //初期化問題.memo.at(p).at(q)は
  memo.at(1).at(0)=1-data.at(0);
  done.at(1).at(0)=1;
  memo.at(1).at(1)=data.at(0);
  done.at(1).at(1)=1;
  for (int i=2;i<n+1;i++){
  memo.at(1).at(i)=0;
  done.at(1).at(i)=1;
  }
  for (int i=2;i<n+1;i++){
  memo.at(i).at(0)=memo.at(i-1).at(0)*(1-data.at(i-1));
  done.at(i).at(0)=1;
  }
  
  
  double s=0;
//cout <<dp(2,1)<<" "<<dp(1,2)<<" "<<memo.at(1).at(3);
  for (int i=n/2+1;i<n+1;i++){
 s+=dp(n,i);//dp(n,i)はカードをn枚使ったときに、面がi回出る確率
 }
  //cout <<s<<endl;
  printf("%.10f", s);
}


Measured memory_bytes: 108032
#Knapsack1
N, W = map(int, input().split())
weight = []
value = []
# N,W =3, 8
# wv_lst = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)
# weight = [3, 4, 5]
# value = [30, 50, 60]

dp = [[0] * (W+1) for _ in range(N+1)]

for n in range(1, N+1):
    weigh = weight[n-1]
    val = value[n-1]
    for w in range(W+1):
        if w < weigh:
            dp[n][w] = dp[n-1][w]
        else:
            dp[n][w] = max(dp[n-1][w], 
                        dp[n-1][w-weigh] + val)
        
# print([dp[i] for i in range(N+1)])
print(dp[-1][-1])
        



Measured memory_bytes: 119916
import java.util.Scanner;


public class Main {
//	final static int MOD = 1000000007;

	public static long ans = 0;

	public static void main(String[] args) {

//		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();



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

		int tmp = d / s;
		if(d % s == 0) {

		} else {
			tmp++;
		}

		if(tmp <= t) {
			f = true;
		} else {
			f = false;
		}


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

		if(f) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

//		System.out.println(ans);

		sc.close();
	}



}

Measured memory_bytes: 35688
from collections import Counter

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

a = Counter(A)

x, y = 0, 0
for k, v in a.items():
  if(v >= 2 and k > y):
    if(k >= x):
      if(v >= 4):
        y = k
      else:
        y = x
      x = k
    else:
      y = k
print(x*y)

Measured memory_bytes: 18600
#include <iostream>
using namespace std;
const int LEN = 2e5 + 10;

// 下标表示余数，数组元素代表在当前状态前共有几个子段模除2019的余数相同
int mod[LEN] = {0};

int main() {
    string s;
    cin >> s;
    int pow = 1, res = 0, ans = 0;
    mod[0] = 1; // 如果余数为0则x本身就可以作为2019的倍数,所以mod[0]初始化为1。
    for (int i = s.size() - 1; i >= 0; i--) {
        res = (res + (s[i] - '0') * pow) % 2019;
        ans += mod[res];
        mod[res] += 1;
        pow = pow * 10 % 2019;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3768
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int m,i,j,ans,price;

int main(void){
	while(scanf("%d",&m)*m){
		m=m/100;ans=1000000;
		for(i=0;i<=m;i+=5){
			for(j=0;j<=m-i;j+=3){
				if((m-i-j)%2==0){
					price=(i/15)*2244+(i%15)/5*850+(j/12)*1870+(j%12)/3*550+((m-i-j)/10)*1520+((m-i-j)%10)/2*380;
					if(price<ans)ans=price;
				}
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

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

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

int main() {
    //cout.precision(10);
    string S;
    cin >> S;
    ll ans = 0;
    ll now = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'B'){
            now++;
            continue;
        }
        ans += now;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N, INFL);
  rep(i, N-1){
    ll b;
    cin >> b;
    A[i] = min(A[i], b);
    A[i+1] = min(A[i+1], b);
  }
  ll ans = 0;
  rep(i, N) ans += A[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int l,r,d;
	scanf("%d %d %d",&l,&r,&d);
	int ans=0;
	for(int i=l;i<=r;i++){
		if(i%d==0) ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include<limits.h>
using namespace  std;
typedef long long int ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define filla(a,k,n) memset(a,k,sizeof(a[0])*n)
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 1e5+5, MOD = 1e9+7;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
int main()
{
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll dp[n];
	for(ll i=0;i<n;i++)
		dp[i]=INT_MAX;
	dp[0]=0;
	//dp[1]=abs(a[1]-a[0]);
	for(ll i=1;i<n;i++)
	{
		for(ll j=1;j<=min(k,i);j++)
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#!/usr/bin/ruby
while (h,w,l=gets.split.map(&:to_i))!=[0,0,0]
d=[[0,-1],[1,0],[0,1],[-1,0]]
d0="NESW".split('')
f=(h+2).times.map{[1]*(w+2)}
g=(h+2).times.map{(w+2).times.map{[nil]*4}}
z=x=y=0
h.times{|i|
	s=gets.chomp
	w.times{|j|
		if (k=d0.index(s[j..j]))
			x=j+1;y=i+1;z=k
		end
		if s[j..j]!='#'
			f[i+1][j+1]=nil
		end
	}
}
c=0
while l>0
	break if g[y][x][z]&&(l%=c-g[y][x][z])==0
	g[y][x][z]=c
	while true
		if !f[y+d[z][1]][x+d[z][0]]
			x+=d[z][0];y+=d[z][1]
			break
		end
		z=(z+1)%4
	end
	l-=1
	c+=1
end
puts "#{y} #{x} #{d0[z]}"
end

Measured memory_bytes: 9788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  ll n,a,b;
  cin >> n >> a >> b;
  
  cout << n/(a+b)*a+min(n%(a+b),a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;


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

    ll sum = 0;
    for(ll i = 1; i * i < n; i++){
        if(n % i == 0){
            ll m = n / i - 1;
            if(n / m == n % m){
                sum += m;
            }
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;

ll N,M,K;
ll a,b,c;
string s;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <algorithm>

int main() {
    std::string s; std::cin >> s;
    s[0] = '2';
    s[1] = '0';
    s[2] = '1';
    s[3] = '8';
    std::cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<int>> hint(N);
  std::vector<int> lut(N);

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

  std::vector<int> chain;
  int num = 0;

  for (int i = 0; i < N; ++i) {
    int table;
    if (lut[i] == 0) {
      ++num;
      lut[i] = num;
      chain.clear();
    } else {
      continue;
    }

    chain.push_back(i);

    for (int i = 0; i < chain.size(); ++i) {
      auto c = chain[i];
      for (auto &h : hint[c]) {
        if (lut[h] == 0) {
          lut[h] = num;
          chain.push_back(h);
        }
      }
      hint[c].clear();
    }
  }

  int result = num;

  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 7288
a = int(input())


hs = [int(x) for x in input().split()]

if a == 1:
  print(0)
  exit()
dp = [0]* len(hs)


dp[0] = 0
dp[1] = abs(hs[1] - hs[0])

for i in range(2, a):
  dp[i] = min(abs(hs[i-1]- hs[i]) + dp[i-1], abs(hs[i-2]- hs[i]) + dp[i-2] )
  
print(dp[-1])

Measured memory_bytes: 52208
using System;

namespace AGC006
{
    class A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string t = Console.ReadLine();

          for (int i = 0; i < s.Length; i++)
            {
                string spart = s.Substring(i, s.Length - i);
                string tpart = t.Substring(0, s.Length - i);
                if (spart == tpart) { Console.WriteLine(s.Length + t.Length - (s.Length - i)); return; }
            }
            Console.WriteLine(s.Length + t.Length);
        }
    }
}


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

long long int labs(long long int a, long long int b)
{
	return ((a>b)?a-b:b-a);
}

long long int lmin(long long int a, long long int b)
{
	return ((a>b)?b:a);
}

int main()
{
	long long int n, k, x[100001];
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i];
	}
	long long int ans = 1145141919;
	for (int i = k; i <= n; ++i)
	{
		ans = lmin(ans, labs(x[i-k]-x[i-1])+lmin(labs(x[i-k]),labs(x[i-1])));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long LL;
int a[N],b[N],vis[N];
int main(){
	int n,x=1,now=0,w,w1;scanf("%d",&n);
	LL k;scanf("%lld",&k);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	while(!vis[x]){
		b[vis[x]=++now]=x;
		x=a[x];
	}
	w=vis[x]-1,w1=now-w;
	if(k<=w)printf("%d\n",b[k+1]);
	else k-=w,printf("%d\n",b[k%w1+w+1]);
	return 0;
}

Measured memory_bytes: 6048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MAX = 1e5 + 5, MOD = 1e9+7;
ll n, k, ans = 1;
bool f, vis[MAX];
struct tree
{
    int to, next;
}G[2 * MAX];
int head[MAX], cnt = -1, x, y;
void add(int u, int v)
{
    cnt++;
    G[cnt].next = head[u];
    G[cnt].to = v;
    head[u] = cnt;
}
void dfs(int u, int depth, int b)
{
    vis[u] = true;
    if(depth == 1)  ans = (ans * k) % MOD;
    else if(depth == 2) ans = (ans * (k - b - 1)) % MOD;
    else ans = (ans * (k - b - 2)) % MOD;
    for(int i = head[u], b_ = 0; i != -1; i = G[i].next){
        int v = G[i].to;
        if(!vis[v]){
            dfs(v, depth + 1, b_);
            b_++;
        }
    }
}

int main()
{
    memset(head, -1, sizeof(head));
    cin >> n >> k;
    for(int i = 1; i <= n - 1; ++i){
        cin >> x >> y;
        add(x, y);
        add(y, x);
    }
    dfs(1,1,0);
    cout << ans;
    return 0;
}

Measured memory_bytes: 8992
//__________________Do_What_You_want___//
//__________I_DO_What_I_Want___________________________//

#include<bits/stdc++.h>
#include <map>
#include "ext/pb_ds/assoc_container.hpp" 
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/detail/standard_policies.hpp"
using namespace __gnu_pbds;
using namespace std ;

//----------------------------------INDEX_TREE-----------------------------------------//
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> multiordered_set;

//-------------------------------------------------------------------------------------//
#define pb push_back 
#define eb emplace_back
#define F first 
#define mk make_pair
#define S second
#define siz(v) (int)v.size() 
#define all(v) (v).begin(),(v).end() 
#define endl '\n'
#define int long long
const int mod = 1000000007 ;
//------------------------------FUNCTIONS----------------------------------------------//
int powermod(int a,int b){int res=1;while(b){if(b&1)(res*=a)%=mod;b/=2;(a*=a)%=mod;}return res%mod;}

int power(int a,int b){int res=1;a%=mod;while(b>0){if(b&1)res*=a;b/=2;a*=a;}return res;}

bool isprime(int n){for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}

vector<int> sieve(int n){vector<int> prime ;vector<int> vis(n+1,false);
for(int i=2;i*i<=n;i++){if(vis[i] == false){for(int j=i*i;j<=n;j+=i){vis[j]=true;}}}
for(int i=2;i<=n;i++){if(vis[i]==false){prime.push_back(i);}}return prime;}

long double to_deg(long double x) { return x * 180 / acos(-1); }
int logi(int x){int p = 0 ;while(x>1){p++;x/=2;}return p ;}

int ncr(int n,int r){int p = 1 , l = 1 ;if(n-r < r) r = n-r ;
    while(r){p *= n ;l *= r ;int g = __gcd(p,l) ;p /= g ;l /= g ;n--;r--;}
    return p ;
}

vector<int>_x{0,0,0,1,1,1,-1,-1,-1} ;
vector<int>_y{0,1,-1,0,1,-1,0,1,-1} ;

int mul(int a , int b){return (a*b)%mod ;}
int add(int a , int b){return (a+b)%mod ;}

//-------------------------------------------------------------------------------------//
vector<int> adj[100010] ;
vector<int> dist(100010) , vis(100010) ;
map<int,int> mp ;

void dfs(int u){
    vis[u] = true ;
    for(int v : adj[u]){
        dist[v] = max(dist[v] , dist[u]+1) ;
        mp[v]-- ;
        if(mp[v] == 0 ) dfs(v);
    }
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    //--------------------------------GETLINE------------------------------------------//
    //cin.ignore();
    //--------------------------------input/output-------------------------------------//
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    //----------------code-------------------------------------------------------------//
    int n,m ;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
        mp[b]++;
    }

    for(int i=1;i<=n;i++){
        if(vis[i] == false and mp[i] == 0 ) dfs(i);
    }
    int ans = 0 ;
    for(int i : dist) ans = max(ans , i ) ;
    cout<<ans<<endl;
}


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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    int n, time;
    cin >> n >> time;
    int ans = (1 << 20);
    for(int i = 0; i < n; i++) {
        int c, t;
        cin >> c >> t;
        if(t <= time) {
            ans = min(ans, c);
        }
    }
    cout << ((ans == (1 << 20)) ? "TLE" : to_string(ans)) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  vector<int> a(n),b(n);

  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  priority_queue<pair<int,int>> pq;
  rep(i,n){
    if(a[i]!=b[i]) pq.push({b[i],i});
  }

  ll ans =0;

  while(!pq.empty()){

    auto cp = pq.top(); pq.pop();
    int val = cp.first;
    int pos = cp.second;

    int pre_pos = pos -1;
    if(pre_pos < 0) pre_pos = n-1;
    int nxt_pos = pos +1;
    if(nxt_pos >= n) nxt_pos = 0;

    if(b[pre_pos]+b[nxt_pos] >= b[pos]){
      cout << -1 << endl;
      return 0;
    }
    int times = max((b[pos]-a[pos])/(b[pre_pos]+b[nxt_pos]),1);
    ans+=times;
    b[pos] -= (b[pre_pos] + b[nxt_pos]) * times;
    if(b[pos]==a[pos]) continue;
    else if(b[pos] < a[pos]){
      cout << -1 << endl;
      return 0;
    }
    pq.push({b[pos],pos});
    // cout << b[pos] << endl;
  }

  cout << ans << endl;


  return 0;
    

}


Measured memory_bytes: 3956
N , K = map(int ,input().split())
S = list(input())

a = []

now = S[0]
cnt = 1
for x in S[1:]:
    if x == now:
        cnt += 1
    else:
        a.append(cnt)
        now = x
        cnt = 1
a.append(cnt)

#偶数番目に0の数、奇数番目に1の数
if S[0] == "0":
    a = [0] + a
if S[-1] == "0":
    a = a + [0]

#print(a)

m = len(a)

if 2 * K + 1 >= m:
    maxsum = N
else:
    l = 0
    r = 2 * K + 1
    nowsum = sum(a[l : r])
    maxsum = nowsum
    while True:
        l += 2
        r += 2
        if r > m:
            break
        nowsum += a[r - 2] + a[r - 1] - (a[l - 2] + a[l - 1])
        maxsum = max(maxsum , nowsum)

print(maxsum)

Measured memory_bytes: 52236
#include<bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//MessageBox(GetForegroundWindow(),"标题","内容",MB_YESNO);
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=n/i;
		if(n%i==0){
			sum--;
		}
	}
	cout<<sum<<endl;
	return 0;
}


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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<int>());
  for(int i=0; i<s.length(); i++){
    if(s[i]<t[i]){
      cout << "Yes" << endl;
      return 0;
    }else if(s[i]>t[i]){
      cout << "No" << endl;
      return 0;
    }
  }
  if(s.length()<t.length()) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3632
n = int(input())
n_list = [int(i) for i in input().split()]

res = ''
for i in range(n - 1):
  if n_list[i + 1] <= n_list[i]:
    res += 't'
  else:
    res += 'f'
    
res_list =[len(i) for i in res.split('f')]
      
print(max(res_list))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<ll>a(n+1);
  rep(i,n+1) cin >> a[i];
  vector<ll>ans(n+1);
  vector<P>m(n+1);
  
  for(int i = n; i >= 0; i--){
    if(i==n)m[i]=P(a[i],a[i]);
    else{
      ll mi = a[i] + (m[i+1].first+1)/2;
      ll ma = a[i] + m[i+1].second;
      m[i] = P(mi,ma);
    }
  }
  if(1 < m[0].first  || m[0].second < 1 ){
    cout << -1 << endl;
    return 0;
  }
  rep(i,n+1){
    if(i == 0)ans[0] = 1;
    else{
      ans[i] = min(2*(ans[i-1]-a[i-1]),m[i].second);
    }
  }
  ll res = 0;
  rep(i,n+1) res += ans[i];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 6368
#include<iostream>
#include<sstream>
#include<vector>
using namespace std;

int main(){
	ostringstream out;

	int N,M,Q,n;
	while(cin >> N >> Q, N|Q){
		vector<int> date(100);
		for(int i=0;i<N;i++){
			cin >> M;
			for(int j=0;j<M;j++){
				cin >> n;
				date[n]++;
			}
		}
		n=0;
		for(int i=1;i<date.size();i++)
			if(date[i]>=Q&&date[n]<date[i]){
				n=i;
				if(date[i==N])
					break;
			}
		out << n << endl;
	}

	cout << out.str();

	return 0;
}

Measured memory_bytes: 1228
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::str::FromStr;

fn read_vec<T: FromStr>(s: String) -> Result<Vec<T>, T::Err> {
    s.split(' ').map(|x| x.parse()).collect()
}

fn main() {
    let mut lines = BufReader::new(io::stdin()).lines().map(|l| l.unwrap());
    let lrd: Vec<usize> = read_vec(lines.next().unwrap()).unwrap();
    println!("{}", lrd[1] / lrd[2] - (lrd[0] - 1) / lrd[2]);
}

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

#define iso ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll int
#define pll pair<ll,ll>
#define mod 1000000007

int main(){
	int n,i,ans1=0,ans2=0,ans3=0,ans4=0;
	cin>>n;
	vector<string> a(n);

	for(i=0;i<n;i++)
		cin>>a[i];

	for(i=0;i<n;i++){
		if(a[i] == "AC")
			ans1++;
		else if(a[i] == "WA")
			ans2++;
		else if(a[i] == "TLE")
			ans3++;
		else if(a[i] == "RE")
			ans4++;
	}

	cout<<"AC x "<<ans1<<endl;
	cout<<"WA x "<<ans2<<endl;
	cout<<"TLE x "<<ans3<<endl;
	cout<<"RE x "<<ans4<<endl;
}

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

using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)

int main() {
    int n, m;
    vector<pair<int, int>> ab;
    cin >> n >> m;
    rep(_, n) {
        int a, b;
        cin >> a >> b;
        ab.push_back({a, b});
    }
    sort(ab.begin(), ab.end());
    long long ans = 0;
    for(auto p : ab) {
        long long c = min(m, p.second);
        ans += c * p.first;
        m -= c;
        if(m == 0) break;
    }
    cout << ans << endl;
}

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

void solve()
{
    int a, b;
    cin >> a >> b;
    if (a == 1)
        a = 14;
    if (b == 1)
        b = 14;
    if (a > b)
        cout << "Alice" << endl;
    else if (a < b)
        cout << "Bob" << endl;
    else
        cout << "Draw" << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3580
#include <cstdio>
 
int main(){
    int n, m, sum;
    scanf("%d%d",&n,&m);
    int a[n][m],b[m],c[n];
    int i,j;
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        scanf("%d",&b[i]);
    }
    for(i = 0; i < n; i++){
        c[i] = 0;
        for(j = 0; j < m; j++){
            c[i] = c[i] + a[i][j] * b[j];
        }
        printf("%d\n", c[i]);
    }
    
    return 0;
}


Measured memory_bytes: 2780
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n)cin >> a[i];
  deque<int> d;
  rep(i,n){
    if(d.size()==0){
      d.push_back(a[i]);
      continue;
    }
    auto id = lower_bound(d.begin(),d.end(),a[i]) - d.begin();
    if(id==0)d.push_front(a[i]);
    else d[id-1]=a[i];
  }
  cout << d.size() << endl;
}

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

int main(){
  int N, K; 
  cin >> N >> K;
  int sum = 0;
  rep(i, N){
    int x;
    cin >> x;
     if((x * 2) <= ((K - x) * 2)){
       sum += x * 2;
     }else{
       sum += (K - x) * 2;
     }
   }
  cout << sum << endl;
}

Measured memory_bytes: 256
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#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 <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#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 <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}

int a, b, h, m;
double ans, k;
signed main() {
	cin >> a >> b >> h >> m;
	k = abs(m * 6 - (h * 30 + m * 0.5));
	k = min(k, 360 - k);
	ans = (2.0 * b * a * (cos(k*pai/180)));
	pf(sqrt(a * a + b * b - ans));
}

Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std; void solve(); int main(){cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
using ll=int_fast64_t; using ld=long double; using pll=pair<ll,ll>; using pld=pair<ld,ld>;
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> void vecout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

class UnionFind {
private:
  vector<ll> m_parent,m_rank,m_size;
  ll root(ll i) {
    if(m_parent[i]==i) return i;
    else return m_parent[i]=root(m_parent[i]);
  }
public:
  UnionFind(ll n) {
    m_parent.resize(n);
    rep(i,n) m_parent[i]=i;
    m_rank.resize(n,0);
    m_size.resize(n,1);
  }
  bool is_same(ll i,ll j) {return root(i)==root(j);}
  ll size(ll i) {return m_size[root(i)];}
  void unite(ll i,ll j) {
    i=root(i); j=root(j);
    if(i==j) return;
    if(m_rank[i]>m_rank[j]) {
      m_parent[j]=i;
      m_size[i]+=m_size[j];
    } else {
      m_parent[i]=j;
      m_size[j]+=m_size[i];
      if(m_rank[i]==m_rank[j]) m_rank[j]++;
    }
  }
};

void solve() {
  // main coding
  ll n,m; cin>>n>>m;
  vector<pll> ab;
  ll a,b;
  rep(i,m) {
    cin>>a>>b;
    ab.emplace_back(--a,--b);
  }
  // calculate
  UnionFind tree(n);
  vector<ll> ans;
  ll score=n*(n-1)/2;
  ans.push_back(score);
  for(auto it=ab.rbegin();it!=ab.rend();++it){
    a=it->fi; b=it->se;
    if(not tree.is_same(a,b)){
      score-=tree.size(a)*tree.size(b);
      tree.unite(a,b);
    }
    ans.push_back(score);
  }
  // output
  reverse(ans.begin(),ans.end());
  for(auto it=++ans.begin();it!=ans.end();++it){
    cout<<*it<<"\n";
  }
}

Measured memory_bytes: 7024
# input
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]



# 左右に要素を追加
for i in range(H): # 左右に要素を追加
    S[i] = ['.'] + S[i] + ['.']

# 上下に要素を追加
S = [['.' for i in range(W + 2)]] + S + [['.' for i in range(W + 2)]]

S_dummy = S

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == '.':
            tmp = 0
            if S[i - 1][j - 1] == '#':
                tmp += 1
            if S[i - 1][j] == '#':
                tmp += 1
            if S[i - 1][j + 1] == '#':
                tmp += 1
            if S[i][j - 1] == '#':
                tmp += 1
            if S[i][j + 1] == '#':
                tmp += 1
            if S[i + 1][j - 1] == '#':
                tmp += 1
            if S[i + 1][j] == '#':
                tmp += 1
            if S[i + 1][j + 1] == '#':
                tmp += 1
            S_dummy[i][j] = tmp

for i in range(1, H + 1):
    for j in range(1, W + 1):
        print(S_dummy[i][j], end = "")
    print('')

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*
2d pointer array
int **dp;
in main function
int row,col;
dp=new int*[n];
rep(i,n)dp[i]=new int[m]
*/
int n,m;
int cost[1009];
int maske[1009];
int allmask;
int dp[1009][1<<12];
int solve(int idx,int mask)
{
  if(idx>=m)
  {
    if(mask==allmask)return dp[idx][mask]= 0;
    return dp[idx][mask]=INT_MAX;
  }
  if(mask==allmask)return dp[idx][mask]=0;
  if(dp[idx][mask]!=-1)return dp[idx][mask];
  int ans=solve(idx+1,mask);
  int newMask=mask|maske[idx];
  ans=min(ans,cost[idx]+solve(idx+1,newMask));
  return dp[idx][mask]=ans;
}
int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  cin>>n>>m;
  clr1(dp);
  rep(i,m)
  {
    int a;
    cin>>cost[i]>>a;
    rep(j,a)
    {
      int b;
      cin>>b;
      b--;
      maske[i]=maske[i] | (1<<b);
    }
  }
  allmask=(1LL<<n)-1;
  int res=solve(0,0);
  if(res==INT_MAX)cout<<"-1";
  else cout<<res;
  cout<<endl;
  return 0;
}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
#define log2(x) (log(x)/log(2))
#define ln '\n'
#define bln(i,n) ((i==n-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int a[3], r;

signed main() {
	rep(i,3) cin >> a[i];
	sort(a,a+3);
	if (a[1]<=a[2]-2) {
		int inc = (a[2]-a[1])/2;
		r += inc, a[1] += inc*2;
	}
	if (a[0]<=a[1]-2) {
		int inc = (a[1]-a[0])/2;
		r += inc, a[0] += inc*2;
	}
	sort(a,a+3);
	a[2] -= a[0], a[1] -= a[0], a[0] = 0;
	int sum = accumulate(a,a+3,0);
	if (sum==0) cout << r << ln;
	else {
		if (sum==1) cout << r+1 << ln;
		if (sum==2) cout << r+2 << ln;
		if (sum==3) cout << r+3 << ln;
		if (sum==4) cout << r+1 << ln;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
vector <int> a[222];
char s[222];
int vis[222], vis1[222], vis2[222];
int main(){
    int n;
    while(cin>>n){
        int ans=-1;
        for(int i=0; i<n; ++i){
            scanf("%s",s);
            for(int j=0; j<n; ++j){
                if(s[j]=='1'){
                    a[i+1].push_back(j+1);
                }
            }
        }
        for(int i=1; i<=n; ++i){
            vector <int> v, v1;
            set<int> st;
            v.clear();
            v1.clear();
            v.push_back(i);
            memset(vis, 0, sizeof vis);
            memset(vis1, 0, sizeof vis1);
            memset(vis2, 0, sizeof vis2);
            bool l=1;
            int cnt=0;
            while(v.size()>0){
                for(int j=0; j<v.size(); ++j){
                    vis1[v[j]]=1;
                    vis2[v[j]]=1;//cout<<v[j]<<" ";
                }
//                cout<<endl;
                ++cnt;
                for(int j=0; j<v.size(); ++j){
                    for(int k=0; k<a[v[j]].size(); ++k){
                        if(vis[a[v[j]][k]] || vis2[a[v[j]][k]]){
                            l=0;
                            break;
                        }
                        if(!vis1[a[v[j]][k]])
                            st.insert(a[v[j]][k]);
                    }
                    if(l==0)
                        break;
                }
                if(l==0)
                    break;
                while(v1.size()){
                    vis[v1.back()]=1;
                    v1.pop_back();
                }
                for(int j=0; j<v.size(); ++j){
                    vis2[v[j]]=0;
                }
                v1=v;
                v.clear();
                for(auto it:st){
                    v.push_back(it);
                }
                st.clear();
            }
            if(l){
                ans=max(ans, cnt);
            }
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 512
# ARC068C - X: Yet Another Die Game (ABC053C)
def main():
    x = int(input())
    ans, r = x // 11 * 2, x % 11
    if r != 0:
        ans = ans + 1 if x % 11 <= 6 else ans + 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define se second
#define fi first
#define pb push_back
#define cn cout<<"\n"
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repr(i,a,b) for(int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

#define _ ios::sync_with_stdio(0); cin.tie(0);

#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>
#define flush fflush(stdout)

const int INF = 1e8;
const ll MOD = 1e9 + 7;

using namespace std;

int main(){
	_

	int t = 1;

	// cin>>t;

	ll r, d, x;
	rep(nc, 0, t){
		cin>>r>>d>>x;

		ll pre = x;
		rep(i, 0, 10) {
			pre = r * pre - d;
			cout<<pre<<"\n";
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int x, y;
    cin >> x >> y;
    int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    cout << (a[x] == a[y] ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }

int main(){
  string s; cin>>s;
  int N = s.size();
  map<int,int> mp;
  int temp = 0;
  int powt = 1;
  REPR(i,N-1){
    int a = ctoi(s[i]);
    if(i<N-1){
      powt *= 10;
      powt %= 2019;
    }
    a *= powt;
    a %= 2019;
    temp += a;
    temp %= 2019;
    ++mp[temp]; 
  }
  ll ans =0;
  REP(i,2019){
    int x = mp[i];
    if(i==0){
      ans += x;
      ans += x*(x-1)/2;
    }
    else{
      ans += (x*(x-1)/2);
    }
  }
  cout << ans <<"\n";
}

Measured memory_bytes: 3708
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  set<ll> st;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  if (st.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())

H %= 12
ra = 0.5*(60*H+M)-6*M
ra = min(ra,360-ra)
cos_ra = math.radians(ra)
C = math.sqrt((A**2+B**2)-(2*A*B*math.cos(cos_ra)))
print(C)

Measured memory_bytes: 9500
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K;
  string S;
  cin >> K >> S;
  if (K < S.length()) S = S.substr(0, K) + "...";
  cout << S << endl;
  return 0;
}


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

void solve(long long N, std::string S, long long Q, std::vector<long long> k)
{

    for (ll i = 0; i < Q; i++) {
        ll D = 0;
        ll M = 0;
        ll DM = 0;
        ll DMC = 0;
        ll ans = 0;
        for (ll j = 0; j < N; j++) {
            if (j - k[i] >= 0) {
                if (S[j - k[i]] == 'D') {
                    D--;
                    DM -= M;
                }
                if (S[j - k[i]] == 'M') {
                    M--;
                }
            }
            if (S[j] == 'D') {
                D++;
            }
            if (S[j] == 'M') {
                M++;
                DM += D;
            }
            if (S[j] == 'C') {
                DMC += DM;
            }
            ans = max(ans, DMC);
        }
        cout << ans << "\n";
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::string S;
    std::cin >> S;
    long long Q;
    scanf("%lld", &Q);
    std::vector<long long> k(Q - 1 - 0 + 1);
    for (int i = 0; i < Q - 1 - 0 + 1; i++) {
        scanf("%lld", &k[i]);
    }
    solve(N, S, Q, std::move(k));
    return 0;
}


Measured memory_bytes: 2308
#include <iostream>
#include<bits/stdc++.h>
#include<string>
#define ll long long

using namespace std;

 int main()
 {
     ll n,m;
     cin>>n>>m;
     ll sum=0;
     for(ll i=0;i<m;i++)
     {
         ll t;
         cin>>t;
         sum=sum+t;
     }
     if(sum>n)
     cout<<-1<<endl;
     else
      cout<<n-sum<<endl;
      return 0;
 }

Measured memory_bytes: 3624