akhauriyash/Code-Regression huggingface dataset:
#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>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

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

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


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

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 lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


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

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int s,w; cin >> s >> w;
    if(s<=w){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    int sum = 0;
    REP(i,n) cin >> v.at(i);
    REP(i,n){
        cin >> c.at(i);
        if(v.at(i) - c.at(i) > 0) sum += v.at(i) - c.at(i);
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;


int main(){
    int n,A[101],l=101,r=-1,c,ans=INFTY;
    cin>>n;
    REP(i,n){
        cin>>A[i];
        l=min(l,A[i]);
        r=max(r,A[i]);
    }

    for(int i=l;i<=r;i++){
        c=0;
        REP(j,n) c+=pow(A[j]-i,2);
        ans=min(ans,c);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N, M = (int(i) for i in input().split())
MOD = 10**9 + 7
S = [int(i) for i in input().split()]
T = [int(i) for i in input().split()]

DP = [[0] * (M+1) for counter1 in range(N+1)]
DP[0][0] = 1
for i in range(N):
    DP[i+1][0] = 1
for i in range(M):
    DP[0][i+1] = 1
for i in range(N):
    for j in range(M):
        if S[i] != T[j]:
            DP[i+1][j+1] = DP[i+1][j] + DP[i][j+1] - DP[i][j]
            DP[i+1][j+1] %= MOD
        else:
            DP[i+1][j+1] = DP[i+1][j] + DP[i][j+1]
            DP[i+1][j+1] %= MOD
print(DP[N][M])

Measured memory_bytes: 73052
import           Control.Applicative

data Tpl = Tpl {a :: Int, b :: Int}
instance Show Tpl where
  show o | (a o) < (b o) = "a < b"
         | (a o) > (b o) = "a > b"
         | otherwise = "a == b"

readTuple :: IO Tpl
readTuple = do
  ns <- map read . words <$> getLine
  return $ Tpl (head ns) (last $ take 2 ns)

main = readTuple >>= print



Measured memory_bytes: 3604
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 100000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll cnt = v[0];
  ll idx = 0;
  sort(all(v));
  ll sum[MAX_N] = {0};
  sum[0] = v[0] * 2;
  repl(i,1,n) sum[i] += sum[i-1] + v[i] * 2;
  rep(i,n-1){
    if(sum[i] < v[i+1]) idx = i + 1;
  }
  cout<< n - idx << endl;
}

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


Measured memory_bytes: 1792
//__n1colai__
#include <bits/stdc++.h>
#include<stdint.h>
using namespace std;
#define vi vector<int>
#define pb emplace_back
#define w(t)   int t;cin>>t;while(t--)
#define show(ar) for(int i=0;i<ar.size();i++) cout<<ar[i]<<" "; cout<<endl;
#define mod 1e9+7
#define ff first
#define ss second
#define fio ios::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define all(x) (x.begin(),x.end())
#define inf 1e9+7
#define MAX 90000000
#define ll long long

vi inp(int n)
{
	vi v; int x;
	for(int i=0;i<n;i++) {
		cin>>x; v.pb(x);
	}
	return v;
}


int main()
{
	fio
	char ch;
	cin>>ch;
	if(ch>='A' && ch<='Z') cout<<'A'<<endl;
	else cout<<'a'<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

long long max(long long a, long long b){
  if(a < b) return b;
  return a;
}

int compare_int(const void *a,const void *b){
  if(*(int*)a > *(int*)b) return 1;
  return -1;
}

int compare_int_reverse(const void *a,const void *b){
  if(*(int*)a < *(int*)b) return 1;
  return -1;
}

int main(void){
  int N;
  scanf("%d", &N);

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

  qsort(A, N, sizeof(int), compare_int);

  long long ans1 = 0;
  if(N%2 == 0){
    for (int i = 0; i < N; i++) {
      if(i < N/2) ans1 -= A[i]*2;
      else ans1 += A[i]*2;
    }
    ans1 += A[N/2-1];
    ans1 -= A[N/2];
  }else{
    for (int i = 0; i < N; i++){
      if(i <= N/2) ans1 -= 2*A[i];
      else ans1 += 2*A[i];
    }
    ans1 += A[N/2];
    ans1 += A[N/2-1];
  }

  qsort(A, N, sizeof(int), compare_int_reverse);

  long long ans2 = 0;
  if(N%2 == 0){
    for (int i = 0; i < N; i++) {
      if(i < N/2) ans2 -= A[i]*2;
      else ans2 += A[i]*2;
    }
    ans2 += A[N/2-1];
    ans2 -= A[N/2];
  }else{
    for (int i = 0; i < N; i++){
      if(i <= N/2) ans2 -= 2*A[i];
      else ans2 += 2*A[i];
    }
    ans2 += A[N/2];
    ans2 += A[N/2-1];
  }

  printf("%lld\n", max(ans1, -ans2));

  return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
#include <algorithm> 
#include <cstdlib>
#include <bitset>
#include <math.h>
#include <numeric>
#include <set>
#include <vector>
#define ll long long
#define pf printf
#define sf scanf
using namespace std;
int main(){
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
  int n,flag(0),m=1,i;
  cin>>n;
  int arr[n];
  for(i=0;i<n;i++){
    cin>>arr[i];
    if(arr[i]==1)flag++;
  }
  if(flag==0)cout<<-1;
  else {
    for(i=0;i<n;i++){
      if(arr[i]==m)m++;
    }
    cout<<n-m+1;
  }
  





  
  


  
 
 
 
    
 
return 0;
}

Measured memory_bytes: 1024
def prime_factorize(n):
    '''引数nの因数分解結果のlistを返す。'''
    arr = []
    while n % 2 == 0:
        arr.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            arr.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        arr.append(n)
    return arr

def main():
    n = int(input())
    f = set(prime_factorize(n))
    s = set()
    for p in f:
        e = 1
        z = p ** e
        while z <= n:
            if n % z == 0:
                if z not in s:
                    n //= z
                    s.add(z)
            e += 1
            z = p ** e
    print(len(s))
        
if __name__ == '__main__':
    main()

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

using P = pair<int, int>;

int main() {
  int N, M;
  cin >> N >> M;
  set<P> requests;
  for (int i{}; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    requests.insert(P{a, b});
  }

  int ans{1};
  P wp{1, N};
  for (const auto &r : requests) {
    P p{max(wp.first, r.first), min(wp.second, r.second)};
    if (p.first < p.second) {
      wp = p;
    } else {
      ++ans;
      wp = r;
    }
  }

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


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

int dr[] = {-1, 1, 0, 0};
int dc[] = {0, 0, -1, 1};

struct node {
    int i, j, dir;
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    string s[n];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    x1--; y1--; x2--; y2--;
    pair<int, int> vis[n][m][4];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            for (int k = 0; k < 4; k++) {
                vis[i][j][k] = make_pair(INT_MAX, -1);
            }
        }
    }
    queue<node> q;
    for (int i = 0; i < 4; i++) {
        vis[x1][y1][i] = make_pair(0, 0);
        int nr = x1 + dr[i], nc = y1 + dc[i];
        if (nr >= 0 && nr < n && nc >= 0 && nc < m && s[nr][nc] == '.') {
            vis[nr][nc][i] = make_pair(1, 1);
            node u;
            u.i = nr; u.j = nc; u.dir = i;
            q.push(u);
        }
    }
    
    while (!q.empty()) {
        node u = q.front();
        q.pop();
        int dir = u.dir;
        pii cost = vis[u.i][u.j][dir];
        // cout << cost.first << ' ' << cost.second << '\n';
        for (int i = 0; i < 4; i++) {
            int nr = u.i + dr[i], nc = u.j + dc[i];
            if (nr >= 0 && nr < n && nc >= 0 && nc < m && s[nr][nc] == '.') {
                pii nxt;
                if (i != dir) {
                    nxt = make_pair(cost.first + 1, 1);
                } else {
                    nxt = make_pair(cost.first, cost.second + 1);
                    if (nxt.second > k) {
                        nxt.first++;
                        nxt.second = 1;
                    }
                }
                if (nxt < vis[nr][nc][i]) {
                    node u;
                    u.i = nr; u.j = nc; u.dir = i;
                    q.push(u);
                    vis[nr][nc][i] = nxt;
                }
            }
        }
    }
    int ans = INT_MAX;
    for (int i = 0; i < 4; i++) {
        ans = min(ans, vis[x2][y2][i].first);
    }
    if (ans == INT_MAX) {
        ans = -1;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 35928
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int a = in.i();
        char[] s = in.s(10);
        out.print(a < 3200 ? "red" : new String(s).trim());
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 32600
#include<stdio.h>
#include<math.h>

int main(){
  int i,j,n,array[10000],sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }
  for(i=0;i<n;i++){
    for(j=2;j<=sqrt(array[i]);j++){
      if(array[i]%j == 0){
	sum--;
	break;
      }
    }
    sum++;
  }
  
  printf("%d\n",sum);
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n,a;
    cin >> n>>a;
    cout << ((n % 500 <= a) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
Mons = list(map(int, input().split()))
Hero = list(map(int, input().split()))

ans = 0

for i in range(N):
    # print("--------------------")
    # print(Mons)
    if Mons[i] >= Hero[i]:
        hunting_count = Hero[i]
        Mons[i] -= hunting_count
        ans += hunting_count
    else:
        hunting_count_part1 = Mons[i]
        Mons[i] -= hunting_count_part1
        Hero[i] -= hunting_count_part1
        ans += hunting_count_part1

        if Mons[i+1] >= Hero[i]:
            hunting_count_part2 = Hero[i]
            Mons[i+1] -= hunting_count_part2
            ans += hunting_count_part2
        else:
            hunting_count_part2 = Mons[i+1]
            Mons[i+1] -= hunting_count_part2
            Hero[i] -= hunting_count_part2 # 今回は必要ない
            ans += hunting_count_part2

print(ans)







Measured memory_bytes: 82020
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((int)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int getnum(int x){
	return (x/10) * (x%10);
}

bool flag(int x){
	return x/10 >= 2 && x%10 >= 2;
}

int main(){
	int M, D;
	cin >> M >> D;
	int ans = 0;
	for(int i=1;i<=M;++i){
		for(int j=1;j<=D;++j){
			if(flag(j)){
				if(getnum(j)==i){
					++ans;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

//ll dp[600][600];
ll dp[2][2000001];

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> b(m);
    rep(i, m) cin >> b[i];
    
    vector<ll> Sa(n + 1);
    vector<ll> Sb(m + 1);
    rep(i, n) Sa[i + 1] = Sa[i] + a[i];
    rep(j, m) Sb[j + 1] = Sb[j] + b[j];

    int curJ = m;
    int best = 0;
    rep (i, n + 1) {
        ll rem = k - Sa[i];
        while (curJ >= 0) {
            if (Sb[curJ] <= rem) {
                best = max(i + curJ, best);
                break;
            }
            curJ--;
        }
    }

    put(best);

    return 0;
}

Measured memory_bytes: 9576
#include<iostream>
#include<iomanip>
#include<cmath>
int main()
{
	int n;
	std::cin >> n;
	int*x = new int[n], *y = new int[n];
	for(int i = 0; i < n; i++)
	{
		std::cin >> x[i];
	}
	for(int i = 0; i < n; i++)
	{
		std::cin >> y[i];
	}
	std::cout << std::fixed << std::setprecision(10);
	double manhattan = 0;
	for(int i = 0; i < n; i++)
	{
		manhattan += std::abs(x[i] - y[i]);
	}
	std::cout << manhattan << std::endl;
	double euclid_2 = 0;
	for(int i = 0; i < n; i++)
	{
		euclid_2 += (x[i] - y[i]) * (x[i] - y[i]);
	}
	std::cout << sqrt(euclid_2) << std::endl;
	double euclid_3 = 0;
	for(int i = 0; i < n; i++)
	{
		euclid_3 += std::abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
	}
	std::cout << cbrt(euclid_3) << std::endl;
	double chebychev = 0;
	for(int i = 0; i < n; i++)
	{
		if(chebychev < std::abs(x[i] - y[i]))
		{
			chebychev = std::abs(x[i] - y[i]);
		}
	}
	std::cout << chebychev << std::endl;
	return 0;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005

// it's swapnil07 ;)


signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n; cin>>n;
    int h[n+1]={0};
    For(i, 1, n+1){
        cin>>h[i];
        if(h[i]-1 >= h[i-1]){
            h[i]=h[i]-1;
        }
    }
    For(i, 1, n+1){
        if(h[i]<h[i-1]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << (a+b-1)/b;
	return 0;
}


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

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

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

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        for(int j=i;j<=s.size();j++){
            string str;
            for(int k=0;k<i;k++){
                str+=s[k];
            }   
            for(int k=j;k<s.size();k++){
                str+=s[k];
            }         
            if(str=="keyence"){
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
    string s; cin >> s;
    ll a = atoi(s.substr(0, 2).c_str()), b = atoi(s.substr(2).c_str());
    bool yymm = 1 <= b && b <= 12;
    bool mmyy = 1 <= a && a <= 12;
    if (yymm && mmyy) {
        cout << "AMBIGUOUS" << endl;
    } else if (yymm) {
        cout << "YYMM" << endl;
    } else if (mmyy) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
open System

let readInts () = stdin.ReadLine().Split(' ') |> Array.map int64

[<EntryPoint>]
let main argv =
    let xy = readInts()
    let x, y = xy.[0], xy.[1]
    let p = readInts() |> Array.sortDescending |> Array.take (int x)
    let q = readInts() |> Array.sortDescending |> Array.take (int y)
    let r = readInts()
    Array.concat [|p;q;r|] |> Array.sortDescending |> Array.take (int (x+y)) |> Array.sum
    |> printfn "%d"
    0


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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

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

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

int n, nm, om;
string pre, pos;

signed main() {
	cin >> n;
	// nは99999 = 1e5、クエリは20回、2^20 = 1048576 = 1e6
	// 空席は3個,5個、と奇数個なら1個じゃないかもしれない
	// もし空席が1個だけなら、iとi+2mの席に座っている人の性別が異なれば間に空席があることがわかる！ ->わからない！
	// 空席を挟んで男女男女・・から女男女男・・に並びが変わる可能性がある そうなってた場合全く逆のことが成り立つ
	// まとめると？
	// iとjの性別が同じ	-> (j-i)が偶数	-> i-j間じゃなくi-0-j間で↓が成り立つからそっち側に必ず空席が存在する
	// 					-> (j-i)が奇数	-> 間に少なくとも1個空席がある(空席を挟まず同じグループに属するなら絶対に性別は異なるはず)
	// iとjの性別が異なる	-> (j-i)が偶数	-> 間に少なくとも1個空席がある(〃)
	// 					-> (j-i)が奇数	-> i-j間じゃなくi-0-j間で〜
	// iとjの性別がわかるとi-j間とその反対のi-0-(n-1)-j間の情報が同時に得られる
	cout << 0 << ln << flush;
	cin >> pre;
	if (pre=="Vacant") return 0;
	int l = 0, r = n;
	rep(T,18) {
		// 虱潰しにやったほうが早い場合
		if (r-l+1<=(19-T)) {
			repst(i,l,r) {
				cout << i << ln << flush;
				cin >> pos;
				if (pos=="Vacant") return 0;
			}
		}
		
		nm = (r+l)/2;
		cout << nm << ln << flush;
		cin >> pos;
		if (pos=="Vacant") return 0;
		if (pre==pos) {
			// omとnmの間に答えがある
			if (abs(om-nm)%2==1) (om==l ? r : l) = nm;
			// その反対側に答えがある
			else (om==l ? l : r) = nm;
		} else {
			// ⇡の反対
			if (abs(om-nm)%2==0) (om==l ? r : l) = nm;
			else (om==l ? l : r) = nm;
		}
		pre = pos;
		om = nm;
		// preがどっちに対応してるのか記録しないと
	}
	cout << r << ln;
	return 0;
}

Measured memory_bytes: 880
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll a, b;

ll ans(ll x) {
    ll res = 0;
    for (ll i = 2; i <= sqrt(x); ++i) {
        if (x % i == 0) {
            ++res;
            while (x % i == 0) x /= i;
        }
    }
    if (x > 1) ++res;
    return res + 1;
}


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> a >> b;
    cout << ans(__gcd(a, b)) << '\n';
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    char c; cin >> c; c++; cout << c << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    n, k = map(int, input().split())
    buckets = [0 for x in range(n+1)]
    for i in range(k):
        d = input()
        a = [int(x) for x in input().split()]
        for item in a:
            buckets[item] += 1
    print(buckets.count(0) - 1)

Measured memory_bytes: 9184
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,b,i=0;cin>>a>>b;
  ll c=min(a,b/2);
  if(c==a){
    c+=(b-a*2)/4;
  }
  cout<<c;
}


Measured memory_bytes: 27012
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int r = inputs[0];
            int d = inputs[1];
            int x2000 = inputs[2];

            int prevX = x2000;
            for (int i = 2001; i <= 2010; i++)
            {
                int x = r * prevX - d;

                Console.WriteLine(x);

                prevX = x;
            }
        }
    }
}

Measured memory_bytes: 13396
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC 9(08).
       01  a2 PIC 9(08).
       01  a3 PIC 9(08).
       01  r pic 9(08).
       01  g pic 9(08).
       01  r2 pic 9(08).
       01 disp pic Z(20)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1 a2 a3.
        compute r2 = a1 * a2
        divide r2 by 2 giving r
        MOVE FUNCTION TRIM(r) to disp
        DISPLAY disp

       STOP RUN.


Measured memory_bytes: 384
import bisect
x = int(input())
aa = [a**5 for a in range(-1000, 1001)]
aset = set(aa)
for a in aa:
    if x+a in aset:
        ans = (x+a, a)
        break
ans1, ans2 = float('inf'), float('inf')
for i in range(-1000, 1001):
    if i**5==ans[0]: ans1 = i
    if i**5==ans[1]: ans2 = i
    if ans1==float('inf') or ans2==float('inf'): continue
    break
print(ans1, ans2, sep=' ')

Measured memory_bytes: 9284
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define K 10000

int main(){
  unsigned int *A, *B;

  int C[K+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);

  for ( i = 0; i <= K; i++ ){
    C[i] = 0;
  }

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

  for ( i = 1; i <= K; i++ ){
    C[i] = C[i] + C[i - 1];
  }

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n-1; i++ ){
    printf("%d ", B[i]);
  }
  printf("%d\n",B[n]);

  return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

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

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

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

int n;
vi a;

int main()
{
    int aa;
    
    ci >> n;
    rep(i, n) {
	ci >> aa;
	a.pb(aa);
    }

    vi tmp = a;
    llint x = 0;

    for(int i = 0; i < n - 1; i++) {
	if(tmp[i] < 0) {
	    tmp[i] *= -1;
	    tmp[i + 1] *= -1;
	}

	x += tmp[i];
    }
    x += tmp[n - 1];

    rep(i, n) a[i] = abs(a[i]);
    
    llint sum = 0;
    int mn = 1000000001;
    
    rep(i, n) {
	mn = min(mn, a[i]);
	sum += a[i];
    }

    co << max(x, sum - mn * 2) << en;
    
    return 0;
}


Measured memory_bytes: 1144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while( sc.hasNext() ){
            String[] line = sc.nextLine().split(" ");
            int inputnum = Integer.parseInt(line[0]);
            int inputnum2 = Integer.parseInt(line[1]);
            if(inputnum == inputnum2){
                System.out.println("a == b");
            }
            else if(inputnum < inputnum2){
                System.out.println("a < b"); 
            }
            else {
                System.out.println("a > b");
            }
        }
    }
}

Measured memory_bytes: 26328
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

typedef long long int ll;
typedef pair<double, double> P;

bool cmp(P& lp, P& rp)
{
	double lt = 0, rt = 0;
	if (lp.second != 0 || lp.first != 0)
		lt = atan2(lp.second, lp.first);
	if (rp.second != 0 || rp.first != 0)
		rt = atan2(rp.second, rp.first);

	return lt < rt;
}

double dis(P& p)
{
	return sqrt(p.first * p.first + p.second * p.second);
}

int main()
{
	// 入力

	int n;
	cin >> n;
	vector<P> p(n);
	rep(i, n) cin >> p[i].first >> p[i].second;

	//

	// 処理

	sort(p.begin(), p.end(), cmp);
	double ans = 0, d = 0;
	rep(i, n)
	{
		P xy(0, 0);
		xy.first += p[i].first;
		xy.second += p[i].second;
		double d = dis(xy);
		for (int j = 1; j < n; j++)
		{
			xy.first += p[(i + j) % n].first;
			xy.second += p[(i + j) % n].second;
			d = max(d, dis(xy));
		}
		ans = max(ans, d);
	}

	//

	// 出力

	cout << setprecision(12) << fixed << ans;

	//

	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll A,B,C; cin >> A >> B >> C;

    bool res = false;
    F0R(i,B) {
        if ((A*(i+1))%B == C) res = true;
    }

    cout << ((res) ? "YES\n" : "NO\n");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;

    rep(i,n){
        while(a[i] % 2 == 0){
            a[i] /= 2;
            ans++; 
        }
    }
    cout << ans << endl;
} 

Measured memory_bytes: 384
import math

(a, v) = [int(s) for s in input().split()]
(b, w) = [int(s) for s in input().split()]
t = int(input())

d = abs(a - b)
d_v = abs(v - w)

if v > w and d <= d_v * t:
    print('YES')
else:
    print('NO')



Measured memory_bytes: 9184
struct UnionFind{
    par:Vec<usize>,
}

impl UnionFind{
    fn new(n:usize)->UnionFind{
        let mut v=Vec::<usize>::new();
        for i in 0..n{
            v.push(i);
        }
        UnionFind{par:v,}
    }

    fn find(&mut self,x:usize)->usize{
        if self.par[x]!=x{
            let z=self.par[x];
            self.par[x]=self.find(z);
            self.par[x]
        }
        else {
            x
        }
    }
    fn unite(&mut self,x:usize,y:usize){
        let xx=self.find(x);
        let yy=self.find(y);
        self.par[yy]=xx;
    }

    fn same(&mut self,x:usize,y:usize)->i32{
        if self.find(x)==self.find(y){
            return 1;
        }
        0
    }
}

fn main(){
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v:Vec<usize>=s.trim().split_whitespace()
                    .map(|e|e.parse().unwrap()).collect();
    let (n,m)=(v[0],v[1]);
    let mut uf =UnionFind::new(n);
    for _ in 0..m {
        let mut t = String::new();
        std::io::stdin().read_line(&mut t).unwrap();
        let x:Vec<usize>=t.trim().split_whitespace()
                    .map(|e|e.parse().unwrap()).collect();
        match x[0]{
            1 => println!("{}",uf.same(x[1], x[2]) ),
            0 => uf.unite(x[1],x[2]),
            _ => println!("{}",x[0]),
        }
    }
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int a,b;cin>>a>>b;
  if(a!=1&&b!=1){
    puts("1");return 0;
  }
  if(a!=2&&b!=2){
    puts("2");return 0;
  }
  if(a!=3&&b!=3){
    puts("3");return 0;
  }

  return 0;
}


Measured memory_bytes: 256
def resolve():
    S = input()
    c = 0
    f = 0
    C = []
    F = []
    for i in range(len(S)):
        if S[i] == "C":
            c = 1
            C.append(i)
        elif S[i] == "F":
            f = 1
            F.append(i)
    print("Yes" if c == 1 and f == 1 and min(C) < max(F) else "No")
resolve()

Measured memory_bytes: 3064
s = input()
if s == '0000' or (int(s[:2]) >= 13 and int(s[-2:]) >= 13):
    print('NA')
elif 1 <= int(s[:2]) <= 12 and 1 <= int(s[-2:]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(s[:2]) <= 12:
    print('MMYY')
elif 1 <= int(s[-2:]) <= 12:
    print('YYMM')
else:
    print('NA')

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

#define int long long 

#define fs first
#define sc second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define pb push_back
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MP make_pair
#define sqr(x) ((x) * (x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e5 + 100;
vector<pair<int, int>> g[N], rg[N];
vector<int> clr(N), ord, dist(N), used(N);
bool cycle = false;

void dfs(int v) {
	clr[v] = 1;
	for (auto i : g[v]) {
		int u = i.fs;
		if (clr[u] == 0) {
			dfs(u);
		} else if (clr[u] == 1) {
			cycle = true;
		}
	}
	clr[v] = 2;
	ord.pb(v);
}

void dfs1(int v) {
	used[v] = 1;
	for (auto i : g[v]) {
		int u, d;
		tie(u, d) = i;
		if (!used[u]) {
			dist[u] = dist[v] + d;
			dfs1(u);
		}
	}	
}

signed main() {
	fastio;
	#ifdef FlameDragon
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u, d;
		cin >> v >> u >> d;
		v--; u--;
		g[v].pb(MP(u, d));
		rg[u].pb(MP(v, -d));
	}

	for (int i = 0; i < n; i++) {
		if (clr[i] == 0) {
			dfs(i);
		}
	}
	if (cycle) {
		cout << "No\n";
		return 0;
	}
	reverse(all(ord));
	fill(all(used), 0);
	for (int i = 0; i < n; i++) {
		int v = ord[i];
		if (!used[v]) {
			dfs1(v);
		}
	}

	for (int v = 0; v < n; v++) {
		for (auto i : g[v]) {
			int u, d;
			tie(u, d) = i;
			if (dist[v] + d != dist[u]) {
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 21964
//Volume5-0583
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int   n,max;
		int[] m = {0,0,0};
		n=sc.nextInt();
		for(int i=0;i<n;i++){
			m[i]=sc.nextInt();
		}
		Arrays.sort(m);
		max = (m[2]+1)/2;

		if(n==2){
			for(int i=1;i<max;i++){
				if(m[1]%i==0 && m[2]%i==0){
					System.out.println(i);
				}
			}
		}
		if(n==3){
			for(int i=1;i<max;i++){
				if(m[0]%i==0 && m[1]%i==0 && m[2]%i==0){
					System.out.println(i);
				}
			}
		}
	}
}

Measured memory_bytes: 18836
#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define f first
#define s second
#define nax 3e5+2
using namespace std;
//1 - red 2 - green 3 - colorless
int main() 
{ 	
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<pair<ll,ll>> v;
	for(ll i=0;i<a;i++){
		ll temp;
		cin>>temp;
		v.pb({temp,1});
	}
	for(ll i=0;i<b;i++){
		ll temp;
		cin>>temp;
		v.pb({temp,2});
	}
	for(ll i=0;i<c;i++){
		ll temp;
		cin>>temp;
		v.pb({temp,3});
	}
	sort(v.rbegin(),v.rend());
	ll ans = 0;
	ll cntred =0,cntgre=0,rem =0;
	for(ll i=0;i<a+b+c;i++){
		if(v[i].s == 1 && cntred <x){
			ans += v[i].f;
			cntred++;
		}
		else if(v[i].s == 2 && cntgre <y){
			ans += v[i].f;
			cntgre++;
		}
		else if(v[i].s == 3){
			ans += v[i].f;
			rem++;
		}
		if(cntred + cntgre == x+y-rem){
			break;
		}
	}
	cout<<ans;
	return 0;
} 


Measured memory_bytes: 10604
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n,m=map(int,input().split())
    XY=[tuple(map(int,input().split())) for i in range(m)]
    graph=[[]for _ in range(n)]
    deg=[0]*n #頂点iの入次数
    for x,y in XY:
        graph[x-1].append(y-1)
        deg[y-1]+=1
    que=deque()
    for v in range(n):
        if deg[v]==0:
            que.append(v)
    dp=[0]*n
    while que:
        v=que.popleft()
        for nv in graph[v]:
            deg[nv]-=1
            if deg[nv]==0:
                que.append(nv)
                dp[nv]=max(dp[nv],dp[v]+1)
    ans=0
    for v in range(n):
        ans=max(ans,dp[v])
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 70492
import sys
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
prog=0
a_idx=0
b_idx=0

while a_idx<n:
    if a[a_idx]+prog>k:
        break
    prog+=a[a_idx]
    a_idx+=1

if a_idx==n:
    while b_idx<m:
        if b[b_idx]+prog>k:
            break
        prog+=b[b_idx]
        b_idx+=1

mx=a_idx+b_idx

if mx==n+m:
    print(mx)
    sys.exit()

for i in range(a_idx+1):
    while b_idx<m and b[b_idx]+prog<=k:
        prog+=b[b_idx]
        b_idx+=1
    if a_idx+b_idx>mx:
        mx=a_idx+b_idx
    if b_idx==m:
        break
    if a_idx==0:
        break
    a_idx-=1
    prog-=a[a_idx]

print(mx)

Measured memory_bytes: 40452
#include <iostream>
#include <string>

using namespace std;

int main(){

  int n;
  cin >> n;
  int answer = 0;
  
  answer += (n / 500) * 1000;
  n %= 500;
  
  answer += (n / 5) * 5;
  
  cout << answer << endl;
       
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll a, b;
    cin>>a>>b;
    if(a<b){
        ll mv=b;
        b=a;
        a=mv;
    }
    ll di=1, count=0;
    rep(i, a){
        count+=di*b;
        di*=10;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
for i in range(10000):
    
    H, W = map(int, input().split())
    
    if H == 0 and W == 0:
        break
    
    for j in range(H):
        if j % 2 == 0:
            for k in range(W):
                if k % 2 == 0:
                    print('#', end='')
                else:
                    print('.', end='')
        else:
            for k in range(W):
                if k % 2 == 0:
                    print('.', end='')
                else:
                    print('#', end='')
                    
        print()
    
    print()


Measured memory_bytes: 7008
#include "bits/stdc++.h"
using namespace std;
int main()
{
	long long n, m, total = 1;
	scanf("%lld %lld", &n, &m);
	if(n < m)
	{
		swap(n, m);
	}
	if(n == m)
	{
		total = 2;
	}
	if(n - m > 1)
	{
		printf("0\n");
		return 0;
	}
	else if(n >= m)
	{
		for(bool i = true; n || m; i = !i)
		{
			if(i)
			{
				(total *= n) %= 1000000007;
				--n;
			}
			else
			{
				(total *= m) %= 1000000007;
				--m;
			}
		}
	}
	printf("%lld\n", total);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 n, m, x[101010], d[101010];

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){cin >> x[i];}
	
	sort(x, x+m);
	
	for(int i = 0; i < m-1; i++){
		d[i] = x[i+1]-x[i];
	}
	
	sort(d, d+m-1);
	
	int a = 0;
	for(int i = 0; i <= m-1-n; i++){
		a += d[i];
	}
	
	cout << a << endl;
	
	return 0;
}

Measured memory_bytes: 1792
a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())
l = [a, b, c, d, e, f]

for i in range(1, 5):
  if l.count(i) == 3:
    print("NO")
    break
else:
  print("YES")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  int d[n];
  REP(i,n){
    cin>>d[i];
  }
  int ans = 0;
  REP(i,n){
    REP(j,i){
      ans += d[j]*d[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int ans[50];

int fibo(int n) {
    if( n == 0 || n == 1 ) return ans[n] = 1;
    if( ans[n] != -1 ) return ans[n];
    return ans[n] = fibo(n - 1) + fibo(n - 2);
}

int main() {
    int n;
    cin >> n;
    for ( int i = 0; i < 50; i++ ) ans[i] = -1;

    cout << fibo(n) << endl;

    return 0;
}


Measured memory_bytes: 3100