akhauriyash/Code-Regression huggingface dataset:
N, K = [int(i) for i in input().split()]
sunuke = [1 for _ in range(N)]
for k in range(K):
	d = int(input())
	A = [int(i) for i in input().split()]
	for i in range(d):
		sunuke[A[i]-1] = 0

print(sum(sunuke))


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

int main(){
  int n;
  cin >> n;
  map<int,int> ni;
  int ans =1;
  while(!ni.count(n)){
    ni[n]=1;
    n = (n%2==0 ? n/2:3*n+1);
    ans ++;
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  ll x,t;cin>>x>>t;

  if(x-t>=0)out(x-t)
  else out(0)
  
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();  
        int N, K;
        {int[] a = r.ii(); N = a[0]; K = a[1];}
        String S = r.s();          
        int[] data = new int[N+2];
        int j = 0;
        int value = S.charAt(0)-'0';
        if(value == 0){
            data[j++] = 0;
        }
        for(int i = 0; i < N; value = 1-value){
            int count = 0;
            try{
                while(S.charAt(i)-'0' == value){
                    count++;
                    i++;
                }            
            } catch(StringIndexOutOfBoundsException e){}
            data[j++] = count;
        }
        if(value == 1)
            data[j++] = 0;
            
        int size = j,
            sum = 0;
        for(int i = 0; i < Math.min(2*K+1, size); i++)
            sum += data[i];
        
        int max = sum;
        for(int i = 3; i+2*K-1 < size; i += 2){
            sum += -data[i-3] - data[i-2] + data[i+2*(K-1)]+data[i+2*K-1];
            if(max < sum)
                max = sum;    
        }
        System.out.println(max);    
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23124
import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String args[])throws IOException{
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String s;
       while((s=br.readLine())!=null){
           String[] str = s.split(" ");
           int n = Integer.parseInt(str[0]);
           int x = Integer.parseInt(str[1]);
           if(n==0 && x==0) break;
           int count=0;
           for(int i=1; i<n; ++i){
               for(int j=i; j<n; ++j){
                   if(i==j) continue;
                   int num = x - (i+j);
                   if(num<1) break;
                   if(num<j) break;
                   if(i != num && j != num && num <= n) count++;
                   num = 0;
               }
           }     
       System.out.println(count);
       }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

bool scomp(const string& a, const string& b){
  if (a.size() != b.size()) return a.size() < b.size();
  return a < b;
}

int main()
{
  int w, h;
  while (w = in(), h = in()){
    string dp[80][80];
    char field[80][80];
    for (int i = 0; i < h; i++) scanf("%s", field[i]);
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        if (isdigit(field[i][j]) && field[i][j] != '0'){
          dp[i][j] += field[i][j];
        }
      }
    }
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        if (!isdigit(field[i][j])) continue;
        if (i > 0 && isdigit(field[i - 1][j]) && dp[i - 1][j] != "0"){
          dp[i][j] = max(dp[i][j], dp[i - 1][j] + field[i][j], scomp);
        }
        if (j > 0 && isdigit(field[i][j - 1]) && dp[i][j - 1] != "0"){
          dp[i][j] = max(dp[i][j], dp[i][j - 1] + field[i][j], scomp);
        }
      }
    }
    string best = "";
    for (int i = 0; i < h; i++){
      best = max(best, *max_element(begin(dp[i]), end(dp[i]), scomp), scomp);
    }
    cout << best << endl;
  }
  return 0;
}

Measured memory_bytes: 1412
#include<iostream>
//#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
#include<map>
#include<vector>
#include <iomanip>
#include <set>
#include<cmath>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
#define int long long
#define mp make_pair
#define error(x) cout<<#x<<"="<<(x)<<endl;
void sp(double y,int x){cout<<fixed<<setprecision(x)<<y;}
int inf=1e15+10;
int const M=2e5+10;
int const M2=1e6+10;
int const M3=1e3+10;
int mod=1e9+7;
map<int,int>mark;
int a[M],dp[M3][M3];
int v[M];
int r;
int n;
int minn=inf,now=0;
int adj[M3][M3];
void bt(int t,int last)
{
 //   cerr<<now<<" "<<last<<" "<<t<<endl;
    if(t==0){
        minn=min(now,minn);
        return;
    }
    for(int i=1;i<=t;i++)
    {
        int tmp=now;
        now+=dp[last][v[i]];
        swap(v[i],v[t]);
        bt(t-1,v[t]);
        now=tmp;
        swap(v[i],v[t]);
    }
}
int sa(int x,int y){if(x%y==0)return x/y;return x/y+1;}
int binp(int x,int y){int ans=1;int t=x;while(y!=0){if(y%2==1){ans*=t;ans;}y/=2;t*=t;t;}return ans;}
main(){
	ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	int m;
	cin>>n>>m>>r;
	int a,b,c;
	for(int i=1;i<=r;i++)
    {
        cin>>v[i];
    }
    for(int i=1;i<=m;i++)
        cin>>a>>b>>c,adj[a][b]=c,adj[b][a]=c;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(adj[i][j]!=0 || i==j)
                dp[i][j]=adj[i][j];
            else
                dp[i][j]=inf;
        }
    }
    //cerr<<"******"<<endl;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                if(j==k)
                    continue;
                dp[j][k]=min(dp[j][k],dp[j][i]+dp[i][k]);
            }
        }
    }
   // for(int i=1;i<=n;i++)
   // {
      //  for(int j=1;j<=n;j++)
            //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    //}
    bt(r,0);
    cout<<minn;
}

Measured memory_bytes: 7552
while True:
  n,m = map(int,input().split())
  if n + m == 0:
    break
  Taro = [int(input()) for _ in range(n)]
  Hana = [int(input()) for _ in range(m)]
  st = sum(Taro)
  sh = sum(Hana)
  for t in range(n):
    for h in range(m):
      if st - 2*Taro[t] == sh - 2*Hana[h]:
        print(Taro[t],Hana[h])
        st = 114514
        break
      if t==n-1 and h==m-1:
        print(-1)
    if st==114514:
      break


Measured memory_bytes: 5600
X, Y, A, B, C = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

pi, qi, ri = 0, 0, 0
ans = 0
for i in range(X + Y):
  x, y, z = 0, 0, 0
  if pi != A and X != 0:
    x = p[pi]
  if qi != B and Y != 0:
    y = q[qi]
  if ri != C:
    z = r[ri]

  if z >= x and z >= y:
    ans += z
    ri += 1
  elif x >= y:
    ans += x
    pi += 1
    X -= 1
  else:
    ans += y
    qi += 1
    Y -= 1

print(ans)

Measured memory_bytes: 22720
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>//cout << fixed からの cout << setprecision(n) << 小数　によって小数を整数部分含めてn桁表示できるようにする
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int r,c;
  int total;
  cin >> r >> c;
  int s[101][101] = {};
  for(int i = 0;i < r; i++){
    for(int j = 0;j < c;j++){
      cin >> s[i][j];
    }
  }
  for(int i = 0;i < r; i++){
    for(int j = 0;j < c;j++){
      total += s[i][j];
    }
    s[i][c] = total;
    total = 0;
  }

  for(int j = 0;j < c+1; j++){
    for(int i = 0;i < r;i++){
      total += s[i][j];
    }
    s[r][j] = total;
    total = 0;
  }
  for(int i = 0;i <= r; i++){
    for(int j = 0;j <= c;j++){
      cout << s[i][j];
      if(j != c){
        cout << " ";
      }
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3120
// adulterous affairs code
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i, 0, 12) {
        if (i == 4)cout << " ";
        cout << s[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int a,b,k,i;
  int ans = 0;
  int cnt = 0;
  cin >> a >> b >> k;

  for(i=min(a,b);i>0;i--){
      if(a%i == 0 && b%i == 0){
          ans = i; cnt ++;
          if(cnt == k){break;}
      }
  }

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


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    if(a.at(i)%2==0 && a.at(i)%3!=0 && a.at(i)%5!=0){
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;   
}


Measured memory_bytes: 256
n = int(input())
ta = [list(map(int, input().split())) for i in range(n)]

t = 1
a = 1

for i in range(n):
    x = max(t//ta[i][0], a//ta[i][1])
    if t > ta[i][0] * x or a > ta[i][1] * x:
        x += 1
    t = ta[i][0] * x
    a = ta[i][1] * x

print(t+a)

Measured memory_bytes: 3188
#import<cstdio>
#define r(a) for(int i=0;i<a;i++)
#define s (scanf("%d",&w),w)
#define c(a,b) a=a<b?a:b
int w,n,m,d[10000],*p;main(){p=d+999;n=s;m=s;r(n)d[i]=s;r(n)p[i]=1e9;r(m){s;r(n)c(p[i],p[i+1]+w*d[n-i-1]);}printf("%d\n",*p);}

Measured memory_bytes: 1032
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    int D,N;
    cin>>D>>N;

    if(D==0){
        if(N==100){
            cout<<101<<endl;
        }else{
            cout<<N<<endl;
        }
    }else if(D==1){
        if(N==100){
            cout<<10100<<endl;
        }else{
            cout<<N*100<<endl;
        }
    }else{
        if(N==100){
            cout<<1010000<<endl;
        }else{
            cout<<N*10000<<endl;
        }
    }
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*GRAPH_TEMPLATE=============================================*/
template<typename T>
class Edge {
public:
    int srch; //searched?探索状態記録「null = -1」
    int to; //辺の行き先
    T cost; //辺の重み
    Edge(int t, T w) : srch(-1), to(t), cost(w) {}
    Edge(int src, int t, T w) : srch(src), to(t), cost(w) {}
};
template<typename T>
using W_Graph = vector<vector<Edge<T>>>;   //重み付きグラフ
using Graph = vector<vector<int>>;         //通常グラフ
template<typename T>
using Matrix = vector<vector<T>>;          //隣接行列(使わなさそう...)

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    W_Graph<ll> g(n);
    rep(i,n-1) {
        int a,b,c; cin >>a>>b>>c;
        --a;--b;
        g[a].emplace_back(b,c);
        g[b].emplace_back(a,c);
    }
    int q,k; cin >> q >> k;
    --k;
    vec<PII> xy(q);
    rep(i,q) {
        cin >> xy[i].first >> xy[i].second;
        --xy[i].first;
        --xy[i].second;
    }

    //dijkstraでｋからの距離を前計算
    vll dist(n, infll);
    using P = pair<ll, int>;
    priority_queue<P, vec<P>, greater<P>> que;
    dist[k] = 0;
    que.emplace(0,k);
    while(que.size()) {
        ll d; int u;
        tie(d,u) = que.top(); que.pop();
        for(auto &v : g[u]) {
            if(!chmin(dist[v.to], dist[u]+v.cost)) continue;
            que.emplace(dist[v.to], v.to);
        }
    }

    //query
    rep(i,q) {
        int x, y;
        tie(x,y) = xy[i];
        cout << dist[x] + dist[y] << endl;
    }
}

Measured memory_bytes: 12416
n = int(input())
a = list(map(int, input().split()))

dp = [[0] * 2 for i in range(n)]
dp[0] = [a[0], -a[0]]

for i in range(n - 1):
    dp[i + 1][0] = max(dp[i][0] + a[i + 1], dp[i][1] - a[i + 1])
    dp[i + 1][1] = max(dp[i][0] - a[i + 1], dp[i][1] + a[i + 1])

print(dp[n - 1][0])


Measured memory_bytes: 25572
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
xy = []
for _ in range(n):
    xy.append(tuple(list(li())))

# 偶奇が一致しているか判定
consis = True    
odev = (xy[0][0] + xy[0][1]) % 2
for x,y in xy[1:]:
    if (x+y)%2 != odev:
        consis = False
        
if consis:
    # x+yが奇数なら2**31～2**0, x+yが偶数なら2**31～2**0,2**0の腕を用意
    m = 0
    if odev == 1:
        m = 32
        ds = [2**i for i in range(31,-1,-1)]
    else:
        m = 33
        ds = [2**i for i in range(31,-1,-1)] + [1]
        
    print(m)
    print(" ".join([str(d) for d in ds]))
    
    # それぞれのx,yをu-v座標に変換
    for x,y in xy:
        u = x+y
        v = x-y
        
        # res=0 から target=uに至るまでの足し算を考える
        us = []
        res = 0
        target = u
        for d in ds:
            if target > res:
                us.append(1)
                res += d
            else:
                us.append(-1)
                res -= d
           
        # res=0 から target=vに至るまでの足し算を考える
        vs = []
        res = 0
        target = v
        for d in ds:
            if target > res:
                vs.append(1)
                res += d
            else:
                vs.append(-1)
                res -= d
                
        # ( u, v) : command
        # (-1,-1) :   L
        # ( 1, 1) :   R
        # (-1, 1) :   D
        # ( 1,-1) :   U
        ans = []
        for u,v in zip(us, vs):
            if u==-1 and v==-1:
                ans.append("L")
            elif u==1 and v==1:
                ans.append("R")
            elif u==-1 and v==1:
                ans.append("D")
            elif u==1 and v==-1:
                ans.append("U")
            
        print("".join(ans))

else:
    print(-1)

Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<deque>
using namespace std;

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

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

    deque<int> col;
    col.push_front(a[0]);
    int left, right, mid;

    for(int i = 1; i < n; i++){
        if(a[i] <= col[0]) col.push_front(a[i]);
        else{
            left = 0;
            right = col.size() - 1;
            while(left < right){
                mid = (left + right) / 2;
                if(a[i] <= col[mid]) right = mid;
                else left = mid + 1;
            }
          	if(col[left] >= a[i]) col[left-1] = a[i];
            else col[left] = a[i];
        }
    }

    cout << col.size() << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
    fio();
    ll a;
    double b;
    cin >> a >> b;
    cout << (ll)(a * (ll)((b + 0.00000001) * 100) / 100) << endl;
}

Measured memory_bytes: 3804
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    s: String
    }
    let ans = match &s[..] {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        _ => 1,
    };
    println!("{}", ans);
}


Measured memory_bytes: 2120
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

lcm = c * d // gcd(c, d)

b_c = b - b // c
b_d = b - b // d
b_cd = b - b // lcm
z_to_b = b_c + b_d - b_cd

am1 = a-1
a_c = am1 - am1 // c
a_d = am1 - am1 // d
a_cd = am1 - am1 // lcm
z_to_a = a_c + a_d - a_cd

print(z_to_b - z_to_a)


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

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 llINF = 1LL << 60;
const int iINF = 1e9;

//---snuke mint---
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){} //ll = x; x = x%mod+mod)%mod; と同じらしい
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
//---main---------------------------------------------
int main(){
    //main
    int N;
    cin >> N;
    mint ans=0;
    if(N==1){
        cout << ans << endl;
        return 0;
    }

    vector<mint> e(N+1);
    e[N] = 1;
    for(int i=N-1;i>=2;i--){
        e[i] = e[i+1]*8;
    }
    
    mint c,t;
    c=N;
    t=0;
    for(int i=2;i<=N;i++){
        c = (c*(N-i+1))/i;
        t = t*2+2;
        //cout << i << ":" << c << "," << t << "," << e[i] << endl;
        ans += c*t*e[i];
    }
    
   cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11096
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    long long D, N;
    cin >> D >> N;
    
    long long ans;
    long long ans1 = 0, ans2 = 0, ans3 = 0;

    for(long long i = 1; ; ++i){
        if(D == 0){
            if(i % 100 != 0){
                ans = i;
                ++ans1;
                if(ans1  == N){
                    break;
                }
            }
        }
        else if(D == 1){
            if(i % 100 == 0 && i % (100 * 100) != 0){
                ans = i;
                ++ans2;
                if(ans2  == N){
                    break;
                }
            }
        }
        else if(D == 2){
            if(i % (100 * 100) == 0 && i % (100 * 100 * 100) != 0){
                ans = i;
                ++ans3;
                if(ans3  == N){
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

/*****************************************************************************/
/*****   1秒間で処理できるfor文ループの回数                                 *****/
/*****   → 10^8 = 100,000,000 回程度                                      *****/
/*****                                                                   *****/
/*****   sort(a, a+N, greater<int>()); // a[0:N) を大きい順にソート        *****/
/*****                                                                   *****/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s;
  rep(i, Size(s)) {
    if (s[i] == '7') ans++;
  }
  if (ans)
    Cout("Yes");
  else
    Cout("No");
  return 0;
}

Measured memory_bytes: 3656
p = [1, 2, 3, float("inf")]
sum_p = [0, 0, 0, 0] 
n = int(input())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
for i in range(n):
    
    diff = abs(x[i] - y[i])
    if sum_p[3] < diff:
        sum_p[3] = diff  
    sum_p[0] += diff ** p[0]
    sum_p[1] += diff ** p[1]
    sum_p[2] += diff ** p[2]

for i in range(len(sum_p)):
    if i < 3:
        print("{:.8f}".format(sum_p[i] ** (1/p[i])))
    else:
        print("{:.8f}".format(sum_p[i]))



Measured memory_bytes: 5656
def calc(s,c)
  num=Array.new(4)
  num[3]=s/500
  s=s-500*num[3]
  num[2]=s/100
  s=s-100*num[2]
  num[1]=s/50
  s=s-50*num[1]
  num[0]=s/10
  return num
end

nf=false
while(money=gets.to_i)
  if money==0
    break
  end
  if nf
    print "\n"
  end
  nf=true
  c=gets.chomp.split(/ /).map{|i| i.to_i}
  m=[10,50,100,500]
  sum=0
  for i in 0..3
    sum+=c[i]*m[i]
  end
  t=calc(sum-money,c)
  for i in 0..3
    if c[i]-t[i]>0
      print m[i]," ",c[i]-t[i],"\n"
    end
  end
end

Measured memory_bytes: 8788
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
using namespace std;

int main(){

    int N;cin>>N;
    LL dis[N][N];
    REP(i,N)REP(j,N)cin>>dis[i][j];

    LL ans =0;
    REP(i,N)for (int j=i+1;j<N;j++)ans += dis[i][j];

    REP(k,N) {
        REP(i, N) {
            REP(j, N) {
                if (dis[i][j] > dis[i][k] + dis[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }

    REP(i,N)for(int j=i+1;j<N;j++){
            REP(k,N){
                if(k==i||k==j)continue;
                if(dis[i][k]+dis[k][j]==dis[i][j]){
                    ans -= dis[i][j];
                    break;
                }
            }
        }



    cout<<ans<<endl;



    return 0;
}

Measured memory_bytes: 896
n = int(input())
d = list(map(int,input().split()))
if n >= 12:
    count = [0]*24
    count[0] += 2
    for i in d:
        count[i] += 1
        count[(24-i)%24] += 1
    if max(count) > 2:
        print(0)
    else:
        print(1)
    exit()
ans = 0
for i in range(1<<n):
    l = [0,24]
    for j in range(n):
        if i>>j & 1:
            l.append(d[j])
        else:
            l.append(24-d[j])
    l.sort()
    count = 24
    for j in range(len(l)-1):
        count = min(count,l[j+1]-l[j])
    ans = max(ans,count)
print(ans)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  string s;
  cin >> s;

  reverse(ALL(s));

  int n = 1;
  vector<int> moda;
  REP(i,s.size()){
    int m = s[i] - '0';
    moda.emplace_back((n * m) % 2019);
    
    n = (n * 10) % 2019;
  }

  map<int, int> mp;
  mp[0]=1;
  int t = 0;
  REP(i,moda.size()){
    t = (t + moda[i]) % 2019;
    mp[t]++;
  }
  
  // REP(i,moda.size()){
  //   cout << moda[i] << endl;
  // }

  ll ans=0;
  for(auto &v: mp){
    ans += (v.second * (v.second - 1))/2;
  }

  cout << ans << endl;

}



Measured memory_bytes: 4428
nyu = true

while nyu == true do
  x, y= gets.chomp.split(" ").map(&:to_i)
  if x == 0 && y == 0
    nyu = false
  else
    y.times do
      print "#"
    end
    puts ""

    (x - 2).times do
      print "#"
      (y - 2).times do
        print "."
      end
      print "#"
      puts ""
    end

    y.times do
      print "#"
    end
    puts ""
    puts ""
  end
end





Measured memory_bytes: 6868
#include <cstdio>
#include <cstring>

const int N = 400;
const int MOD = (int)1e9 + 7;

int n, c, a[N], b[N], sum[N + 1][N + 1], ways[2][N + 1];

void update(int& x, int a)
{
    x += a;
    if (x >= MOD) {
        x -= MOD;
    }
}

int main()
{
    for (int i = 1; i <= N; ++ i) {
        sum[i][0] = 1;
        for (int j = 1; j <= N; ++ j) {
            sum[i][j] = 1LL * sum[i][j - 1] * i % MOD;
        }
        for (int j = 0; j <= N; ++ j) {
            update(sum[i][j], sum[i - 1][j]);
        }
    }
    scanf("%d%d", &n, &c);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
    }
    for (int i = 0; i < n; ++ i) {
        scanf("%d", b + i);
    }
    ways[0][0] = 1;
    for (int i = 0; i < n; ++ i) {
        memset(ways[i + 1 & 1], 0, sizeof(ways[i & 1]));
        for (int s = 0; s <= c; ++ s) {
            for (int k = 0; s + k <= c; ++ k) {
                update(ways[i + 1 & 1][s + k], 1LL * ways[i & 1][s] * (sum[b[i]][k] + MOD - sum[a[i] - 1][k]) % MOD);
            }
        }
    }
    printf("%d\n", ways[n & 1][c]);
}


Measured memory_bytes: 768
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

#include <cstdint>

template <std::uint_fast64_t Modulus = 1000000007ULL> class Modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr Modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr Modint operator+(const Modint rhs) const noexcept {
    return Modint(*this) += rhs;
  }
  constexpr Modint operator-(const Modint rhs) const noexcept {
    return Modint(*this) -= rhs;
  }
  constexpr Modint operator*(const Modint rhs) const noexcept {
    return Modint(*this) *= rhs;
  }
  constexpr Modint operator/(const Modint rhs) const noexcept {
    return Modint(*this) /= rhs;
  }
  constexpr Modint &operator+=(const Modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr Modint &operator-=(const Modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr Modint &operator*=(const Modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr Modint &operator/=(Modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using namespace std;

// ?????????a
// dp[i] i文字目まで使った時の通り数
// ?????????a
// ???a??a??a
//  -> ???a??a??|a なにもしない dp[i - 1]
//  -> ???a??|aaaa 1個目のa dp[i - k]
//  -> ???|aaaaaaa 2個目のa dp[i - k]

// . 4 2 5 4 2 4
// 1 1 1 1 2 3 5
// . -> "" (1)
// 4 -> 4 (1)
// 4 2 -> 4 2 (1)
// 4 2 5 -> 4 2 5 (1)
// 4 2 5 4 -> 4 4 4 4, 4 2 5 4 (2)
// 4 2 5 4 2 -> 4 4 4 4 2, 4 2 2 2 2, 4 2 5 4 2 (3)

// . 1 2 1 2 2 2 2 1 2
// 1 1 1 2 3 3 3 3 5 
template <std::uint_fast64_t Modulus = 1000000007ULL>
std::ostream& operator<<(std::ostream& os, const Modint<Modulus>& obj)
{
    os << obj.value();
    return os;
}

int n;
vector<Modint<>> dps(2 * 100000, 0);
vector<int> c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<Modint<>> dp;
    cin >> n;
    dp.resize(n + 1);
    c.resize(n);
    REP(i, n) cin >> c[i];
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        if (i >= 2 && c[i - 1] == c[i - 2]) {
            dp[i] = dp[i - 1];
        } else {
            dp[i] = dps[c[i - 1]] + dp[i - 1];
            dps[c[i - 1]] += dp[i - 1];
        }
    }
    // DV(dp);
    cout << dp[n].value() << endl;
}


Measured memory_bytes: 4224
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<random>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1e9;
typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 500+10
    ll A,B,ans;
int main(){
    cin>>A>>B;
    if(abs(B)-abs(A)>0){
        if(A>=0){
            ans=abs(B)-abs(A);
            if(B<0)ans++;
        }else{
            ans=abs(B)-abs(A)+1;
            if(B<0)ans++;
        }
    }else{
        if(A<=0){
            ans=-abs(B)+abs(A);
            if(B>0)ans++;
        }else{
            ans=-abs(B)+abs(A)+1;
            if(B>0)ans++;
        }
    }
    cout<<ans;
}


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

typedef long long               ll;
typedef unsigned long long      ull;

const int N = 5 * 100 * 1000 + 20;

vector <ll> adj[N], Adj[N];
bool vis[N], mark[N];
ll col[N], Col[N], Ans[N];

void dfs(ll v, ll c) {
    vis[v] = true;
    col[v] = c;
    for (auto u: adj[v])
        if (col[u] == -1)
            dfs(u, c);
}

void DFS(ll v, ll c) {
    mark[v] = true;
    Col[v] = c;
    for (auto u: Adj[v])
        if (Col[u] == -1)
            DFS(u, c);
}

int main() {
    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    ll n, k, l;
    cin >> n >> k >> l;
    for (int i = 0, u, v; i < k; i++) {
        cin >> v >> u;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 0, u, v; i < l; i++) {
        cin >> v >> u;
        Adj[u].push_back(v);
        Adj[v].push_back(u);
    }
    ll C = 0, C1 = 0;
    fill(col, col + n + 20, -1);
    fill(Col, Col + n + 20, -1);
    for (int i = 1; i <= n; i++) {
        if (col[i] == -1)
            dfs(i, C);
        C++;
    }
    for (int i = 1; i <= n; i++) {
        if (Col[i] == -1)
            DFS(i, C1);
        C1++;
    }
    map <pair <ll, ll>, vector <ll>> Mp;
    for (int i = 1; i <= n; i++)
        Mp[{col[i], Col[i]}].push_back(i);
    for (auto x: Mp) {
        ll sz = x.second.size();
        for (auto i: x.second)
            Ans[i] = sz;
    }
    for (int i = 1; i <= n; i++)
        cout << Ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 61708
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;

long long N;
vector<long long> p;

bool isOK(int swap_num) {
    vector<long long> copy = p;
    for (int i = 0; i < N - 1; i++) {
        if (copy[i] == i) {
            swap(copy[i], copy[i + 1]);
            swap_num--;
        }
    }
    if (copy[N - 1] == N - 1) {
        swap_num--;
    }
    return (swap_num >= 0);
}

int main()
{
    cin >> N;
    p.resize(N);
    REP (i, N) {
        cin >> p[i];
        p[i]--;
    }

    int ng = -1, ok = N;
    while (ng + 1 != ok) {
        int mid = (ok + ng) / 2;
        if (isOK(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}


Measured memory_bytes: 1792
n = int(input())
lst1 = []
for i in range(1, n+1):
    if i % 3 == 0:
        lst1.append(i)
    else:
        j = 0
        lst2 = []
        while i >= 1:
            if i % 10 == 3:
                lst1.append(i*(10**j) + sum(lst2))
                break
            else:
                lst2.append((i%10)*(10**j))
                j += 1
                i = i // 10
print(' ', end='')
print(*lst1)


Measured memory_bytes: 6128
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    ll h,n;
    cin >> h >> n;
    ll sum = 0;
    for (ll i=0;i<n;i++){
        ll a;
        cin >> a;
        sum += a;
    }
    if(sum >= h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS 1e-10
#define equal(a,b) (fabs(a-b) < EPS)

struct Point{
  double x,y;

  Point(){}
  Point(double x,double y) : x(x),y(y) {}

  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
};

double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double norm(const Point &p){ return dot(p,p); }

istream &operator >> (istream &is,Point &p){ 
  return is >> p.x >> p.y;
}

typedef Point Vector;

struct Segment{
  Point s,t;
  Segment(){}
  Segment(Point s,Point t) : s(s),t(t) {}
};

Point crosspointSS(const Segment &a,const Segment &b){
  Vector va = a.t-a.s, vb = b.t-b.s;
  double d = cross(vb,va);
  return a.s+va*cross(vb,b.t-a.s)*(1.0/d);
}

int main(){
  int Q;
  Segment s1,s2;
  cin >> Q;
  while(Q--){
    cin >> s1.s >> s1.t >> s2.s >> s2.t;
    Point p = crosspointSS(s1,s2);
    printf("%.10f %.10f\n",p.x,p.y);
  }
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = 5042;
const int mod = (int)1e9 + 7;

int n;
vector<int> adj[MAXN];

void read()
{
	cin >> n;
	for(int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int cnt[MAXN];
int tr_sz[MAXN];
int dp[MAXN][MAXN][2];
int tmp[MAXN][2];

inline int mult(int x, int y) { return x * 1ll * y % mod; }

inline void add(int &x, int y) 
{  
	x += y;
	x %= mod;
}

int pre_dfs(int u, int pr)
{
	tr_sz[u] = 1;
	for(int v: adj[u])
		if(v != pr)
			tr_sz[u] += pre_dfs(v, u);
	return tr_sz[u];
}

void dfs(int u, int pr)
{
	for(int v: adj[u])
		if(v != pr)
			dfs(v, u);

	dp[u][1][0] = 1;

	int sz = 1;
	for(int i = 0; i <= n; i++) tmp[i][0] = tmp[i][1] = 0;
	for(int v: adj[u])
		if(v != pr)
		{
			for(int i = 0; i <= sz + tr_sz[v]; i++) tmp[i][0] = tmp[i][1] = 0;
			for(int p = 0; p < 2; p++)
				for(int sz1 = 1; sz1 <= sz; sz1++)
					if(dp[u][sz1][p]) 
						for(int p2 = 0; p2 < 2; p2++)
							for(int sz2 = 1; sz2 <= tr_sz[v]; sz2++)
								if(dp[v][sz2][p2])
								{
									add(tmp[sz1 + sz2][p ^ p2], mult(dp[u][sz1][p], dp[v][sz2][p2]));
									add(tmp[sz1][p ^ p2 ^ 1], mult(cnt[sz2], mult(dp[u][sz1][p], dp[v][sz2][p2])));
								}

			sz += tr_sz[v];
			for(int i = 0; i <= sz; i++)
				dp[u][i][0] = tmp[i][0], dp[u][i][1] = tmp[i][1];
		}
}

void solve()
{
	cnt[0] = 1;
	for(int i = 2; i <= n; i += 2)
		cnt[i] = (cnt[i - 2] * 1ll * (i - 1)) % mod;

	pre_dfs(1, 1);
	dfs(1, 1);

	int answer = 0;
	for(int c = 1; c <= n; c++)
	{
		answer = (answer + mult(cnt[c], dp[1][c][0])) % mod;
		answer = (answer + (mod - mult(cnt[c], dp[1][c][1]))) % mod;
	}

	cout << answer << endl;
}

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

	read();
	solve();
	return 0;
}



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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
    ll n, k;
    cin >> n >> k;
    if(k%2==1){
        cout << (n/k)*(n/k)*(n/k) << endl;
    }
    else{
        ll x = n/(k/2);
        if(x%2==0) cout << x*x*x/4 << endl;
        else{
            x /= 2;
            cout << x*x*x + (x+1)*(x+1)*(x+1) << endl;
        }
    }
}

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

using namespace std;

void inputData(int* data) {
	for (int i = 0; i < 10; i++) {
		cin >> data[i];
	}
}

int comp(const void *c1, const void *c2) {
	int tmp1 = *(int *)c1;
	int tmp2 = *(int *)c2;

	if( tmp1 > tmp2 )  return -1;
	if( tmp1 == tmp2 ) return  0;
	if( tmp1 < tmp2 )  return  1;
}

int calcUnivScore(const int* data) {
	int score = 0;
	for (int i = 0; i < 3; i++) {
		score += data[i];
	}
	return score;
}

int main()
{
	int univW[10], univK[10];
	inputData(univW);
	inputData(univK);

	qsort(univW, 10, sizeof(int), comp);
	qsort(univK, 10, sizeof(int), comp);

	int scoreW = calcUnivScore(univW);
	int scoreK = calcUnivScore(univK);

	cout << scoreW << " " << scoreK << endl;

	return 0;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  int n,m;
  cin >> n >> m;
  UnionFind tree(n);
  vector<int> p(n);
  for(int i=0;i<n;++i){
    cin >> p[i];
    p[i]--;
  }
  for(int i=0;i<m;++i){
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    tree.unite(x,y);
  }
  int cnt=0;
  for(int i=0;i<n;++i){
    if(tree.same(i,p[i]))cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using df = vector<vll>;
// df data(n, vll(m));
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, m, n) for (ll i = m; i < n; ++i)

vector<int> divisible(int n) {
  vector<int> res;
  for (int i = (int)sqrt(n) + 1; i > 0; --i) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) {
        res.push_back(n / i);
      }
    }
  }
  sort(res.rbegin(), res.rend());
  return res;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  rep(i, n) cin >> arr[i];
  int sum = 0;
  rep(i, n) sum += arr[i];

  vector<int> divs = divisible(sum);

  for (int div : divs) {
    vector<int> test(n);
    rep(i, n) test[i] = arr[i] % div;
    sort(test.begin(), test.end());
    int sum = 0;
    rep(i, n) sum += test[i];
    int change = 0;
    rep(i, n - sum / div) change += test[i];
    if (change <= k) {
      cout << div << endl;
      break;
    }
  }
}


Measured memory_bytes: 256