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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  string s, t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  cout << (s < t ? "Yes" : "No") << "\n";
}


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

int main() {
	int N, K;
	int temp;
	vector<int> h;
	int min;
	int temp2;

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> temp;
		h.push_back(temp);
	}

	sort(h.begin(), h.end());  // 昇順ソート

	min = h[0 + K - 1] - h[0];
	for (int i = 1; i <= N - K; i++) {
		temp2 = h[i+ K-1] - h[i];
		if (min > temp2) {
			min = temp2;
		}
	}

	cout << min << endl;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s;cin>>s;
    if(s=="AAA" || s=="BBB")out("No");
    else out("Yes");
}


Measured memory_bytes: 256
import math
import decimal
def main():
    n = int(input())
    x = input().split()
    x = [int(t)for t in x]
    
    x_ = sum(x)
    p = round(x_/n)

    s = [(t-p)*(t-p)for t in x]
    print(sum(s))


if __name__ == "__main__":
    main()

Measured memory_bytes: 5288
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=ans*10+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=200;
int n,k,a[maxn],f[1000000];
int main(){
//	freopen(".in","r",stdin);
	n=read(),k=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=k;i++){
		int ok=0;
		for(int j=1;j<=n;j++)
			if(a[j]<=i&&!f[i-a[j]]){
				ok=1;
				break;
			}
		f[i]=ok;
	}
	if(f[k]) printf("First\n");
	else printf("Second\n");
	return 0;
}








Measured memory_bytes: 512
#include <stdio.h>
int main(void) {
   int a, b, c;
   int N;
   scanf("%d", &N);
   while(N>0) {
      scanf("%d %d %d", &a, &b, &c);
      a*=a; b*=b; c*=c;
      puts((a+b-c && b+c-a && c+a-b) ? "NO" : "YES");
      N--;
   }
   return (0);
}

Measured memory_bytes: 580
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

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

int main() {
    int a,b,k;
    cin>>a>>b>>k;
    vector<int>v;
    for(int i=1;i<=a;i++){
        if(a%i==0 && b%i==0) v.push_back(i);
    }
    cout<<v[v.size()-k]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

            int yyyy = Integer.parseInt(S.substring(0, 4));
            int mm = Integer.parseInt(S.substring(5, 7));
            int dd = Integer.parseInt(S.substring(8, 10));

            System.out.println(isHeisei(yyyy, mm, dd) ? "Heisei" : "TBD");
        }
    }

    private static boolean isHeisei(int yyyy, int mm, int dd) {
        if (yyyy < 2019) {
            return true;
        }
        if (yyyy > 2019) {
            return false;
        }
        if (mm < 5) {
            return true;
        }
        return false;
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  using P = pair<int, int>;
  vector<P> v;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    v.emplace_back(b, a);
  }
  sort(all(v));
  i64 now = 0;
  rep(i, n) {
    int b, a;
    tie(b, a) = v[i];
    now += a;
    if (now > b) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <cctype>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5, M = 2e5+5;
struct Edge
{
    int next, to;
    Edge(int next = 0, int to = 0):next(next), to(to) {};
}edge[M<<1];
int tot, head[N];
void _add(int x, int y) { edge[++tot] = Edge(head[x], y), head[x] = tot; }
void add(int x, int y) { _add(x, y), _add(y, x); }
int n, m, col[N];
int64 ans, c[3];
bool dfs(int x, int d)
{
    bool ret = true; col[x] = d;
    for(int i = head[x]; i; i = edge[i].next)
    {
        int y = edge[i].to;
        if(col[y] == -1) ret &= dfs(y, d^1); else ret &= col[y] != d;
    }
    return ret;
}
// int fa[N], e[1000][1000], res;
// int code(int i, int j) { return (i-1)*n+j; }
// int find(int x) { return fa[x] == x?x:fa[x] = find(fa[x]); }

int main()
{
    n = read(), m = read();
    memset(col, -1, sizeof(col));
    for(int i = 1; i <= m; ++i)
    {
        int x = read(), y = read();
        add(x, y); 
        // e[x][y] = e[y][x] = 1;
    }
    for(int i = 1; i <= n; ++i)
    {
        if(~col[i]) continue;
        if(!head[i]) ++c[0];
        else if(dfs(i, 0)) ++c[1];
        else ++c[2];
    }
    // for(int i = 1; i <= n; ++i)
    //     for(int j = 1; j <= n; ++j)
    //         fa[code(i, j)] = code(i, j);
    // for(int i = 1; i <= n; ++i)
    //     for(int j = 1; j <= n; ++j)
    //         for(int k = 1; k <= n; ++k)
    //             for(int l = 1; l <= n; ++l)
    //                 if(e[i][k]&&e[j][l])
    //                     fa[find(code(i, j))] = find(code(k, l));
    // for(int i = 1; i <= n*n; ++i) res += find(i) == i;
    ans = c[0]*(2*n-1)-c[0]*c[0]+c[0]+c[1]*2+c[2]+(c[1]+c[2])*(c[1]+c[2]-1)+c[1]*(c[1]-1);
    printf("%lld\n", ans);
    // printf("%d\n", res);
    return 0;
}

/*
7 6
1 2
2 3
1 3
5 6
6 7
5 7
*/

Measured memory_bytes: 6912
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def solve(A: int, B: int, C: int, K: int):
    if K <= A:
        print(K)
    elif K <= A + B:
        print(A)
    else:
        print(A - (K - A - B))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64976
import bisect
n = int(input())
A = list(map(int,input().split()))
A.sort()
if A[-1] <= 0:
    m = A[-1] - sum(A[:-1])
    print(m)
    now = A[-1]
    for i in range(n-1):
        print(now,A[i])
        now -= A[i]
elif A[0] >= 0:
    m = sum(A[1:]) - A[0]
    print(m)
    now = A[0]
    for i in range(1,n-1):
        print(now,A[i])
        now -= A[i]
    print(A[n-1],now)
else:
    zero = bisect.bisect_left(A,0)
    minus = A[:zero]
    plus = A[zero:]
    print(sum(plus) - sum(minus))
    now = minus[0]
    for p in plus[:-1]:
        print(now,p)
        now -= p
    print(plus[-1],now)
    now = plus[-1] - now
    for m in minus[1:]:
        print(now,m)
        now -= m
    

Measured memory_bytes: 61836
#include<stdio.h>
int a[200],b[200],c[1000],d[1000],n,m,i,j,k,t=0;
int w,q;
int main(){for(;;){scanf("%d",&n);if(n==0)break;for(i=0;i<n;i++){scanf("%d %d",&a[i],&b[i]);}scanf("%d",&m);for(i=0;i<m;i++){scanf("%d %d",&c[i],&d[i]);}for(i=0;i<m;i++){w=c[i]-a[0];q=d[i]-b[0];for(j=1;j<n;j++){for(k=0;k<m;k++){if(a[j]+w==c[k]){if(b[j]+q==d[k]){t++;break;}}}}if(t==n-1){printf("%d %d\n",w,q);t=0;break;}t=0;}}return 0;}

Measured memory_bytes: 608
N,K = map(int, input().split())
line = list(map(int, input().split()))
# output = [1 for i in range(N-K+1)]
# print(output)
for i in range(N-K):
    if line[i] < line[i+K]:
        print('Yes')
    else:
        print('No')
    

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

int main()
{
  int n;
  vector<int64_t> a(100000);
  int64_t ans1 = 0, ans2 = 0, sum = 0;

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n; i++)
  {
    if (i % 2 != 0 && sum + a[i] >= 0)
    {
      ans1 += abs(sum * (-1) - 1 - a[i]);
      sum = - 1;
    }
    else if (i % 2 == 0 && sum + a[i] <= 0)
    {
      ans1 += abs(sum * (-1) + 1 - a[i]);
      sum = 1;
    }
    else
      sum += a[i];
  }
  sum = 0;
  for (int i = 0; i < n; i++)
  {
    if (i % 2 == 0 && sum + a[i] >= 0)
    {
      ans2 += abs(sum * (-1) - 1 - a[i]);
      sum = - 1;
    }
    else if (i % 2 != 0 && sum + a[i] <= 0)
    {
      ans2 += abs(sum * (-1) + 1 - a[i]);
      sum = 1;
    }
    else
      sum += a[i];
  }
  cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 1024
from itertools import combinations
n, m, x = map(int, input().split())

books = []

for i in range(n):
  books.append(list(map(int, input().split())))

combBooks = []
for i in range(n, 0, -1):
    combBooks.append(list(combinations(books, i)))
prices = []
flag = True
for combin in combBooks:
    if flag:
        flag = False
        for comb in combin:
            sums = [0]*m
            price = 0
            for book in comb:
                price += book[0]
                for algorithm in range(m):
                    sums[algorithm] += book[algorithm+1]
            flag_break = True
            for sum in sums:
                if sum < x:
                    flag_break = False
                    break
            if flag_break:
                flag = True
                prices.append(price)

if not prices:
    print("-1")
else:
    print(min(prices))


Measured memory_bytes: 9648
x = int(input())
a = 0
if 400 <= x <= 599:
    a = 8
if 600 <= x <= 799:
    a = 7
if 800 <= x <= 999:
    a = 6
if 1000 <= x <= 1199:
    a = 5
if 1200 <= x <= 1399:
    a = 4
if 1400 <= x <= 1599:
    a = 3
if 1600 <= x <= 1799:
    a = 2
if 1800 <= x <= 1999:
    a = 1

print(a)


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

int main() {
	int n;
	cin>>n;
	long long p=1;
	long long arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	for(int i=0;i<n;i++){
	    if(arr[i] == 0){
	        cout<<0;
	        return 0;
	    }
	}
	for(int i=0;i<n;i++){
	   if(arr[i] <= (1000000000000000000/p))
	   {
	       p *= arr[i];
	   }
	   else{
	       cout<<"-1";
	       return 0;
	   }
	}
	cout<<p;
	return 0;
}

Measured memory_bytes: 4404
n,m=list(map(int,input().split()))
st=[]
for i in range(n):
    a,b=list(map(int,input().split()))
    st.append([a,b])
cp=[]
for j in range(m):
    c,d=list(map(int,input().split()))
    cp.append([c,d])
g=[]
for i in range(n):
    m_dt=abs(st[i][0]-cp[0][0])+abs(st[i][1]-cp[0][1])
    idx=1
    for j in range(1,m):
        dt=abs(st[i][0]-cp[j][0])+abs(st[i][1]-cp[j][1])
        if dt<m_dt:
            m_dt=dt
            idx=j+1
    print(idx)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<int,vector<int>,greater<int>> que;

string s;
llint a[10];
llint n;

llint calc(int bit){
	llint ret=0;
	llint tmp=a[0];
	for(int i=0;i<n-1;i++){
		if(bit &(1<<i)){
			ret+=tmp;
			tmp=0;
		}
		else{
			tmp*=10;
		}
		tmp+=a[i+1];
	}
	return ret+tmp;
}

void solve(){
	cin >> s;
	n=s.size();
	for(int i = 0; i < n; i++) a[i] = s[i] - '0';
	llint r=0;
	for(int b=0;b<(1<<(n-1));b++){
		r+=calc(b);
	}
	cout << r << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

using namespace std;

bool x_is_bigger_than_y(string x, string y){
	for(int i = 0;;++i){
		if(x[i] > y[i]){
			return false;
		}else if(x[i] < y[i]){
			return true;
		}
	}
}

int main(){
	string s, t; cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	if(x_is_bigger_than_y(s, t)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
	int a,b,c,d,e,k;
  	cin>>a>>b>>c>>d>>e>>k;
  
  	bool dis=true;
  
  if(e-a>k){

  	dis=false;
  }

  if(dis){
  	cout<<"Yay!"<<endl;
  }
  
  else{
  	cout<<":("<<endl;
  }

}

Measured memory_bytes: 3552
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll gcd(ll a, ll b) {
  ll v0=a, v1=b, v2=v0%v1;
  while(v2>0) {
    v0 = v1;
    v1 = v2;
    v2 = v0%v1;
  }
  return v1;
}

bool more(ll A, ll B, ll C, ll D) {
  ll yey = gcd(A, C);
  B *= C/yey;
  D *= A/yey;
  if(B<D) return true;
  else return false;
}

int main() {
  ll A, B, C, D, E, F;
  cin>>A>>B>>C>>D>>E>>F;
  ll ans1=1, ans2=0;
  ll t, s;
  for(ll i=0;i*100*A<=F;++i) {
    for(ll j=0;j*100*B<=F;++j) {
      t = 100*A*i+100*B*j;
      if(t==0) continue;
      if(t>F) continue;
      for(ll k=0;100*k*C<=E*t;++k) {
        for(ll l=0;100*l*D<=E*t;++l) {
          s = k*C+l*D;
          if(100*s>E*t) continue;
          if(t+s>F) continue;
          if(more(ans1, ans2, t, s)) {
            ans1 = t;
            ans2 = s;
          }
        }
      }
    }
  }
  if(ans1==1) cout<<100*A<<" "<<0<<endl;
  else cout<<ans1+ans2<<" "<<ans2<<endl;
}


Measured memory_bytes: 3600
import sys
input = sys.stdin.buffer.readline
N, K = map(int, input().split())
A = [tuple(map(int, line.split())) for line in sys.stdin.buffer.readlines()]
A.sort()
mod = 998244353

acc = [0]*(N+5)
acc[0] = 1
for i in range(1, N+1):
    cum = 0
    for l, r in A:
        if i-l < 0:
            break
        p, q = max(0, i-r), max(0, i-l)
        cum += acc[q]-acc[p-1]
    acc[i] = (cum+acc[i-1]) % mod

print((acc[N-1]-acc[N-2]) % mod)


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ld, ld> pld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <ld> vld;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef set <ld> sld;
typedef set <ll> sll;
typedef set <pll> spll;
typedef char ch;
typedef string str;
typedef tree <int,
            null_type,
            less<int>,
            rb_tree_tag,
            tree_order_statistics_node_update> super_set;
const ll DIM = 3004;
const ll MODULO = 1e9+7;
const ld INF = 1e9;
const ld eps = 1e-9;
const ld pi = acos(-1.0);
const ld e = pow(1.0 + 1.0/INF, INF);
const ld gr = (1.0+sqrt(5.0))/2.0;
const ld alpha0 = 2*cos(pi/8)/(1+cos(pi/8));
const ld beta0 = 2*sin(pi/8)/(1+cos(pi/8));
ll n;
ld res,P[DIM],F[DIM][DIM];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("paintbarn.in", "r", stdin);
    //freopen("paintbarn.out", "w", stdout);

    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> P[i];
    F[0][0] = 1;
    F[1][1] = P[1];
    F[1][0] = 1-P[1];
    for (int i = 2; i <= n; i++) {
        F[i][0] = 1-P[i];
        F[i][0] *= F[i-1][0];
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            F[i][j] = F[i-1][j]*(1-P[i]) + F[i-1][j-1]*P[i];
        }
    }
    for (int i = 0; i <= n; i++) {
        if (i > n-i)
            res += F[n][i];
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}


Measured memory_bytes: 141056
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define mem(a,n) memset(a,sizeof(a),n)
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+5;
const int INF=0x3f3f3f3f;
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        int sum=1800*m+100*n;
        for(int i=0;i<m;i++)
            sum*=2;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int revcompare(const void* a, const void* b) {
    return *(int*)b- *(int*)a;
}

struct node_t{
    int value;
    struct node_t* left;
    struct node_t* right;
};

struct node_t* mallocNode(int adds) {
    struct node_t* add;

    add = (struct node_t*)malloc(sizeof(struct node_t));
    if (add == NULL) {
        return NULL;
    }

    add->left = NULL;
    add->right = NULL;
    add->value =  adds;

    return add;
}

int addNode(struct node_t* root, int tmps) {
    struct node_t* node;
    if (root == NULL) {
        root = mallocNode(tmps);
        return 0;
    }

    node = root;
    while (1) {
        if (tmps < node->value) {
            if (node->left == NULL) {
                node->left = mallocNode(tmps);
                return 0;
            }
            node = node->left;
        }
        else if (tmps > node->value) {
            if (node->right == NULL) {
                node->right = mallocNode(tmps);
                return 0;
            }
            node = node->right;
        }
        else {
            return 1; // 重複のときのみ1を返す
        }
    }

}


int main() {
    int i,j;
    int n;
    int x;

    scanf("%d", &x);

    for(i=x;;i++){
        for(j=2;j<=i;j++){
            if(i%j == 0) break;
        }
        //printf("i:%d j:%d\n", i, j);
        if(i==j) break;
    }
    printf("%d", i);
    return 0;

}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;

void solve() {
	int N, D; cin >> N >> D;
	vector<int>d(N);
	vector<int>A(N + 1), B(N + 1);
	A[0] = D;
	REP(i, N) {
		cin >> d[i];
		A[i + 1] = min(A[i], abs(A[i] - d[i]));
	}
	B[N] = 1;
	REPR(i, N) {
		if (B[i + 1] <= d[i] / 2)B[i] = B[i + 1];
		else B[i] = B[i + 1] + d[i];
	}
	int Q; cin >> Q;
	while (Q--) {
		int q; cin >> q;
		q--;
		if (A[q] >= B[q+1])print("YES");
		else print("NO");
	}
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 15072
#include<stdio.h>

int main(void)
{

	int N;
	char c[10001];
	scanf("%d", &N);
	scanf("%s", c);

	for (int i= 0;c[i] != '\0';i++) {
		c[i] += N;
		if (c[i] > 'Z')c[i] = c[i]-'Z'+'A'-1;
	}
	printf("%s",c);
	return 0;
}

Measured memory_bytes: 128
fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim()
        .split_whitespace()
        .map(|e| e.trim().parse().ok().unwrap())
        .collect()
}

fn main() {
    let (h, w) = {
        let hw = read_vec::<usize>();
        (hw[0], hw[1])
    };

    let s: Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect()).collect();

    let black: char = "#".to_owned().chars().next().unwrap();
    let mut succeed = true;
    for i in 0..h {
        for j in 0..w {
            if s[i][j] != black {
                continue;
            }

            if i > 0 {
                if s[i - 1][j] == black {
                    continue;
                }
            }

            if i < h - 1 {
                if s[i + 1][j] == black {
                    continue;
                }
            }

            if j > 0 {
                if s[i][j - 1] == black {
                    continue;
                }
            }

            if j < w - 1 {
                if s[i][j + 1] == black {
                    continue;
                }
            }

            succeed = false;
            break;
        }

        if !succeed {
            break;
        };
    }

    if succeed {
        println!("{}", "Yes")
    } else {
        println!("{}", "No")
    };
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
	int n;
	while (cin >> n, n != 0){
		double sum = 0, v = 0;
		for (int i = 0; i < n; i++){
			int s;
			cin >> s;
			sum += s;
			v += s * s;
		}
		cout << setprecision(10) << sqrt(v / n - sum * sum / n / n) << endl;
	}
}



Measured memory_bytes: 3220
s=list(input())
n=len(s)
ans=0
tmp=-10
cnt=[0]*20
for i in range(n):
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        cnt[i]=1
for i in cnt:
    if i==1:
        ans+=1
    else:
        if tmp<ans:
            tmp=ans
            ans=0
if tmp==-10:
    print(ams)
else:
    print(tmp)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='C')
        {
            for(int j=i+1;j<a.size();j++)
            {
                if(a[j]=='F')return !(cout<<"Yes\n");
            }
        }
    }
    cout<<"No\n";
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val ds = readInputLine().split(" ").map { it.toInt() }.toIntArray()
    
    var ans = 0

    for (i in 0 until N) {
        for (j in i + 1 until N) {
            ans += ds[i] * ds[j]
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37620
// Problem : F - Intervals on Tree
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	int n;cin>>n;
	int ans=0;
	for(int i=1;i<=n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		ans+=(n-i+1)*i;
		ans-=(n-max2(x,y)+1)*min2(x,y);
	}
	ans+=n;
	cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    char a,b;
    cin >> a >> b;
    if(a > b ) cout << '>' << '\n';
    else if(a < b) cout << '<' << '\n';
    else cout << '=' << '\n';
    return 0;                                                                                                         
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
	double w,h,x,y;
	cin >> w >> h >> x >> y;
	double s=(w*h)/2.0;
	int r=0;
	cout << fixed << setprecision(10);
	if ((y==(h/2.0)) && (x==(w/2.0))) r=1;
	cout << s << " " << r;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

unsigned long long f[100000];

int main() {

  unsigned long long n, m, p, ans = 0, d;
  cin >> n;
  for(int i =1;i <= n;i++){
    cin >> p;
    f[p]++;
    ans += p;
  }
  cin >> m;
  for(int i =1;i <= m;i++){
    cin >> p >> d;
    ans += -(f[p] * p) + f[p] * d;
    f[d] += f[p];
    f[p] = 0;
    cout << ans << '\n';
  }
  return 0;
}



Measured memory_bytes: 4412
read n a b
ans=0
for (( k = 1; k <= n; k++ )); do
    dsum=0
    for (( j = 0; j < ${#k}; j++, dsum += ${k:j:1} )); do : ; done
    (( dsum >= a && dsum <= b )) && (( ans += k ))
done
echo ${ans}


Measured memory_bytes: 376
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}

int main(){
   int a,b;
   cin >> a >> b;
   b += 3 * a;
   cout << b/ 2 << endl;
}

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

const int NMAX=1120, JMAX=187, KMAX=14;
int dp[NMAX+1][JMAX+1][KMAX+1];
vector<int> primes;

void init(){
	for(int i=0; i<=NMAX; ++i)for(int j=0; j<=JMAX; ++j)for(int k=0; k<=KMAX; ++k)dp[i][j][k]=0;

	bool isPrime[NMAX+1];
	fill(begin(isPrime), end(isPrime), true);
	isPrime[0]=isPrime[1]=false;
	for(int i=2; i<=NMAX; ++i){
		if(isPrime[i]){
			dp[i][primes.size()][1]=1;
			primes.push_back(i);
			for(int j=i+i; j<=NMAX; j+=i)	isPrime[j]=false;
		}
	}
//	cout << primes.size() << endl;

	for(int k=1; k<KMAX; ++k){
		for(int n=2; n<=NMAX; ++n){
			for(int j=0; j<primes.size(); ++j){
				for(int j2=j+1; j2<primes.size(); ++j2){
					if(n+primes[j2]>NMAX)	break;
					dp[n+primes[j2]][j2][k+1] += dp[n][j][k];
				}
			}
		}
	}

}

int main(){
	init();

	int N,K;
	while(true){
		cin>>N>>K;
		if((N|K)==0)	break;
		int ans=0;
		for(int j=0; j<primes.size(); ++j)	ans+=dp[N][j][K];
		cout<<ans<<endl;
	}

//	for(int j=0; j<pries.size(); ++j){
//		cout << j << " " << dp[2][j][2] << endl;
//	}

//	for(int i=1; i<=NMAX; ++i)for(int k=1; k<=KMAX; ++k){
//		int tmp=0;
//		for(int j=0; j<primes.size(); ++j)	tmp+=dp[i][j][k];
//		cout<<i<<" "<<k<<" "<<tmp<<endl;
//	}

	return 0;
}

Measured memory_bytes: 13564
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
    }

    let rainy_days = (s as String)
        .split("S")
        .map(|rainy| rainy.len())
        .max()
        .unwrap();

    println!("{}", rainy_days);
}

Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define mod 1e9 + 7 
using namespace std ;
int main () {
	int n , m ;
	cin >> n >> m ;
	vector < vector < char > > a ( n,vector < char > (  m  ) ) ;
	for( int i = 0 ; i< n ; i++ ){
		for( int j = 0 ; j < m ; j++){
			cin >> a[i][j] ;
		}
	}
	vector < vector < long long > > dp ( n,vector < long long > (  m ,0 ) ) ;
	if(a[0][0] == '.')	dp[0][0] = 1 ;
	for( int i = 1 ;i < m; i++)	if(a[0][i]=='.') dp[0][i] = dp[0][i-1] ;
	for( int i = 1 ;i < n; i++)	if(a[i][0]=='.') dp[i][0] = dp[i-1][0] ;
	for( int i = 1 ; i < n ; i++ ) {
		for( int j = 1 ; j < m ; j++){
			if(a[i][j] == '.'){
				dp[i][j] = dp[i-1][j]+dp[i][j-1];
				if(dp[i][j] >= mod )
					dp[i][j]-=mod;
						
			}	
		}
	}
	cout << dp[n-1][m-1] ;
	
}

Measured memory_bytes: 9088
#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 <iterator>
#include <numeric>
#include <bitset>
#include <cassert>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();
		
		int cntA = 0;
		int cntB = -1;
		int cntC = -1;
		
		char next = a.charAt(0);
		String ans = "";
		outside: do {
			
			switch (next) {
			case 'a':
				cntA++;
				if (cntA == a.length()) {
					ans = "A";
					break outside;
				}
				next = a.charAt(cntA);
				break;
			case 'b':
				cntB++;
				if (cntB == b.length()) {
					ans = "B";
					break outside;
				}
				next = b.charAt(cntB);
				break;
			case 'c':
				cntC++;
				if (cntC == c.length()) {
					ans = "C";
					break outside;
				}
				next = c.charAt(cntC);
				break;
			
			}
		} while(true);

		System.out.println(ans);
		
	}
}

Measured memory_bytes: 23124
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    cnt = 0
    for i in range(N)[::-1]:
        x = A[i] + cnt % B[i]
        cnt += (B[i] - x) % B[i]
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42140
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

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

int main(){
    int n,m;
    cin >> n >> m;
    graph g(n);
    vector<int> deg(n,0);
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        g[x].emplace_back(y);
        deg[y]++;
    }
    queue<int> que;
    rep(i,n){
        if(deg[i]==0) que.push(i); 
    }
    vector<int> dp(n+1,0);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(auto nv: g[v]){
            deg[nv]--;
            if(deg[nv]==0){
                que.push(nv);
                chmax(dp[nv],dp[v]+1);
            }
        }
    }
    cout << *max_element(dp.begin(),dp.end()) << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll x,y,z;
  cin >> x >> y >> z;
  ll now=y+2*z;
  ll cnt=0;
  while(now<=x){
    now+=y+z;
    cnt++;
  }
  cout << cnt << endl;
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);
#define debug(x) cerr << #x << " = " << x << "\n" ;

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

ll a , b ;

int main(){

 cin >> a >> b ;
 if( ( a + b ) % 2 ){
    cout << "IMPOSSIBLE" ;
 } else cout << ( a + b ) / 2 ;

 return 0 ;
}


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

using namespace std;
#define deb(x) cout << #x << ": " << x << endl
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fkn(i, k, n) for (i = k; i < n; i++)
#define ll long long
#define F first;
#define S second;
#define PB push_back;
#define MP(x,y) make_pair(x,y);
typedef vector<ll> vll;

bool powerOfTwo(ll x)
{
    return !(x & (x - 1));
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a;
    ll c;
    long double b;

    cin>>a>>b;
    c = b;
    b = b - (long double)c;
    
    
    long double ans1 = a * b;
    ll ans = a*c;
    ll x = ans + ans1;
                     cout << x;

    // cin>>n;
    // vector<ll> v(n);
    // ll q=0;
    // fo(i,n) 
    // {
    //     cin>>v[i];
    //     if(v[i] == 0)
    //     {
    //         q=1;
    //     }
    // }
    // if(q)
    // {
    //     cout<<0;
    // }
    // else{
    // fo(j,n)
    // {
    //     cout<<j<<" " <<ans<<" "<<1e18/v[j]<< endl;
    //     if (ans  > 1e18/v[j])
    //     {
    //         ans =-1;
    //         break;
    //     }
    //     else{
    //     ans *=v[j];
    //     }
    // }
  
    // cout<<ans;
    // }


    


}



Measured memory_bytes: 3672
#include<stdio.h>
int main()
{
  int a=0;
  int b=0;
  int result=0;
  scanf("%d%d",&a,&b);
  if(b%a==0)
  {
    result=a+b;
  }
  else
  {
    result=b-a;
  }
  printf("%d",result);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int checkHeight(double h);

int main()
{
    int n;
    int count[6] = {};
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        double height;
        cin >> height;
        count[checkHeight(height)]++;
    }
    for(int i = 0; i < 6; i++)
    {
        cout << i + 1 << ":";
        for(int j = 0; j < count[i]; j++)
        {
            cout << "*";
        }
        cout << endl;
    }
    return 0;
}

int checkHeight(double h)
{
    int ret_value = 0;
    if(isless(h, 165.0))
    {
        ret_value = 0;
    }
    else if(isless(h, 170.0))
    {
        ret_value = 1;
    }
    else if(isless(h, 175.0))
    {
        ret_value = 2;
    }
    else if(isless(h, 180.0))
    {
        ret_value = 3;
    }
    else if(isless(h, 185.0))
    {
        ret_value = 4;
    }
    else
    {
        ret_value = 5;
    }
    return ret_value;
}



Measured memory_bytes: 3200
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	static final int MAX_A_I = 10000;
	public static void main(String[] args) throws NumberFormatException, IOException {
		
		//System.setIn(new FileInputStream("./ALDS1_6_A-in8.txt"));
		/*BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		*/
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] c = new int[MAX_A_I + 1];
		int[] a = new int[n+1];
		//String[] l = br.readLine().split(" ");
		for(int i = 0; i < n; ++i) {
			//a[i] = Integer.parseInt(l[i]);
			a[i] = Integer.parseInt(sc.next());
			c[a[i]] += 1;
			
		}
		sc.close();
		
		for(int i = 1; i <= MAX_A_I; ++i) {
			c[i] += c[i-1];
		}
		
		int[] b = new int[n+1];
		for(int i = n - 1; i >= 0; --i){
			//System.out.println(i + " " + a[i] + " " + c[a[i]]);
			b[c[a[i]] - 1] = a[i];
			c[a[i]] -=  1;
		}
		
		StringBuilder sb = new StringBuilder();//10*n);
		long start = System.nanoTime();
		for(int i= 0; i < n; ++i) {
			sb.append(b[i] + " ");
		}
		/*for(int i = 0; i <= MAX_A_I; ++i) {
			while(c[i] > 0){
				sb.append(i);
				sb.append(" ");
				c[i] -= 1;
			}
		}*/
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb);
		//System.out.println((System.nanoTime() - start)/1000/1000 + " ms");
	}

}

Measured memory_bytes: 305420
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

// MARK: - header
namespace {
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<ull MOD>
struct Mod {
    ull v = 0;
    Mod() {};
    Mod(ull val) : v(val) {}
    operator ull() const {return v;}
    ull operator=(ll x) {return v = x % MOD;}
    ull operator+=(ll x) {return operator=(v + x);}
    ull operator*=(ll x) {return operator=(v * x);}
};
}

// MARK: - answer

ll N;
vector<ll> cap;

const ll MOD = 1e9+7;

void input() {
    cin >> N;
    cap.resize(5);
    for (auto& c : cap)
        cin >> c;
}

ll solve() {
    ll min = *min_element(cap.begin(), cap.end());
    return ceil(double(N) / min) + 4;
}

int main() {
    input();
    cout << solve() << endl;
    
    return 0;
}



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

int main()
{
    int n, sum = 0;
    cin >> n;
    vector<int> p(n);

    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }

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

    for (int i = 0; i < n - 1; i++)
    {
        sum += p[i];
    }
    cout << sum + (p[n - 1] / 2) << endl;
}

Measured memory_bytes: 256