akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int H, W, N, sr, sc;;
  string S, T;
  std::cin >> H >> W >> N;
  std::cin >> sr >> sc;
  std::cin >> S >> T;
  pair<int, int> win_ul{1, 1}, win_lr{H, W};
  vvi win = vv(N, 4, 0, int);
  for(int i=N-1;i>=0;i--){
    if(S[i]=='L'){
      win_ul.second++;
    }else if(S[i]=='R'){
      win_lr.second--;
    }else if(S[i]=='U'){
      win_ul.first++;
    }else{
      win_lr.first--;
    }
    if(T[i]=='L'){
      if(win_lr.second<W) {
        win_lr.second++;
        if(win_lr.second==W&&S[i]=='R') win_lr.second--;
      }
    }else if(T[i]=='R'){
      if(win_ul.second>1){
         win_ul.second--;
         if(win_ul.second==1&&S[i]=='L') win_ul.second++;
      }
    }else if(T[i]=='U'){
      if(win_lr.first<H) {
        win_lr.first++;
        if(win_lr.first==H&&S[i]=='D') win_lr.first--;
      }
    }else{
      if(win_ul.first>1) {
        win_ul.first--;
        if(win_ul.first==1&&S[i]=='U') win_ul.first++;
      }
    }
    win[i][0]=win_ul.first;
    win[i][1]=win_ul.second;
    win[i][2]=win_lr.first;
    win[i][3]=win_lr.second;
    if(win[i][0]>win[i][2]|win[i][1]>win[i][3]){
      std::cout << "NO" << '\n';
      return 0;
    }
  }
  if(win[0][0]<=sr&& win[0][1]<=sc && win[0][2]>=sr &&win[0][3]>=sc){
    std::cout << "YES" << '\n';
  }else{
    std::cout << "NO" << '\n';
  }

  /*for(int i=0;i<N;i++){
    for(int j=1;j<=H;j++){
      for(int k=1;k<=W;k++){
        if(win[i][0]<=j&& win[i][1]<=k && win[i][2]>=j &&win[i][3]>=k){
          std::cout << "#";
        }else{
          std::cout << ".";
        }
      }
      std::cout << '\n';
    }
    std::cout << win[i][0] << win[i][1] << win[i][2] << win[i][3] << '\n';
    std::cout << '\n';
    std::cout << '\n';
  }*/

  return 0;
}


Measured memory_bytes: 11644
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
int a,b;
int main()
{
	fast;
	cin>>a>>b;
	if (a>=13)
	   cout<<b<<endl;
 else if (a<=12 && a>5)
    cout<<b/2<<endl;
 else
    cout<<0<<endl;
	return 0;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }

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

    while(true) {
        ll N, M;
        std::cin >> N >> M;
        if(N == 0 && M == 0) break;

        std::vector<ll> A(N);
        REP(i, N) {
            std::cin >> A[i];
        }
        ll ans = 0;
        for(int i = 0; i < N - 1; i++) {
            for(int j = i + 1; j < N; j++) {
                if(A[i] + A[j] <= M) chmax(ans, A[i] + A[j]);
            }
        }
        if(ans == 0) {
            std::cout << "NONE" << std::endl;
        }
        else {
            std::cout << ans << std::endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3148
import java.io.*;
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final FastReader s=new FastReader();
        int h = s.nextInt();
        int w = s.nextInt();
        int m = s.nextInt();
        
        // Map<Integer, Integer> xc = new HashMap<Integer, Integer>();
        // Map<Integer, Integer> yc = new HashMap<Integer, Integer>();
        int[] xc = new int[h+1];
        int[] yc = new int[w+1];
        // Set<String> b = new HashSet<>();
        Set<Long> b = new HashSet<>();
        int mx = 0;
        int my = 0;
        // boolean[][] b = new boolean[h][w];
        // Map<Integer, Set<Integer>> b =  new HashMap<>();

        for(int i=0; i<m; i++) {
            int x = s.nextInt();
            int y = s.nextInt();
            // if(!xc.containsKey(x)) xc.put(x, 0);
            // if(!yc.containsKey(y)) yc.put(y, 0);
            // xc.put(x, xc.get(x)+1);
            xc[x]++;
            mx = Math.max(mx, xc[x]);
            // yc.put(y, yc.get(y)+1);
            yc[y]++;
            my = Math.max(my, yc[y]);
            b.add(gethash(x,y));
            // if(mx==xc.get(x) || my==yc.get(y))
            // b.add(getString(x, y));
            // b[x-1][y-1] = true;
            // if(mx==xc.get(x) || my==yc.get(y)) {
            //     if(!b.containsKey(x)) b.put(x, new HashSet<>());
            //     b.get(x).add(y);
            // }
        }

        List<Integer> vx = new ArrayList<>();
        List<Integer> vy = new ArrayList<>();
        for(int i=0;i<xc.length;i++) {
            if(xc[i]==mx)
                vx.add(i);
        }

        for(int i=0;i<yc.length;i++) {
            if(yc[i]==my)
                vy.add(i);
        }
     
        for(int x : vx) {
            for(int y : vy) {
                if(!b.contains(gethash(x,y))) {
                    System.out.println(mx+my);
                    return;
                }                
            }
        }
        System.out.println(mx+my-1);
    }

    private static long gethash(int x, int y) {
        return x*1_000_000l + y;
    }

    // private static String getString(int x, int y) {
    //     return Integer.toString(x) + "." + Integer.toString(y);
    // }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try { st = new StringTokenizer(br.readLine()); }
                catch (final IOException  e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
        String nextLine() {
            String str = "";
            try { str = br.readLine(); }
            catch (final IOException e) { e.printStackTrace(); }
            return str;
        }
    }
}

Measured memory_bytes: 76100
#include<stdio.h>

int main(){
  int a,b,c,d;
  int count = 0;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  do{
    if( count % 2 == 0 ){
      c = c - b;
    }else{
      a = a - d;
    }
    //printf("%d %d %d\n",a,c,count);
    count++;
  }while( a > 0 && c > 0 );

  if( a > c ){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1616
# coding: utf-8

N = int(input())
input_Blue = [input() for i in range(N)]

M = int(input())
input_Red = [input() for j in range(M)]

dict_Blue = {}
for str_Blue in input_Blue:
  dict_Blue[str_Blue] = dict_Blue.get(str_Blue,0) + 1

dict_Red = {}
for str_Red in input_Red:
  dict_Red[str_Red] = dict_Red.get(str_Red,0) + 1

for Blue_Key in dict_Blue.keys():
    if Blue_Key in dict_Red.keys():
      dict_Blue[Blue_Key] = dict_Blue[Blue_Key] - dict_Red[Blue_Key]

if max(dict_Blue.values()) < 0 :
       print(0)
else:
       print(max(dict_Blue.values()))
  


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

using namespace std;

int main()
{
 int n,a,b;
  
  cin>>n>>a>>b;
  
  if(a*n>=b)
    cout<<b<<endl;
  else
    
    cout<<a*n<<endl;
  
  
  return 0;
  
}


Measured memory_bytes: 256
// #define LOCAL
// #define CPP_IO

#pragma region

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;

#define f first
#define s second

#ifdef LOCAL
#define debug cout
#else
#define debug \
    if (0) cout
#endif

#define DUMP(a) debug << #a " = " << (a) << "\n";
#define DUMP2(a, b) debug << #a " = " << (a) << " " #b " = " << (b) << "\n";
#define DUMP3(a, b, c) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << "\n";
#define DUMP4(a, b, c, d) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << " " #d " = " << (d) << "\n";

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[ ";
    for (auto e : v) os << e << " ";
    return os << "]";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
#ifdef CPP_IO
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
#endif
    solve();
}

#pragma endregion

const ll MOD = 1e9 + 7;
int n, c[200005], pre[200005], last[200005];
ll dp[200005];
void solve() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &c[i]);
        pre[i] = last[c[i]];
        last[c[i]] = i;
    }
    dp[1] = 1LL;
    for (int i = 2; i <= n; ++i) {
        if (c[i] == c[i - 1]) {
            dp[i] = dp[i - 1];
            continue;
        }
        dp[i] = dp[i - 1] + dp[pre[i]];
        dp[i] %= MOD;
        // DUMP2(i, dp[i]);
    }
    printf("%lld\n", dp[n]);
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main() {
    int W , H , x , y , r;
    cin >> W >> H >> x >> y >> r;
    if(x >= r && y >= r && W - r >= x && H - r >= y){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {
   int H,W,K;
   cin >> H >> W >> K;
   vvi G(H,vi(W,0));

   string S[310];
   rep(i,H){
       cin >>S[i];
   }

   int strawBerryCount=1;
   rep(i,H){
       rep(j,W){
        
        if(S[i][j] == '#'){
           G[i][j] = strawBerryCount;
           strawBerryCount++;
        }
    };
   }
    
    //4方向に累積和みたいなことをしていく
    //→
    rep(i,H){
       rrep(j,W-1){
            if(G[i][j] == 0){
                G[i][j] = G[i][j-1];
            }
        }
    }
    //←
    rep(i,H){
        for(int j=W-2;j>=0;j--){
            if(G[i][j] == 0){
                G[i][j] = G[i][j+1];
            }
        }
    }
    //↓
    rep(j,W){
        rrep(i,H-1){
            if(G[i][j] == 0){
                G[i][j] = G[i-1][j];
            }
        }
    }
    //↑
    rep(j,W){
        for(int i=H-2;i>=0;i--){
            if(G[i][j] == 0){
                G[i][j] = G[i+1][j];
            }
        }      
    }

    rep(i,H){
        rep(j,W){
            cout << G[i][j]<< " ";
        }
        cout<<endl;
    }
    
    
    

}

Measured memory_bytes: 1280
S = input()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print ("Yes")
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print ("Yes")
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print ("Yes")
else:
    print ("No")

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner(os.Stdin)
	N := sc.NextInt()
	Q := sc.NextInt()
	S := sc.Next()
	R := []rune(S)
	num := make([]int, N+1)
	for i := 0; i < len(R)-1; i++ {
		if R[i] == rune('A') && R[i+1] == rune('C') {
			num[i+2] = num[i+1] + 1
		} else {
			num[i+2] = num[i+1]
		}
	}
	for i := 0; i < Q; i++ {
		l := sc.NextInt()
		r := sc.NextInt()
		ans := num[r] - num[l-1]
		if l-2 >= 0 && R[l-2] == rune('A') && R[l-1] == rune('C') {
			ans--
		}
		fmt.Println(ans)
	}
}

func lcm(x, y int) int {
	x, y = max(x, y), min(x, y)
	if y == 0 {
		return x
	}
	return lcm(y, x%y)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// scanner
type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner(r io.Reader) *Scanner {
	rdr := bufio.NewReaderSize(r, 1024)
	return &Scanner{r: rdr}
}

func (s *Scanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		line, isp, err := s.r.ReadLine()
		if err != nil {
			os.Exit(1)
		}
		s.buf = append(s.buf, line...)
		if !isp {
			break
		}
	}
}

func (s *Scanner) NextInt() int {
	i, err := strconv.Atoi(s.Next())
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) NextFloat64() float64 {
	i, err := strconv.ParseFloat(s.Next(), 64)
	if err != nil {
		os.Exit(1)
	}
	return i
}

func (s *Scanner) Next() string {
	s.Pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	next := string(s.buf[start:s.p])
	s.p++
	return next
}

func (s *Scanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}


Measured memory_bytes: 6016
#include <stdio.h>

int main(void){
	double a, b, c, d, e, f;
	double det;
	double x, y;

	while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		det =  (a*e) - (b*d);
		y = ((a*f) - (c*d)) /det;
		x = ((c*e) - (b*f)) / det;

		if(x == 0){
			printf("0.000 %.3f\n", y);
		}else if(y == 0){
			printf("%.3f 0.000\n", x);
		}else if(x == 0 && y == 0){
			printf("0.000 0.000\n");
		}else{
			printf("%.3f %.3f\n", x, y);
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=998244353;
const long double eps=1e-60;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,m;cin>>n>>m;
    vector<bitset<300>> v(n);
    rep(i,n){
        rep(j,m){
            int a;cin>>a;
            if(a)v[i].set(j);
        }
    }
    ll cnt=n;
    vb used(n,false);
    rep(i,300){
        ll k=-1;
        rep(j,n)if(!used[j]&&v[j].test(i)){
            if(k==-1){
                k=j;used[j]=true;
            }
            else v[j]^=v[k];
        }
        if(k!=-1)cnt--;
    }
    out((modpow(2,n)-modpow(2,cnt)+mod)*modpow(2,m-1)%mod);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;io.in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
struct IO{
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
}io;
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n,x,t);
    io.out(t*updivide(n,x));
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
        set<char> right={'y', 'u', 'i', 'o', 'p', 'h', 'j', 'k', 'l', 'n', 'm'};
        string s;
        while(cin>>s && s!="#"){
                int ans=0;
                rep(i, (int)s.size()-1){
                        int a=right.find(s[i])!=right.end();
                        int b=right.find(s[i+1])!=right.end();
                        if(a!=b) ++ans;
                }
                printf("%d\n", ans);
        }
}


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

int main(){
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;

    for(int i = 0;i < s.size();i++){
        if(i != a){
            if(!('0' <= s[i] && s[i] <= '9')){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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;
}
using namespace std;

void solve(){
	ll a[3];
    rep(i,3)cin>>a[i];
    sort(begin(a),end(a));
    if(a[0]%2&&a[1]%2&&a[2]%2){
        cout<<(a[2]-a[2]/2)*a[1]*a[0]-a[2]/2*a[1]*a[0]<<"\n";
    }
    else cout<<0<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int K, N; cin >> K >> N; 
	int A[200010] = {}; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	A[N] = A[0] + K; 
	int mx = 0;  
	for(int i = 0; i < N; i++) mx = max(mx, A[i+1] - A[i]); 
	cout << K - mx << endl; 
}

Measured memory_bytes: 1024
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    s, t = input().split()
    a, b = LI()
    u = input()
    if u == s:
        print("{} {}".format(a - 1, b))
    elif u == t:
        print("{} {}".format(a, b - 1))
    return


# B
def B():
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38384
import sys

readline = sys.stdin.readline
class Bit:
    def __init__(self, lst):
        t = 1
        while (t << 1) <= len(lst):
            for i in range(t, len(lst) - t + 1, t << 1):
                lst[i + t - 1] += lst[i - 1]
            t <<= 1
        self.lst = lst

    def add(self, pos, value):
        pos += 1
        while pos <= len(self.lst):
            self.lst[pos - 1] += value
            pos += pos & (-pos)

    def update(self, pos, value):
        diff = value - self.at(pos)
        self.add(pos, diff)

    def at(self, pos):
        return self.sum(pos + 1) - self.sum(pos)
    
    def sum(self, pos):
        # sum of [0, pos)
        if pos == 0:
            return 0
        s = 0
        while pos > 0:
            s += self.lst[pos - 1]
            #pos -= pos & (-pos)
            pos &= ~(-pos)
        return s
    
def solve():
    N = int(readline())
    A = [float(readline()) for i in range(N)]

    C = [0] * N
    c5s = set()

    for i, a in enumerate(A):
        #b = int(a * (10 ** 9))
        #b = a * (10 ** 9)
        b = round(a * (10 ** 9))
        c2, c5 = -9, -9
        while b % 2 == 0:
            b //= 2
            c2 += 1
        while b % 5 == 0:
            b //= 5
            c5 += 1
        
        C[i] = (c2, c5)
    
    Q = [(-a, -b) for a,b in C]

    count0 = sum(a >= 0 and b >= 0 for a,b in C)

    # Coordinate compression
    s1 = set()
    s2 = set()
    for a,b in C:
        s1.add(a)
        s2.add(b)
    for a,b in Q:
        s1.add(a)
        s2.add(b)
    xs = sorted(s1)
    ys = sorted(s2)
    compA = {v: i for i, v in enumerate(xs)}
    compB = {v: i for i, v in enumerate(ys)}
    C = [(compA[a], compB[b]) for a,b in C]
    Q = [(compA[a], compB[b]) for a,b in Q]
    H, W = len(xs), len(ys)

    C.sort()
    Q.sort(reverse=True)

    bit = Bit([0] * W)
    ans = 0

    j = N - 1
    for x, y in Q:
        while j >= 0 and C[j][0] >= x:
            bit.add(C[j][1], 1)
            j -= 1
        ans += bit.sum(W) - bit.sum(y)

    print((ans - count0) // 2)


solve()

Measured memory_bytes: 130788
def main():
    members = int(input())
    days, lest = map(int, input().split(" "))
    eaten_chocolate = 0
    for _ in range(members):
        eaten_chocolate += (1 + (days - 1) // int(input()))
    print(eaten_chocolate + lest)


if __name__ == '__main__':
    main()

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

int N;
vint G[111111];
int C[111111];

int ans[111111];
void dfs(int v,int p,int &t){
	ans[v]=C[t++];
	for(auto u:G[v]){
		if(u==p)continue;
		dfs(u,v,t);
	}
}

signed main(){
	cin>>N;
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);G[b].pb(a);
	}

	rep(i,N)cin>>C[i];
	sort(C,C+N);reverse(C,C+N);
	int t=0;
	dfs(0,-1,t);

	cout<<accumulate(C+1,C+N,0ll)<<endl;
	rep(i,N){
		if(i)cout<<" ";
		cout<<ans[i];
	}cout<<endl;
	return 0;
}

Measured memory_bytes: 3840
N,M=map(int,input().split())
A={int(input()) for _ in range(M)}
mod=10**9+7

dp=[0]*(N+1)
dp[0]=1
dp[1]=1
if 1 in A:
  dp[1]=0

for i in range(2,N+1):
  if i in A:
    continue
  dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[N])

Measured memory_bytes: 11884
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
ll ppow(ll x, ll n) {
	ll ans = 1;
	while (n > 0) {
		if ((n & 1) == 1)ans = ans * x;
		x = x * x;
		n >>= 1;
		x %= mod;
		ans %= mod;
	}
	return ans;
}
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll sz, fact[N], inv[N];
void setinv() {
	fact[0] = 1; inv[0] = 1;
	for (int i = 1; i <= sz; i++) {
		fact[i] = (fact[i - 1] * i) % mod;  //階乗を求める
		inv[i] = ppow(fact[i], (ll)mod - 2) % mod; // フェルマーの小定理で逆元を求める
	}
}
ll conv(ll r) {//nCr
	return fact[sz] * inv[r] % mod * inv[sz - r] % mod;
}
int main() {
	int v[3],ans=0;
	cin >> v[0] >> v[1] >> v[2];
	sort(v, v + 3);
	ans += (v[1] - v[0]) / 2;
	if ((v[1] - v[0]) % 2 == 1) { ++ans; v[2]++; }
	cout << ans + v[2] - v[1] << endl;
	return 0;
}

Measured memory_bytes: 256
/*
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
*/
#include <bits/stdc++.h>

#define rep(i,n)  for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n % 2){
        cout << n/2 +1 ;
    }else{
        cout << n/2;
    }
    return 0;
}


Measured memory_bytes: 256
local ior = io.input()
local t = {}
for i = 1, 100000 do t[i] = 0 end
local n = ior:read("*n")
for i = 1, n do
  local a = ior:read("*n")
  if 1 < a then t[a - 1] = t[a - 1] + 1 end
  if 0 < a then t[a] = t[a] + 1 end
  t[a + 1] = t[a + 1] + 1
end
local ret = 0
for i = 1, 100000 do
  ret = math.max(ret, t[i])
end
print(ret)


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[(int) Math.pow(10, 5)];
        for (int i = 0; i < n; i++) {
            int aa = Integer.parseInt(sc.next());
            a[aa]++;
        }
        int ans = 0;
        if (n == 1) {
            System.out.println(1);
            return;
        }
        for (int i = 0; i < n - 1; i++) {
            int temp = 0;
            if (i != 0) {
                temp += a[i - 1];
            }
            temp += a[i];
            temp += a[i + 1];
            ans = Math.max(ans, temp);
        }
        System.out.println(ans);
    }
}

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

void maxHeapify(int a[], int n, int i) {
	int l = i * 2;
	int r = l + 1;
	int largest = i;
	if (l <= n && a[l] > a[largest]) {
		largest = l;
	}
	if (r <= n && a[r] > a[largest]) {
		largest = r;
	}
	if (largest != i) {
		int tmp = a[largest];
		a[largest] = a[i];
		a[i] = tmp;
		maxHeapify(a, n, largest);
	}
}

void buildMaxHeap(int n, int a[]) {
	for (int i = n/2; i >= 1; i--) {
		maxHeapify(a, n, i);
	}
}

int main() {
	int n, i;
	cin >> n;
	int a[n+1];
	for (i=1;i<=n;i++) {
		cin >> a[i];
	}
	buildMaxHeap(n, a);
	for (i=1;i<=n;i++) {
		cout << " " <<  a[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 4948
<?php
/*
  AOJ 0598
  Title:JOI Emblem
  @kankichi573
*/
$result=array();
$hata=array();
$template=array();

fscanf(STDIN,"%d %d",$m,$n);

for($i=0;$i<$m;$i++)
  fscanf(STDIN,"%s",$hata[$i]);
for($i=0;$i<2;$i++)
  fscanf(STDIN,"%s",$template[$i]);
$cnt4=0;


for($i=0;$i<$m-1;$i++)
  for($j=0;$j<$n-1;$j++)
    {
      $cnt=0;
      for($k=0;$k<2;$k++)
	for($l=0;$l<2;$l++)
	  $cnt+=(substr($hata[$i+$k],$j+$l,1)==substr($template[$k],$l,1))?1:0;
      
      if($cnt==4)
	$cnt4++;
      if($cnt==3)
	{
	for($k=0;$k<2;$k++)
	  for($l=0;$l<2;$l++)
	    if(substr($hata[$i+$k],$j+$l,1)!=substr($template[$k],$l,1))
	      {
		if(isset($result[$i+$k][$j+$l][substr($template[$k],$l,1)]))
		  $result[$i+$k][$j+$l][substr($template[$k],$l,1)]++;
		else
		  $result[$i+$k][$j+$l][substr($template[$k],$l,1)]=1;
	      }
	}
    }

$max=0;
foreach ($result as $key1 => $val1)
{
  foreach ($val1   as $key2 => $val2)
    {
      foreach($val2 as $key3 => $val3)
	{
	  $max = max($max,$val3);
	}
    }
}

printf("%d\n",$cnt4+$max);

return(0);

?>

Measured memory_bytes: 116608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,q) for(int i = 0; q > i; i++)
#define repp(i,o,q) for(int i = o; q > i; i++)
#define reppp(i,o,q) for(int i = o; q >= i; i++)
int main(){
  int N,K;cin >> N >> K;
  int a[N];rep(i,N)cin>>a[i];
  int dp[N+1];
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  repp(i,2,N){
    dp[i] = 2000000000;
    reppp(j,1,K){
      if(i-j < 0)break;
      dp[i] = min( dp[i-j] + abs(a[i-j] - a[i]),dp[i]);
    }
  }
  cout << dp[N-1] << endl;
}

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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, 1000)
    {
        string t;
        int x = i;
        rep(j, 3)
        {
            t += '0' + x % 10;
            x /= 10;
        }

        int ti = 0;
        rep(j, n)
        {
            if (s[j] == t[ti])
            {
                ++ti;
                if (ti == 3)
                {
                    ans++;
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string s; cin>>s;
    if(s<="2019/04/30") cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
     
#define PB(x) push_back(x)
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x) make_pair(x);
    
#define debug(x) cerr << #x << '=' << x << endl;
#define debug2(x, y) cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(a) for (int x: a) cerr << x << ' '; cerr << endl;
#define debugm(a, n, m) for (int i = 0; i < n; i++, cout << endl)           \
						for (int j = 0; j < m; j++) cout << a[i][j] << ' ';

#define int long long
     
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{
	int n;
	cin >> n;
	int v[n];
	for (int& x: v) cin >> x;
	
	sort(v, v+n);
	double ans = (v[0] + v[1])/2.0;
	
	for (int i = 2; i < n; i++) {
		ans = (ans+v[i])/2.0;
	}
	cout << ans << endl;
}


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

int main(void){
	ll x,y,z,k;
	cin>>x>>y>>z>>k;
	vector<ll> a(x);
	rep(0,i,x)cin>>a[i];
	vector<ll> b(y);
	rep(0,i,y)cin>>b[i];
	vector<ll> c(z);
	rep(0,i,z)cin>>c[i];
	ll n0=x*y;
	ll c0=0;
	vector<ll> sum(n0);
	rep(0,i,x){
	    rep(0,j,y){
	        sum[c0]=a[i]+b[j];
	        ++c0;
	    }
	}
	sort(sum.rbegin(),sum.rend());
    sort(c.rbegin(),c.rend());
    ll n1=min(n0,k),n2=min(z,k),n3=n1*n2;
    ll c1=0;
    vector<ll> ans(n3);
    rep(0,i,n1){
        rep(0,j,n2){
            ans[c1]=sum[i]+c[j];
            ++c1;
        }
    }
    sort(ans.rbegin(),ans.rend());
    rep(0,i,k){
        cout<<ans[i]<<endl;
    }
}

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

int main(){
    long long A, B, C, K;
    cin >> A >> B >> C >> K;
    
    if(abs(A-B) > round(pow(10,18))){
        cout << "Unfair" << endl;
        return 0;
    }

    if(K%2 == 0){
        cout << A-B << endl;
    }else{
        cout << B-A << endl;
    }
    return 0;

}

Measured memory_bytes: 3624
// VABC049_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M;
    cin >> N >> M;
    vector<string> vec(N);
    REP(i, N) cin >> vec[i];

    // calculation
    REP(i, N) {
        cout << vec[i] << "\n";
        cout << vec[i] << "\n";
    }
    
    return 0;
}

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

using namespace std;

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

const int MOD = 1000000007;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    cout << max(0, c - (a - b)) << endl;

    return 0;
}



Measured memory_bytes: 256
module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

------------------------------------------

main :: IO ()
main = do
  [n, m] <- readInts
  edges <- replicateM m $ do
    [a, b] <- readInts
    return (a-1, b-1)
  let graph = createGraph n edges
  print $ solve n graph

type Graph = [[Int]]

createGraph :: Int -> [(Int, Int)] -> Graph
createGraph n edges = loop (replicate n []) edges
  where updateGraph i v graph = concat [take i graph, [v : (graph !! i)], drop (i+1) graph]
        loop graph [] = graph
        loop graph ((a,b):es) =
          let nextGraph = updateGraph b a $ updateGraph a b graph
          in loop nextGraph es

solve :: Int -> Graph -> Int
solve n graph = dfs 0 1 [0]
  where dfs i depth visited
          | depth == n = 1
        dfs i depth visited
          | nexts == [] = 0
          | otherwise = sum $ flip map nexts $ \w -> dfs w (depth+1) (w:visited)
            where nexts = filter (not . (`elem` visited)) $ graph !! i
          -- in sum $ flip map nexts $ \w -> dfs w (depth+1) (w:visited)

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"


Measured memory_bytes: 1020
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<climits>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define INF 0x3f3f3f3f
#define MAXN int(1e5)
int x[MAXN+5];
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int main(){
	int n=read(),p=read();
	if(n==1){
		printf("%d\n",abs(p-read()));
		return 0;
	}
	int tmp=abs(p-read());
	for(int i=2;i<=n;i++)
		tmp=gcd(tmp,abs(read()-p));
	printf("%d\n",tmp);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n,0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 200005
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define flush fflush(stdout);

int main(){

    fast;

    string a;
    cin >> a;
    ll i,n=a.size();
    ll sum = 0;
    for(i=0;i<n;i++){
        sum+=(int(a[i]-'0'));
    }
    if(sum%9){
        cout << "No\n";
    }
    else{
        cout << "Yes\n";
    }

}

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


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

int main()
{
  int n, x; cin >> n >> x;
  // vector<ll> donuts;
  ll min_donut = pow(10, 6);
  int ans = 0;

  rep(i,n) {
    ll tmp; cin >> tmp;
    x -= tmp;
    ans ++;

    if (min_donut > tmp) {
      min_donut = tmp;
    }
  }
  ans = ans + (x / min_donut);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 1e6+6;
const ll inf =1e9;

ll a[MAX];
int main(){
	fastio;
	ll tc,n,m,b;
	tc=1;
//	cin>>tc;
	while(tc--){
		cin>>n;
		f(i,2,n+1) cin>>b, a[b]++;
		f(i,1,n+1) cout<<a[i]<<" ";
		cout<<endl;
	}
}

Measured memory_bytes: 5152
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] d = na(n);
		int result = 0;
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				result += d[i] * d[j];
			}
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> a(5);
  for (int i = 0; i < 5; i++)
    cin >> a[i];
  ll mn = *min_element(begin(a), end(a));
  ll g = (n + mn - 1) / mn;
  cout << 4 + g << '\n';
  return 0;
}

Measured memory_bytes: 384
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g




n = int(input())
w = list(map(int,input().split()))
l = 0
r = 0
ans = 10000000000000000000


for i in range(1,n+1):
    l = sum(w[0:i])
    r = sum(w[i:])
    if ans > abs(l-r):
        ans = abs(l-r)

print(ans)







Measured memory_bytes: 3064