akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it,o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;


ll solve(ll N, ll h, ll n){
    ll upper = N * h *n;
    ll lower = 4 * h *n - N*n -N *h;
    if(lower == 0)return -1;
    if(upper % lower != 0)return -1;
    return upper / lower;
}

int main() {
    ll N;
    cin >> N;
    REP(i, 1, 3500+1){
        REP(j, 1, 3500+1){
            ll ans = solve(N, i, j);
            if(ans > 0){
                cout << i <<' ' << j << ' ' << ans <<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, K, eq = 0;
  std::cin >> N >> K;
  ll ans = N - K + 1;
  vector<ll> A(N);
  for(int i=0;i<N;i++) std::cin >> A[i];
  /*
  std::vector<int> B(N);
  for(int i=0;i+K-1<N;i++){
    for(int j=0;j<N;j++) B[j] = A[j];
    for(int j=0;j<i;j++) std::cout << A[j] << " ";
    std::vector<int> tmp;
    for(int j=i;j<i+K;j++) tmp.push_back(A[j]);
    sort(tmp.begin(), tmp.end());
    for(int j=0;j<K;j++) std::cout << tmp[j] << " ";
    for(int j=i+K;j<N;j++) std::cout << B[j] << " ";
    std::cout << '\n';
  }
  */
  set<int> las;
  ll count = 1;
  for(int i=1;i<N;i++){
    if(A[i-1]<A[i]) count++;
    else count = 1;
    if(count >= K) eq++, las.insert(i-(K-1));
  }
  set<ll> now;
  for(int i=0;i<K;i++) now.insert(A[i]);
  for(int i=0;i+K<N;i++){
    now.insert(A[i+K]);
    auto it = now.begin();
    auto itr = now.end();
    itr--;
    if((*it)==A[i]&&(*itr)==A[i+K] && las.find(i)==las.end()) ans--;
    now.erase(A[i]);
  }
  std::cout << ans - (eq>=2?eq-1:0) << '\n';
  return 0;
}


Measured memory_bytes: 11264
n,k=map(int,input().split())
it=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(it[1]-it[0])
for i in range(2,n):
    mi=dp[i-1]+abs(it[i-1]-it[i])
    for j in range(max(0,i-k),i):
        
        mi=min(dp[j]+abs(it[j]-it[i]),mi)
    dp[i]=mi
print(dp[-1])


Measured memory_bytes: 52448
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j;
    cin>>n;
    vector<int> v(n);
    for(i=0;i<n;i++) cin>>v[i];
    double ans;
    sort(v.begin(),v.end());
    ans=v[0];
    for(i=1;i<n;i++){
        ans=(ans+v[i])/2.0;
    }
    cout<<ans<<endl;
    return 0;
}


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


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = min({
    a+b,
    b+c,
    c+a
  });
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int a = sc.nextInt();

        double dh = (double)h;
        double da = (double)a;

        double ans = Math.ceil(dh / da);

        int ians = (int)ans;

        System.out.println(ians);

    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
const int N_MAX = 100;
int main (void) {
    int n;
    int a[2][N_MAX];
 
    cin >> n;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
 
    for (int i = 1; i < n; i++) a[0][i] += a[0][i - 1];
    a[1][0] += a[0][0];
    for (int i = 1; i < n; i++) {
        a[1][i] += max(a[0][i], a[1][i - 1]);
    }
 
    cout << a[1][n - 1] << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
    int n;
    cin>>n;
    ll a[n];
    rep(i,n){
        cin>>a[i];
        a[i]-=i+1;
    }
    sort(a,a+n);
    ll sum[n+1];
    sum[0]=0;
    rep(i,n)sum[i+1]=sum[i]+a[i];
    ll ans=longinf;
    rep(i,n){
        ll ret=a[i]*(i+1)-sum[i+1];
        ret+=sum[n]-sum[i+1]-a[i]*(n-i-1);
        ans=min(ans,ret);
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;
using System.Numerics;
using System.Text.RegularExpressions;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long Gcd(long x,long y)
        {
            if (x < y) Gcd(y, x);
            while (y > 0)
            {
                var z = x;
                x = y;
                y = z % y;
            }
            return x;
        }

        public static long Lcm(long x,long y)
        {
            return x * y / Lcm(x, y);
        }

        public static bool IsLowercaseAlphabet(char target)
        {
            return new Regex("^[a-z]+$").IsMatch(target.ToString());
        }

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var n = Read();
            var a = Reads();
            var b = a.OrderByDescending(x => x).ToArray();
            long ans = b[0];
            for (int i = 1; i <n/2 ; i++)
            {
                ans += b[i] * 2;
            }
            if (n % 2 == 1) ans += b[n / 2];
            WriteLine(ans);

            
            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 46128
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi p(n);

		for(int i=0;i<n;i++)
		{
			scanf("%d", &p[i]);
		}

		int ans=0;
		for(int i=1;i+1<n;i++)
		{
			if(p[i-1]<p[i] && p[i]<p[i+1]) ans++;
			if(p[i+1]<p[i] && p[i]<p[i-1]) ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pdd;

#define INF 0x7f7f7f
#define mem(a,b) memset(a , b , sizeof(a))
#define FOR(i, x, n) for(int i = x;i <= n; i++)
// const ll mod = 1e9 + 7;
// const int maxn = 1e5 + 10;
// const double eps = 1e-6;


ll yihuo(ll x)
{
    if (x % 4 == 0) {
        return x;
    } else if (x % 4 == 1)
    {
        return 1;
    } else if (x % 4 == 2)
    {
        return x + 1;
    } else if (x % 4 == 3)
    {
        return 0;
    } else
    {
        return 0;
    }
    
}

void solve()
{
    ll A, B;
    cin >> A >> B;
    cout << (yihuo(A - 1) ^ yihuo(B)) << endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    //cout.tie(nullptr);
#ifdef FZT_ACM_LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#else
    ios::sync_with_stdio(false);
    int T = 1;
    //cin >> T;
    while(T--)
        solve();
#endif
    return 0;
}


Measured memory_bytes: 3612
#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
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
const static ll MOD = 1e9 + 7;
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

int main() {
    int N; cin >> N;
    vector<pair<int, int>> a(100000), b(100000);
    rep(i, N / 2) {
        int x, y; cin >> x >> y;
        a[--x].first++; b[--y].first++;
        a[x].second = i+1; b[x].second = i+1;
    }

    sort(a.begin(), a.end(), greater<pii>()); sort(b.begin(), b.end(), greater<pii>());

    int minus = 0;
    if (a[0].second != b[0].second) {
        minus = N - a[0].first - b[0].first;
    }
    else {
        minus = N- max(a[0].first + b[1].first,a[1].first + b[0].first);
    }

    cout << minus << endl;
}


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

#define    int               long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    string s,t;
    cin>>s>>t;
    int ans=sz(t);
    f(i,0,sz(s)-sz(t))
    {
        int c=0;
        f(j,0,sz(t)-1)
            if(t[j]!=s[i+j])    c++;
        ans=min(ans,c);
    }
    cout<<ans;
}

Measured memory_bytes: 3652
import numpy as np
from collections import Counter

target_num = int(input())

test_ = []
for i in range(1, target_num+1):
    for v in range(1, target_num+1):
        test_.append(np.gcd(i, v))
count_dict = dict(Counter(test_))

sum_list = 0
for num in range(1, target_num+1):
    for i, v in count_dict.items():
        sum_list += np.gcd(num, i)*v
print(sum_list)

Measured memory_bytes: 28364
#include<iostream>
#include<cmath>
#include<string>

using std::cin;
using std::cout;
using std::endl;

int main()
{
	std::string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < 3;i++) {
		if (s[i] == '1') count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
    int s,w;cin>>s>>w;
    if(w>=s){
        cout<<"unsafe\n";
    }
    else{
        cout<<"safe\n";
    }
}

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

    int t;
    // cin >> t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())

ll Euler_phi_func(ll n) {
    ll res = n;
    for (ll i = 2; i*i <= n; ++i) {
        if (n%i == 0) {
            res -= res / i;
            while (n%i == 0)n /= i;
        }
    }
    if (n > 1)res -= res / n;
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    cout << Euler_phi_func(n) << endl;
    return 0;
}



Measured memory_bytes: 3220
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li, li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li, li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b) {
	if (b)cout << "Yes";
	else cout << "No";
}
void yes(li b) {
	if (b)cout << "yes";
	else cout << "no";
}

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

	li N,M;
	cin >>N>>M;
	if(N<M){
		Rep(i,M){
			cout<<N;
		}
	}
	else{
		Rep(i,N){
			cout<<M;
		}
	}
}

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

int main(){
  int A, B;
  cin >> A >> B;
  
  if ( A == B ) {
	cout << A + B << endl;
  } else if ( A > B ) {
	cout << 2 * A - 1 << endl;
  } else {
	cout << 2 * B - 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
from heapq import heappop, heappush
n = int(input())
inf = 100 * 100000

M = [[] for i in range(n)]

for i in range(n):
    L = list(map(int, input().split()))
    u = L[0]
    k = L[1]
    v = L[2::2]
    c = L[3::2]
    for j in range(k):
        M[u].append((v[j], c[j]))
result = [0] * n
S = set()
V = set(range(n))
S.add(0)
d = []
for m in M[0]:
    heappush(d, (m[1], m[0]))
T = V - S

while len(T) != 0:
    c, v = heappop(d)
    while v in S:
        c, v = heappop(d)
    result[v] = c
    S.add(v)
    T.remove(v)
    for m in M[v]:
        if m[0] in T:
            heappush(d, (result[v] + m[1], m[0]))

for i, v in enumerate(result):
    print(i, v)

Measured memory_bytes: 95468
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int[] a = in.readIntArray(n);
            int ans = 0;
            for (int i = 0; i < n; i++) ans += a[i] - 1;
            out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] ans = new int[size];
            for (int i = 0; i < size; i++) ans[i] = readInt();
            return ans;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 23124
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int n;
	cin >> n;
	vector<int> hoge;
	int back = -1;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (back != a) {
			back = a;
		}
		else {
			back = -1;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int solve(int n){
    int i = 1;
    int j = 1;
    int k = 1;
    int res = 0; 
    for(i = 1; i <= n; i++){
          for(j = 1; i * j <= n; j++){
                for(k = 1; ((i * i)+(j * j)+(k * k)+(i * j + j * k + k * i)) <= n; k++){
                    if(((i * i)+(j * j)+(k * k)+(i * j + j * k + k * i)) == n){
                         res++;
                    }
                }
          }
    }
  return res;
}

int main(){
  int n = 0;
  cin >> n;
  int res = 0;
  for(int i = 1; i <= n; i++){
    cout << solve(i) << "\n";
  }
  return 0;
}


Measured memory_bytes: 3620
/*
СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define zhfs main
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define re return
#define forn(i, n) for (int i = 1; i <= n; i++)
int cnt[1234], ccnt[1234];
int zhfs()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i = 0; i < 26; i++)
	{
		cnt[i] = 10100101;
	}
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		memset(ccnt, 0, sizeof(ccnt));
		for (int j = 0; j < (int)s.length(); j++)
		{
			ccnt[s[j] - 'a']++;
		}
		for (int j = 0; j < 26; j++)
		{
			cnt[j] = min(cnt[j], ccnt[j]);
		}
	}
	for (int i = 0; i < 26; i++)
	{
		for (int j = 0; j < cnt[i]; j++)
		{
			cout << (char)(i + 'a');
		}
	}
	cout << endl;
}



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

const int INF = 1e9 + 7;
int n;
int need_a, need_b, need_c;
vector<int> l;

int dfs(int dep, int a, int b, int c) {
  if ( dep == n ) {
    int ret = ( min(min(a, b), c) > 0 ) ? abs(a - need_a) + abs(b - need_b) + abs(c - need_c) - 30 : INF;
    return ret;
  }

  int ret0 = dfs(dep+1, a, b, c);
  int ret1 = dfs(dep+1, a+l[dep], b, c) + 10;
  int ret2 = dfs(dep+1, a, b+l[dep], c) + 10;
  int ret3 = dfs(dep+1, a, b, c+l[dep]) + 10;

  return min(min(ret0, ret1), min(ret2, ret3));
}

int main() {
  cin >> n >> need_a >> need_b >> need_c;
  for ( int i = 0; i < n; i++ ) {
    int len;
    cin >> len;
    l.push_back(len);
  }

  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}


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

int main(){
long long int N;
cin>>N;
long long int ans=0;
for(long long int k=1;k<N;k++){
if(k*k+k >= N) break;
if(N%k != 0)continue;
ans += N/k-1;
}
cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,q,a[100010],rank[100010]={},cnt=1,l,dat[100010]={100010};
    vector<int> res;
    cin >> n >> m >> q;
    REP(i,q){
        cin >> a[i];
    }
    for(int i= q-1; i>=0;--i){
        if(rank[a[i]]==0){
            rank[a[i]]=cnt;
            ++cnt;
            res.push_back(a[i]);
        }
    }
    REPN(i,1,m){
        if(rank[i]==0){
            rank[i]=cnt;
            ++cnt;
            res.push_back(i);
        }
    }

    for(int i=m-1;i>0;--i){
        if(res[i]<res[i-1]){
            l=i;
            break;
        }
    }

    for(int i= q-1; i>=0;--i){
        if(dat[rank[a[i]]]<dat[rank[a[i]]-1]){
        ++dat[rank[a[i]]];
        }
    }
    //REPN(i,1,l){
        if(dat[l]<n){
            cout << "No" <<endl;
            return 0;
        }
    //}
    cout << "Yes" <<endl;
    /*
    OUT(l)
    REP(i,m){
        OUT(res[i])
    }
    REP(i,m+1){
        OUT(dat[i])
    }
    //*/



    return 0;
}


Measured memory_bytes: 2044
#include <stdio.h>

int main(void){
  int n,i,j,k;
  scanf("%d",&n);
  int retsu[n];
  for (i = 1; i <= n; i++){
    k = n - i;
    scanf("%d",&retsu[k]);
  }
  for (j = 0; j < n; j++){
    if( j ) printf(" ");
    printf("%d",retsu[j]);
    }
    printf("\n");
 return 0;
}



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

int main(){
  int N, M;
  cin >> N >> M;
  vector<bool> AC(N, false);
  vector<int> WA(N, 0);
  int num_AC=0;
  for(int ii=0; ii<M; ii++){
    int p;
    string S;
    cin >> p >> S;
    p--;
    if(AC[p])continue;
    if(S=="AC"){
      num_AC++;
      AC[p]=true;
    }else{
      WA[p]++;
    }
  }
  int num_WA=0;
  for(int ii=0; ii<N; ii++){
    if(AC[ii]) num_WA += WA[ii];
  }
  cout << num_AC << " " << num_WA << endl;
  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static System.Math;

class Program{
	static int x;
	static int y;
	static int z;
	static int k;
	static long[] a;
	static long[] b;
	static long[] c;

	static void Main(){
		string[] input = Console.ReadLine().Split();
		x = int.Parse(input[0]);
		y = int.Parse(input[1]);
		z = int.Parse(input[2]);
		k = int.Parse(input[3]);
		a = Console.ReadLine().Split().Select(long.Parse).ToArray();
		b = Console.ReadLine().Split().Select(long.Parse).ToArray();
		c = Console.ReadLine().Split().Select(long.Parse).ToArray();
		Array.Sort(a);
		Array.Sort(b);
		Array.Sort(c);
		List<long> ab = new List<long>();
		foreach (var ai in a)
			foreach (var bi in b)
				ab.Add(ai + bi);
		ab.Sort();
		List<long> large = new List<long>();
		foreach (var ci in c)
			for (int i = 1;i <= Min(3000,ab.Count);i++)
				large.Add(ci + ab[ab.Count - i]);
		large.Sort();
		for (int i = 1;i <= k;i++)
			Console.WriteLine(large[large.Count - i]);
	}
}

Measured memory_bytes: 63132
/** 	Author: Apoorva Mittal  **/
#include <bits/stdc++.h>

using namespace std;
#define int long long
#define endl "\n"
#define nl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<pair<int, int>>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repD(i, a, b) for (int i = a; i >= b; i--)
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define init(i, k) memset(i, k, sizeof i)
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define inp(a) rep(i, 0, a.size()) cin >> a[i];
#define out(a)                               \
    cout << #a << ": " << endl;              \
    rep(i, 0, a.size()) cout << a[i] << " "; \
    cout << endl;
#define out2d(a)                \
    cout << #a << ": " << endl; \
    rep(i, 0, a.size())         \
    {                           \
        rep(j, 0, a[0].size())  \
                cout            \
            << a[i][j] << " ";  \
        cout << endl;           \
    }

#define flush fflush(stdout);
#define lb lower_bound
#define ub upper_bound
#define maxe *max_element
#define mine *min_element
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define pqueue priority_queue
#define precise(x) cout << fixed << showpoint << setprecision(x);
#define setbit(x) __builtin_popcountll(x)
#define gcd(a, b) __gcd(a, b)
#define deb(x) cout << #x << " " << x << endl;
#define Y "YES"
#define N "NO"
const int mod = 1e9 + 7;

// ====== Useful functions begin ======
inline int add(int a, int b) { return ((a % mod) + (b % mod)) % mod; }
inline int sub(int a, int b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline int mul(int a, int b) { return ((a % mod) * (b % mod)) % mod; }
// ====== Useful functions end ======
const int inf = 1e13;
const int maxn = 1e3 + 5;

//--------------------------------------------------------------------------------------------------------------------------------
// int n;
//--------------------------------------------------------------------------------------------------------------------------------
void max_self(int &a,int b)
{
    a = max(a,b);
}
void min_self(int &a,int b)
{
    a = min(a,b);
}
void solve()
{
    int n,W;
    cin>>n>>W;
    vi w(n);
    vi P(n);
    int sum=0;
    rep(i,0,n)
    {
        cin>>w[i];
        cin>>P[i];
        sum+=P[i];
    }
    vector<int>dp(sum+1,inf);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int pa=sum-P[i];pa>=0;pa--)
        {
            min_self(dp[pa+P[i]], w[i] + dp[pa]);
        }
    }
    // out(dp)
    for(int p=sum;p>=0;p--)
    {
        if(dp[p] <= W)
        {
            cout<<p<<endl;
            return;
        }
    }
}
signed main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    speed;
    int t = 1;
    // cin >> t;

    for (int tt = 1; tt <= t; tt++)
    {
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
}

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

int main(){
    ll K, A, B;
    cin >> K >> A >> B;
    if(A + 2 >= B || K <= A - 1) cout << K + 1 << endl;
    else{
        if((K-A+1)%2==0){
            cout << A + (K-A+1)/2*(B-A) << endl;
        }else{
            cout << A + (K-A+1)/2*(B-A) + 1 << endl;
        }
    } 
}

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

int N, K;
string s;

signed main() {
  cin >> N >> K >> s;
  // 全部0、または全部1の時はこの処理をする
  if (count(s.begin(), s.end(), s[0]) == N) {
    cout << N << endl;
    return 0;
  }

  // 「-3, 1, -1」みたいな配列を作る処理を開始
  vector<int> v;
  int zero = 0, one = 0;
  int idx = 0; // 0, 1の境目
  for (int i = 0; i < N; i++) {
    if (s[i] != s[0]) {
      idx = i;
      break;
    }
    if (s[i] == '0') zero++;
    if (s[i] == '1') one++;
  }

  for (int i = idx; i < N; i++) {
    if (s[i] == '0') {
      if (one) {
        v.push_back(one);
        one = 0;
      }
      zero++;
    }

    if (s[i] == '1') {
      // dbg(zero)
      if (zero) {
        v.push_back(-zero);
        zero = 0;
      }
      one++;
    }
  }

  if (one) { v.push_back(one); }
  if (zero) { v.push_back(-zero); }

  // 「-3, 1, -1」みたいな配列を作る処理が終了

  vector<int> V;
  V.push_back(0); // vの先頭に0を追加した配列。累積和の配列と一緒に使うのでこうしたほうが使いやすくなる
  for (int i = 0; i < v.size(); i++) {
    V.push_back(v[i]);
  }

  vector<int> rui = V; // 累積和の配列
  // 累積和を作る処理
  for (int i = 0; i < rui.size(); i++) {
    rui[i] = abs(rui[i]);
  }
  for (int i = 1; i < rui.size(); i++) {
    rui[i] += rui[i-1];
  }

  // ここまでで前処理は完了したのであとは頑張って答えを求める

  int ans = 0;
  queue<int> que; // 選んだ範囲に含まれる連続する0の区間のインデックスを管理。このインデックスは累積和で使う
  int ii = 0; // 選ぶ区間のスタート位置のインデックス
  for (int i = 1; i < rui.size(); i++) {
    // 連続する0の区間のインデックスをキューに追加
    if (V[i] < 0) {
      que.push(i);
    }

    // キューのサイズがKを超えたらスタート位置を更新する
    if (que.size() > K) {
      ii = que.front(); que.pop();
    }

    // 答えを更新
    if (ans < rui[i] - rui[ii]) {
      ans = rui[i] - rui[ii];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1720
#include <stdio.h>
#define SIZE 32767

int main(void) {
    int i = 0;
    int x[SIZE] = {0};
    for(i = 0; i < SIZE; i++) {
        scanf("%d", &x[i]);
    }
    for(i = 0; i < SIZE; i++) {
        if(x[i] == 0) return 0;
        else {
            printf("Case %d: %d\n", i+1, x[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 736
import math

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)


def best_alignment(lst, small):

	ans = 0

	p = []

	if(small):
		p.append(lst[-1])
		p.append(lst[-1])
		del lst[-1:]
	else:
		m = min(lst)
		p.append(lst[0])
		p.append(lst[0])
		lst.pop(0)


	while(len(lst)>0):

		if(small):
			ans = ans + abs(max(p)-lst[0])
			if(len(lst)==1):
				break

			ans = ans + abs(min(p)-lst[1])

			p = []
			p.append(lst.pop(0))
			p.append(lst.pop(0))
			small = False
			continue
		else:
			ans = ans + abs(min(p)-lst[-1])
			if(len(lst)==1):
				break

			ans = ans + abs(max(p)-lst[-2])

			p = []
			p.append(lst[-1])
			p.append(lst[-2])
			del lst[-2:]
			small = True
			continue

	return ans	




N = int(input().strip())
A = []
for i in range(N):
	A.append(int(input().strip()))

A.sort()
A_=A.copy()

print(max(best_alignment(A, True), best_alignment(A_, False)))

Measured memory_bytes: 7908
#include<stdio.h>
int main()
{
    //int A,B,C,D,E;
    int X,Y;
    scanf("%d %d", &X, &Y);
    for(int i; i<=X; i++)
    {
      
    if((i*2)+(X-i)*4==Y)
    {
    	printf("Yes");
        return(0);
    }
      
    }
  	printf("No");
}

Measured memory_bytes: 1732
n = int(input())
dict_list = [{'a':0, 'b':0, 'c':0, 'd':0, 'e':0, 'f':0, 'g':0, 'h':0, 'i':0, 'j':0, 'k':0, 'l':0, 'm':0, 'n':0, 'o':0, 'p':0, 'q':0, 'r':0, 's':0, 't':0, 'u':0, 'v':0, 'w':0, 'x':0, 'y':0, 'z':0} for i in range(n)]

for i in range(n):
    S = input()
    for s in S:
        dict_list[i][s] += 1

dic = {'a':0, 'b':0, 'c':0, 'd':0, 'e':0, 'f':0, 'g':0, 'h':0, 'i':0, 'j':0, 'k':0, 'l':0, 'm':0, 'n':0, 'o':0, 'p':0, 'q':0, 'r':0, 's':0, 't':0, 'u':0, 'v':0, 'w':0, 'x':0, 'y':0, 'z':0}
for k, v in dic.items():
    dic[k] = 100
    for j in range(n):
        dic[k] = min(dict_list[j][k], dic[k])

W = []
for k, v in dic.items():
    for i in range(v):
        W.append(k)

W.sort()
W = ''.join(W)

print(W)


Measured memory_bytes: 3192
import sys
from collections import defaultdict, deque


def main():
    S = input()

    o = ['R', 'U', 'D']
    e = ['L', 'U', 'D']

    counter = 0
    for i in range(len(S)):
        if (i+1) % 2 == 1 and S[i] in o or (i+1) % 2 == 0 and S[i] in e:
            counter += 1
    if counter == len(S):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define base 402653189
#define mod 998244353
#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
#define MX 2000005

int n;
string str;
struct dataa{
	int first;
	int second;
};
dataa pr[MX];

int open = 0;
int close = 0;
vector<int>pvt,nvt;
vector<int>res;

void process(int pos){
	int len = str.size();
	pr[pos].first = 0;
	pr[pos].second = 0;

	for (int i = 0; i < len; i++){
		if (str[i] == '(') pr[pos].first++;
		else if (pr[pos].first) pr[pos].first--;
	}
	for (int i = len - 1; i >= 0; i--){
		if (str[i] == ')') pr[pos].second++;
		else if (pr[pos].second)pr[pos].second--;
	}
	//cout<<"Pos "<<pos<<" "<<pr[pos].first<<" "<<pr[pos].second<<endl;

	if (pr[pos].first >= pr[pos].second) pvt.push_back(pos);
	else nvt.push_back(pos);
}
bool cmp(int &tmp, int &tpp){
	return (pr[tmp].second < pr[tpp].second);
}
bool comp(int &tmp, int &tpp){
	return (pr[tmp].first > pr[tpp].first);
}

int main(){
	optimize();
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> str;
		process(i);
	}
	sort(pvt.begin(), pvt.end(), cmp);
	sort(nvt.begin(), nvt.end(), comp);
	
	vector<int>res;
	res.reserve(n);
	res.insert(res.end(), pvt.begin(), pvt.end());
	res.insert(res.end(), nvt.begin(), nvt.end());


	for (auto now : res){
		if (pr[now].second <= open) open += (pr[now].first - pr[now].second);
		else{
			cout << "No\n";
			return 0;
		}
	}
	if(open==0){
      	cout << "Yes\n";
		//for (int i = 0; i < n; i++) cout << res[i] << " ";
    }
  	else{
      	cout<<"No\n";
    }
	return 0;
}


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

int main() {
  long long num;
  long long zanHp = 0;
  long long zanAtk = 0;
  long long cnt = 0;
  cin >> num;
  
  vector<long long> vecHp(num+1);
  vector<long long> vecAtk(num);
  
  for(int i = 0; i < num + 1; i++) cin >> vecHp.at(i);
  for(int i = 0; i < num; i++) cin >> vecAtk.at(i);
  
  for(int i = 0; i < num; i++){
    if(vecHp.at(i) >= vecAtk.at(i)){
      // HP >= ATK
      cnt += vecAtk.at(i);
    }else{
      // HP < ATK
      cnt += vecHp.at(i);
      vecAtk.at(i) -= vecHp.at(i);
      if(vecHp.at(i+1) >= vecAtk.at(i)){
        cnt += vecAtk.at(i);
        vecHp.at(i+1) -= vecAtk.at(i);
      }else{
        cnt += vecHp.at(i+1);
        vecHp.at(i+1) = 0;
      }
    }
  }
  
  cout << cnt;
}


Measured memory_bytes: 1792
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f
int mmap[1005][1005];
int arr[12345];
int main()
 {
    int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int d=b*c;
	if(d>=a)
	printf("Yes\n");
	else
	printf("No\n"); 
}


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

int n, m;
vector<int> su;

int main(){
  scanf("%d%d", &n, &m);
  for(int i=0;i<n;i++){
    int suu; scanf("%d", &suu);
    su.push_back(suu);
  }
  sort(su.begin(), su.end());
  for(int i=0;i<n;i++){
    if(m < su[i]){
      printf("%d\n", i);
      return 0;
    }
    m -= su[i];
  }
  printf("%d\n", n - (m > 0));
  return 0;
}

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

int main(void){
    int n, count[200000] = {0};
    cin >> n;
    for(int i = 1; i < n; ++i){
        int num;
        cin >> num;
        count[num-1]++;
    }
    for(int i = 0; i < n; ++i){
        cout << count[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n;

int main() {
	cin >> n;
	vector<double> v(n);
	inc(i, n) { cin >> v[i]; }
	sort(RALL(v));
	
	while(SI(v) > 1) {
		double x = v.back();
		v.pop_back();
		v.back() = (v.back() + x) / 2.0;
	}
	
	printf("%.12f\n", v[0]);
	
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    double a, b, x;
    cin >> a >> b >> x;
    cout << setprecision(12);
    double square = x / a;
    if (square >= a * b / 2.0)
    {
        cout << atan2((a * b - square) * 2.0 / a, a) * 180.0 / M_PI << endl;
    }
    else
    {
        cout << 90.0 - atan2(2.0 * x / a / b, b) * 180.0 / M_PI << endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
  int h,n;
  cin>>h>>n;
  ll sum;
  for(int i=0; i<n ; i++){
    int tmp;
    cin>>tmp;
    sum += tmp;
  }
  if(sum>=h) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAXstr 1000000

char joiChar[MAXstr], str[MAXstr+1];
int joi[MAXstr], sz;

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

int main() {
	int maxJOI = 0;
	int i;

	// 入力
	scanf("%s", str);

	// 文字列圧縮
	sz = 1, joi[0] = 1, joiChar[0] = str[0];
	for (i = 1; str[i]; ++i) {
		if (str[i] == joiChar[sz-1]) ++joi[sz-1];
		else {
			joi[sz] = 1;
			joiChar[sz] = str[i];
			++sz;
		}
	}

	// 判定
	for (i = 1; i < sz-1; ++i)
		if (joiChar[i] == 'O' && joiChar[i-1] == 'J' && joiChar[i+1] == 'I'
			&& joi[i-1] >= joi[i] && joi[i+1] >= joi[i])
				maxJOI = max( maxJOI, joi[i] );

	// 出力
	printf("%d\n", maxJOI);

	return 0;
}

Measured memory_bytes: 6828
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=5e5+9;
ll sum[N];
int main()
{
    FASTINOUT;
    ll k,x;
    cin>>k>>x;
    ll v[x];
    for (int i=0; i<x; i++)
        cin>>v[i];
    ll sum=v[0]+(k-v[x-1]);
    ll ans=v[x-1]-v[0];
    for(int i=1; i<x; i++)
    {
        ans=min(k-v[i]+v[i-1],ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
MOD1 = 1000000000 + 7
def factorial_mod(n, mod):
    import math
    return math.factorial(n) % mod
n,m = map(int, input().split())
if abs(n-m) > 1:
    print(0)
elif n == m:
    res = factorial_mod(m, MOD1) * factorial_mod(n, MOD1)
    res *= 2
    res %= MOD1
    print(res)
else:
    res = factorial_mod(m, MOD1) * factorial_mod(n, MOD1)
    res %= MOD1
    print(res)

Measured memory_bytes: 46960
(defparameter *prime* (+ 7 (expt 10 9)))

;; nCa = n!/a!*(n-a)!
;; nCa = n*(n-1)*(n-2)*...* (n-a+1) / a*(a-1)*...*1

;; This function is copied from sansaqua's submission
;; https://atcoder.jp/contests/abc156/submissions/10273417
(defun mod-inverse (a modulus)
  (declare ((integer 1 #.most-positive-fixnum) modulus))
  (let ((a (mod a modulus))
        (b modulus)
        (u 1)
        (v 0))
    (declare (fixnum a b u v))
    (loop until (zerop b)
          for quot = (floor a b)
          do (decf a (the fixnum (* quot b)))
             (rotatef a b)
             (decf u (the fixnum (* quot v)))
             (rotatef u v))
    (setq u (mod u modulus))
    (if (< u 0)
        (+ u modulus)
        u)))

;; This function is copied from sansaqua's submission
;; https://atcoder.jp/contests/abc156/submissions/10273417
(defun power-mod (base power modulus)
  "BASE := integer
POWER, MODULUS := non-negative fixnum"
  (declare ((integer 0 #.most-positive-fixnum) modulus power)
           (integer base))
  (labels ((recur (x p)
             (declare ((integer 0 #.most-positive-fixnum) x p)
                      (values (integer 0 #.most-positive-fixnum)))
             (cond ((zerop p) 1)
                   ((evenp p) (recur (mod (* x x) modulus) (ash p -1)))
                   (t (mod (* x (recur x (- p 1))) modulus)))))
    (recur (mod base modulus) power)))

(defun choose (n a)
  (let ((x 1)
        (y 1))
    (loop for i from 0 below a
          do (setf x (mod (* x (- n i)) *prime*)
                   y (mod (* y (+ i 1)) *prime*)))
    (mod (* x (mod-inverse y *prime*)) *prime*)))

(defun solve (n a b)
  (mod (- (power-mod 2 n *prime*) 1
          (choose n a)
          (choose n b))
       *prime*))

#-swank
(let* ((n (read))
       (a (read))
       (b (read)))
  (format t "~A~%" (solve n a b)))


Measured memory_bytes: 18528
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int sz=1e5+5;

int n,k;

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>k;
    vector<int> a(n),dp(k+1,0);
    for(int i=0;i<n;i++){
	    cin>>a[i];
	}
	//dp[i] = if True , with i stones first player wins 
	for(int i=0;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i>=a[j] && dp[i-a[j]]==0){
				dp[i]=1;
			}
		}
	}
	
	if(dp[k]==1)cout<<"First\n";
	else cout<<"Second\n";
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout <<(H-h)*(W-w)<<"\n";
}

Measured memory_bytes: 256
from heapq import heappop, heappush

n, m = map(int, input().split())
links = [set() for _ in range(n)]
link_list = []
for _ in range(m):
    s, t, c = map(int, input().split())
    s, t = s - 1, t - 1
    link_list.append((s, t, c))
    links[s].add((c, t))
    links[t].add((c, s))

result = 0
for s, t, limit in link_list:
    queue = [(0, s)]
    visited = set()
    while queue:
        c, v = heappop(queue)
        if c >= limit:
            break
        if v == t:
            result += 1
            break
        if v in visited:
            continue
        visited.add(v)
        for nc, nv in links[v]:
            if nv in visited:
                continue
            if v == s and nv == t:
                continue
            heappush(queue, (c + nc, nv))
print(result)


Measured memory_bytes: 3572
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

import math

def main(): 
    N = II()
    engines = []
    for _ in range(N):
        x, y = LI()
        angle = math.atan2(y, x)
        engines.append((x,y,angle))

    # 偏角ソート
    engines.sort(key=lambda x: x[2])

    dist_max = 0
    # 各エンジンを先頭に、そこから pi の範囲にあるエンジンをすべて用いて進行し、距離を算出する。
    cnt = -1
    for x1, y1, angle1 in engines:
        cnt += 1
        if angle1 <= 0:
            search_criteria = lambda x: True if angle1 <= x < angle1+math.pi else False
        else:
            search_criteria = lambda x: True if (angle1 <= x) or (x < angle1-math.pi) else False
        # search_criteria = lambda x, y: True if x1*x + y1*y > 0 else False

        x_sum = 0
        y_sum = 0
        for x, y, angle in engines[cnt:] + engines[:cnt]:
            if search_criteria(angle):
            # if search_criteria(x, y):
                x_sum += x
                y_sum += y
            dist_max = max(dist_max, math.sqrt(x_sum**2 + y_sum**2))
    
    print(dist_max)

main()

Measured memory_bytes: 3316