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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<LL,LL>;
using Pdd = P<double,double>;
using Psi = P<string,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

P<Vll,Vll> primeFactor(LL n){
    Vll p,e; LL m=n; int c;
    for(LL i=2;i*i<=n;i++){
        if(m%i!=0){continue;}
        c=0;
        while(m%i==0){c++;m/=i;}
        p.pb(i); e.pb(c);
    }
    if(m>1){ p.pb(m); e.pb(1);}
    return mp(p,e);
}

int main(){
    LL N;
    cin>>N;
    auto p = primeFactor(N);

    LL ans = 0;
    REP(i,p.fi.size()){
        LL cnt = 0;
        LL sum_e = 0;
        LL j = 1;
        LL e = p.se[i];
        while(sum_e+j<=e){
            cnt++;
            sum_e += j;
            j++;
        }
        ans += cnt;
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test


constexpr int mod = 1e9 + 7;

struct M {
    unsigned v;
    M(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    M& operator+=(M r) { if ((v += r.v) >= mod) v -= mod; return *this; }
    M& operator-=(M r) { if ((v += mod - r.v) >= mod) v -= mod; return *this; }
    M& operator*=(M r) { v = (uint64_t)v * r.v % mod; return *this; }
};

uint32_t add(M a, M b) { return (a += b).v; }
uint32_t mul(M a, M b) { return (a *= b).v; }
uint32_t sub(M a, M b) { return (a -= b).v; }

uint32_t po(M x, int n) {
    M res(1);
    while (n > 0) {
        res *= (n & 1 ? x : 1);
        x *= x; n /= 2;
    }
    return res.v;
}

constexpr int maxn = 1003;

int32_t dp[maxn][maxn];
char s[maxn][maxn];

void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> s[i][j];
        }
    }
    dp[1][1] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            if (i == 1 && j == 1) continue;
            if (s[i][j] == '.') {
                dp[i][j] = add(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    cout << dp[n][m] << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 8452
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Data.List

modNum :: Integer
modNum = 10^9 + 7

canSolve :: [Integer] -> Bool
canSolve arr
    | isOdd = canSolveOdd sorted 0
    | otherwise = canSolveEven sorted 0
    where
        isOdd = ((length arr) `mod` 2) > 0
        sorted = sort arr

canSolveOdd :: [Integer] -> Integer -> Bool
canSolveOdd [] _ = True
canSolveOdd (x:xs) idx
    | x == target = canSolveOdd xs (idx + 1)
    | otherwise = False
    where
        target = ((idx + 1) `div` 2) * 2


canSolveEven :: [Integer] -> Integer -> Bool
canSolveEven [] _ = True
canSolveEven (x:xs) idx
    | x == target = canSolveEven xs (idx + 1)
    | otherwise = False
    where
        target = (idx `div` 2) * 2 + 1

modPow :: Integer -> Integer -> Integer
modPow _ 0 = 1
modPow x y = (x * (modPow x (y - 1))) `mod` modNum

solve:: [Integer] -> Integer
solve arr
    | (canSolve arr) = modPow 2 (fromIntegral ((length arr) `div` 2))
    | otherwise = 0

main :: IO ()
main = do
    _ <- BS.getLine
    a <- map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine
    print $ solve a


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

int main(){
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  if(2*x==W && 2*y==H){
    printf("%lf %d\n", (double)W*(double)H/2, 1);
  }
  else{
    printf("%lf %d\n", (double)W*(double)H/2, 0);
  }
  return 0;
}

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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 100005;
int n , ara[N];
int tree[4 * N];

void update(int node,int L,int R,int pos,int val)
{
    if(pos < L or pos > R)return;
    if(pos == L and pos == R){
        tree[node] = val;
        return;
    }
    int mid = (L + R)/2;
    update(2 * node,L,mid,pos,val);
    update(2 * node + 1,mid + 1,R,pos,val);
    tree[node] = max(tree[2 * node] ,tree[2 * node + 1]);
}
int query(int node,int L,int R,int from,int val)
{
    int mid = (L + R)/2;
    if(L >= from){
        if(L == R){
            if(tree[node] > val)return L;
            return 2e9;
        }
        if(tree[2 * node] > val){
            return query(2 * node,L,mid,from,val);
        }else if(tree[2 * node + 1] > val){
            return query(2 * node + 1,mid + 1,R,from,val);
        }else{
            return 2e9;
        }
    }else{
        if(R < from)return 2e9;
        return min(query(2 * node,L,mid,from,val),query(2 * node + 1,mid + 1,R,from,val));
    }
}
int main()
{
    FastRead
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> ara[i];
        update(1,1,n,i,ara[i]);
    }

    set<int>st;
    for(int i = 1;i <= n;i++)st.insert(i);

    int done = 0,ans = 1,val = -1;
    while(st.size() > 0){
        auto it = st.upper_bound(done);
        if(it == st.end()){
            done = 0;
            val = -1;
            ans++;
            continue;
        }
        int in = query(1,1,n,*it,val);
        if(in == 2e9){
            done = 0;
            val = -1;
            ans++;
            continue;
        }
        update(1,1,n,in,0);
        done = in;
        st.erase(in);
        val = ara[in];
    }
    cout << ans << "\n";

}



Measured memory_bytes: 6400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int Q = 301;

void solve() {
	int h,a,n;
  cin>>h>>n;
  REP(i,1,n) {
  	cin>>a;
    h -= a;
  }
  if (h<=0) cout<<"Yes";
  else cout<<"No";
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include<iterator>
#include<utility>
#include<math.h>
#include <cmath>
#include<algorithm>


using namespace std;

typedef long long ll; // %lld
typedef vector<int> vi;
typedef pair<int, int> pi;

#define mod (pow(10,9)+7);
#define PB push_back
#define POB pop_back
#define MP make_pair
#define itri std::vector<int>::iterator
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)


void showpq(vector <ll> gq)
{
	vector <ll> g = gq;
	reverse(g.begin(), g.end());
	while (!g.empty())
	{
		cout << g.back() << " ";
		g.pop_back();
	}
	cout << '\n';
}

double findMedian(vector <ll> a, ll n)
{
	// First we sort the array
	//sort(a, a + n);
	sort(a.begin(), a.end());

	// check for even case
	if (n % 2 != 0)
		return (long double)a[n / 2];

	return (long double)(a[(n - 1) / 2] + a[n / 2]) / 2.0;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("inno.in", "r", stdin);
	freopen("ottu.txt", "w", stdout);
#endif

	ll n, L, H, m, diff;

	cin >>  n;
	m = n;
	vector<ll> low, high;

	while (n--)
	{
		cin >> L >> H ;
		low.PB(L);
		high.PB(H);
	}

	sort(low.begin(), low.end());
	sort(high.begin(), high.end());

	//diff = ll(findMedian(high, m) - findMedian(low, m));

	if (m % 2 != 0)
	{
		cout <<  ( ( high[(m - 1) / 2] - low[(m - 1) / 2] )  + 1)  << endl;
	}
	if (m % 2 == 0)
	{
		cout <<  (  ( ( high[m / 2] + high[(m / 2) - 1] )  -  ( low[m / 2] + low[(m / 2) - 1] )  ) + 1)  << endl;
	}


	return 0;
}

Measured memory_bytes: 6644
from collections import Counter

n = int(input())
s_list = []

for i in range(n):
    s_list.append(input())

s_list.sort()
c = Counter(s_list)
l = c.most_common()    
count = l[0][1]
l.sort()
for i in l:
    if count == i[1]:
        print(i[0])

Measured memory_bytes: 46840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG 

int main(){
   int d,g;
   cin>>d>>g;
   ll p[d];
   ll c[d];
   ll sum[d];
   rep(i,d){
       cin>>p[i]>>c[i];
       sum[i]=100*(i+1)*p[i]+c[i];
   }

   ll ans= INF;
   for(int bit=0;bit<(1<<d); bit++){
       ll a=0;
       int b=-1;
       ll pans=0;
       //aは暫定の合計、bは全部解かない問題のうち一番得点が高い物、pansは解いた問題数の暫定
       rep(i,d){
           if(bit&(1<<i)){
               a+=sum[i];
               pans+=p[i];
           }
           else b=max(b,i);
       }
       if(a>=g) ans=min(ans,pans);
       else {
           int count=0;
           while(count<p[b]&&a<g){
               a+=100*(b+1);
               count++;
               pans++;
           }
           if(a>=g) ans=min(ans,pans);
           else continue;

       }
   }

   cout<<ans<<endl;

}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	int neg = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>arr[i] ;
		if(arr[i] < 0)
			neg++ ;
	}
	for(int i = 0 ; i < n ; ++i)
	{
		if(neg == n)
			arr[i] *= -1 ;
	}
	sort(arr , arr + n) ;
	vector< pair<int , int> >ans ;
	if(neg > 0 && neg < n)
	{
		int cnt = 0 ;
		for(int i = 1 ; i < n ; ++i)
		{
			if(arr[i] >= 0)
				arr[i-cnt] = arr[i] ;
			else
			{
				cnt++ ;
				ans.emplace_back(arr[n-1] , arr[i]) ;
				arr[n-1] -= arr[i] ;
			}
		}
		n -= cnt ;
	}
	int cur = arr[0] ;
	for(int i = 1 ; i < n-1 ; ++i)
	{
		ans.emplace_back(cur , arr[i]) ;
		cur -= arr[i] ;
	}
	if(arr[n-1] >= 0)
		ans.emplace_back(arr[n-1] , cur) ;
	else
		ans.emplace_back(cur , arr[n-1]) ;
	cout<<ans.back().first - ans.back().second<<"\n" ;
	for(int i = 0 ; i < ans.size() ; ++i)
	{
		if(neg == n)
		{
			ans[i].first *= -1 , ans[i].second *= -1 ;
			if(i == ans.size() - 1)
				swap(ans[i].first , ans[i].second) ;
		}
		cout<<ans[i].first<<" "<<ans[i].second<<"\n" ;
	}
	return 0 ;
}		

Measured memory_bytes: 4652
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			String str=sc.next();
			if(str.equals("-")){
				break;
			}else{
				char[] ar = str.toCharArray();
				Queue<Character> q = new LinkedList<Character>();
				for(char ch:ar){
					q.offer(ch);
				}
				int m=sc.nextInt();
				for(int i=0;i<m;i++){
					int h=sc.nextInt();
					for(int j=0;j<h;j++){
						char ch=q.poll();
						q.offer(ch);
					}
				}
				while(q.size()>0){
					System.out.print(q.poll());
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 26356
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;



int main(){
    int N;
    cin >> N;
    int a[N];
    int XX[100001] = {0};

    for(int i = 0 ; i < N; i++){
        cin >> a[i];
        XX[a[i]+2]++;
        XX[a[i]+1]++;
        XX[a[i]]++;
    }

    int result = 0;

    for(int i = 0; i < 100001; i++){
        if(result < XX[i]){
            result = XX[i];
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoderBC042 {
  class AtCoderBC042 {
    static void Main(string[] args) {
      new AtCoderBC042().solve1();
    }

    private void solve1() {
      string[] input = Console.ReadLine().Split();
      int[] a = Array.ConvertAll(input, Int32.Parse);
      int cc = 0; int cs = 0;
      foreach (int x in a) {
        if (x == 5)
          cc++;
        if (x == 7)
          cs++;
      }
      Console.WriteLine(cc == 2 && cs == 1 ? "YES" : "NO");     
    }//end M.

  }
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
#define pb              push_back
#define ll              long long int
#define scd(a)          scanf("%d",&a)
#define mp(a,b)         make_pair(a,b)
#define scl(w)          scanf("%I64d",&w)
#define scdd(a,b)       scanf("%d %d",&a,&b)
#define srt(a)          sort(a.begin(),a.end())
#define rsrt(a)         sort(a.rbegin(),a.rend())
#define scll(a,b)       scanf("%I64d %I64d",&a,&b)
///4direction ->        int del_x[]={-1,0,1,0},del_y[]={0,1,0,-1};
#define input(v,n)      for (int i=0;i<n;i++){int a;cin >> a;v.push_back(a);}
#define inputll(v,n)    for (ll i=0;i<n;i++){ll a;cin >> a;v.push_back(a);}
#define vii             vector < int >
#define vll             vector < ll >
#define pii             pair < int , int >
#define pll             pair < ll , ll >
#define show(x)         cout << #x << " : " << x << endl
#define mk              make_pair
#define inf             10000000000000016

#define maxn            1000006

using namespace std;

int main()
{
      string s,t;
      cin >> s >> t;
      ll ans = 0;
      for (int i=0 ; i<s.size() ; i++){
            if (s[i]!=t[i])ans++;
      }
      cout << ans << endl;



      return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  if(abs(c-a) <=d)
    cout << "Yes" << endl;
  else{
    if(abs(b-a) <= d && abs(c-b) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 2010
#define inf (1<<30)
int l[10],sum[1000],cnt[1000];
int main(){
	int n,a,b,c; 
	in(n);in(a);in(b);in(c);
	FOR(i,1,n)in(l[i]);
	FOR(i,1,(1<<n)-1){
		cnt[i]=-10;
		FOR(j,0,n-1)
			if(i&(1<<j)){
				sum[i]+=l[j+1];
				cnt[i]+=10;
			}
	}
	int ans=inf;
	FOR(i,1,(1<<n)-1)
		FOR(j,1,(1<<n)-1)
			FOR(k,1,(1<<n)-1)
				if((i&j)==0&&(i&k)==0&&(j&k)==0){
					ans=min(ans,cnt[i]+cnt[j]+cnt[k]+abs(sum[i]-a)+abs(sum[j]-b)+abs(sum[k]-c));
				}
	out(ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    int a[4],b[4],hit,blow;
    
    while(scanf("%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
        hit=0;blow=0;
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(a[i]==b[j]){
                    if(i==j) hit++;
                    else blow++;
                }
            }
        }
        printf("%d %d\n",hit,blow);
    }
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(m<a[i])
		{
			cout<<i;
			return 0;
		}
		m-=a[i];
	}
	if(!m)
	cout<<n;
	else
	cout<<n-1;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{
  int p, l, r;
}Node;

Node t[MAX];

int n;

void pre(int u){
  if(u==NIL)return;

  printf(" %d", u);

  pre(t[u].l);
  pre(t[u].r);
}

void in(int u){
  if(u==NIL)return;

  in(t[u].l);

  printf(" %d", u);

  in(t[u].r);
}

void post(int u){
  if(u==NIL) return;

  post(t[u].l);
  post(t[u].r);

  printf(" %d",u);
}

int main(){
  int i, v, l, r, root;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    t[i].p = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d", &v, &l, &r);
    t[v].l = l;
    t[v].r = r;

    if(l != NIL)
      t[l].p = v;
    if(r != NIL)
      t[r].p = v;
  }

  for(i=0;i<n;i++){
    if(t[i].p==NIL)
      root = i;
  }

  printf("Preorder\n");

  pre(root);

  printf("\n");

  printf("Inorder\n");

  in(root);

  printf("\n");

  printf("Postorder\n");

  post(root);

  printf("\n");

  return 0;
}

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

using namespace std;
#define ll long long
const int K = 1e5 + 1, mod = 1e9 + 7;
int dp[2][K];
void add(int &a, int b) {
  if ((a += b) >= mod) a -= mod;
}
int get(bool ind, int r, int l) {
  if (l <= 0) return dp[ind][r];
  return (dp[ind][r] - dp[ind][l - 1] + mod) % mod;
}
int a[501];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  //cout << "\x1B[34m";
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i <= k; i++) dp[n & 1][i] = 1;
  for (int i = n - 1; i >= 0; i--) {
    bool f = i & 1;
    for (int j = 0; j <= k; j++) {
      int &ret = dp[f][j];
      ret = get(!f, j, j - a[i]);
      if (j) add(ret, dp[f][j - 1]);
    }
  }
  cout << get(0, k, k) << endl;
  return 0;
}


Measured memory_bytes: 1024
<?php
  fscanf(STDIN, "%d", $n);
$cnt=0;
$ans="No";
for($i=0;$i<$n;++$i){
  fscanf(STDIN, "%d %d", $d1, $d2);
  if($d1==$d2){
  $cnt=++$cnt;
  }else{
  $cnt=0;}
  if($cnt>=3){
  $ans="Yes";
  break;}
}
echo $ans;


Measured memory_bytes: 16232
#include<stdio.h>
int main()
{
	int X[100],k=0,a,N,j=0,i,s,ts=0;
	float p,q;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%d",&X[i]);
		k=k+X[i];
	}
	a=k/N;
	p=k%N;
	q=p/N;
	if(q>0.5)
	j=a+1;
	else
	j=a;
	for(i=0;i<N;i++)
	{
		s=(X[i]-j)*(X[i]-j);
		ts=ts+s;
	}
	printf("%d\n",ts);
}

Measured memory_bytes: 128
N=int(input())
a=[-1]+[int(i) for i in input().split()]
b=[0 for i in range(N+1)]
for i in range(1,N+1)[::-1]:
    tmp=0
    for j in range(2*i,N+1,i):
        tmp+=b[j]
    if tmp%2!=a[i]:
        b[i]=1
ans=[]
for i in range(N+1):
    if b[i]==1:
        ans.append(str(i))
print(len(ans))
print(" ".join(ans))

Measured memory_bytes: 72376
import sys

step = input()
count = 0
judge = False

for char in step:
    count = count + 1
    if count % 2 == 1:
        if char == "R" or char == "U" or char =="D":
            judge = True
        else:
            print("No")
            sys.exit()
    elif count % 2 == 0:
        if char == "L" or char == "U" or char == "D":
            judge = True
        else:
            print("No")
            sys.exit()

if judge:
    print("Yes")

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

using namespace std;

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; }

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

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

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

	long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		long long left = min(a[i], b[i]);
		a[i] -= left;
		b[i] -= left;
		ans += left;

		long long right = min(b[i], a[i + 1]);
		b[i] -= right;
		a[i + 1] -= right;
		ans += right;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int MAXN=110;
int n,a[MAXN];
void output(int a[],int n){
	int i;
	for(i=0;i<n;i++){
		if(i>0) printf(" ");
		printf("%d",a[i]);
	}
	printf("\n");
}
int main() {
	scanf("%d",&n);
	for(int i=0; i<n; i++) {
		scanf("%d",&a[i]);
	}
	int v,j,i;
	output(a,n);
	for(i=1; i<n; i++) {
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v) {
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		output(a,n);
	}
}

Measured memory_bytes: 3172
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD = 1000000007
#define INF (1e9)
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll N, i;
    cin >> N >> i;
    print(N-i+1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n,a[100005],flag=0;
int main(int argc, char *argv[])
{
	int s1=0,s2=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%4==0)s1++;
		if(a[i]%4!=0&&a[i]%2==0)s2++;
	}
	if(n/2<=s1||(s1*2+s2)>=n)cout <<"Yes"<<endl;
	else cout <<"No"<<endl;
	
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    ll n, k;
    cin >> n >> k;
    
    int h[100000];
    int ans = 0;
    for(int i=0; i<n; i++){
        cin >> h[i];
        if (h[i] >= k) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  string s;
  cin>>s;
  bool a = false;
  for(int i=0;i<s.length()-1;i++)if(s[i]==s[i+1]){a=true;}
  a?cout<<"Bad"<<endl:cout<<"Good"<<endl;
}








Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
#define NIL -1
#define MAXN 1000
struct Node{
	int p, lchild, rchild;
};

Node T[MAXN];
int n, D[MAXN], H[MAXN];

void setDepth(int u, int d){
	if (u == NIL) {
		return;
	}
	D[u] = d;
	setDepth(T[u].lchild, d+1);
	setDepth(T[u].rchild, d+1);
}

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if (T[u].lchild != NIL) {
		h1 = setHeight(T[u].lchild) + 1;
	}
	if (T[u].rchild != NIL) {
		h2 = setHeight(T[u].rchild) + 1;
	}
	return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
	if (T[u].p == NIL) {
		return NIL;
	}
	if (T[T[u].p].lchild != u && T[T[u].p].lchild != NIL) {
		return T[T[u].p].lchild;
	}
	if (T[T[u].p].rchild != u && T[T[u].p].rchild != NIL) {
		return T[T[u].p].rchild;
	}
	return NIL;
}

void print(int u){
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].p);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if (T[u].lchild != NIL) {
		deg++;
	}
	if (T[u].rchild != NIL) {
		deg++;
	}
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);
	
	if (T[u].p == NIL) {
		printf("root\n");
	}else if (T[u].lchild == NIL && T[u].rchild == NIL) {
		printf("leaf\n");
	}else {
		printf("internal node\n");
	}
}

int main(int argc, char *argv[]) {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		T[i].p = NIL;
	}
	
	for (int i = 0; i < n; i++) {
		int v, l, r;
		scanf("%d %d %d", &v, &l, &r);
		T[v].lchild = l;
		T[v].rchild = r;
		if (l != NIL) {
			T[l].p = v;
		}
		if (r != NIL) {
			T[r].p = v;
		}
	}
	int root = 0;
	for (int i = 0; i < n; i++) {
		if (T[i].p == NIL) {
			root = i;
		}
	}
	setDepth(root, 0);
	setHeight(root);
	for (int i = 0; i < n; i++) {
		print(i);
	}
	return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N,K;
	vector<llong> l;

	cin >> N >> K;
	l.resize(N);
	for(int i = 0; i < N; i++)
		cin >> l[i];
	sort(BE(l), greater<llong>());

	llong ans = 0;
	for(int i = 0; i < K; i++)
		ans += l[i];
	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = new String[2];
		strArray = br.readLine().split(" ");
		int A = Integer.parseInt(strArray[0]) - 1;
		int B = Integer.parseInt(strArray[1]) - 1;

		int result = (A + B - 1) / A;

		System.out.println(result);

	}

}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const ll inf=1e9+7;
using namespace std;
int main() 
{
	int a,b;
	cin>>a>>b;
	int ans=a*b;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

struct edge{int to,cost;};
vector<int> G[100005];
 
long long int n,m,k,i,j=1;
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1,};

std::vector<P> tree[100010];
long long int d[100005];
bool flag=false;
char s[105];
int a[4]={0,0,0,0};

int main(){
	cin>>n;
	for(i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=='G')a[0]++;
		if(s[i]=='W')a[1]++;
		if(s[i]=='Y')a[2]++;
		if(s[i]=='P')a[3]++;
	}
	int b=0;
	for(i=0;i<4;i++){
		if(a[i]>=1)b++;
	}
	if(b==3)cout<<"Three";
	else cout<<"Four";
	cout<<endl;
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(){
    int n,k,count;
    scanf("%d%d",&n,&k);
    count=0;
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(k<=a[i]){

        count++;
        }
    
    }

    
    printf("%d",count);
    


    return 0;
}

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

using namespace std;

class Solution {
 private:
  int c(int n) {
    if (n < 2) return 0;
    return n * (n - 1) / 2;
  }

 public:
  int payment(int n) {
    int rest = n % 1000;
    if (rest == 0)
      return 0;
    else
      return 1000 - rest;
  }
};

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

  Solution sol;
  const int ans = sol.payment(n);
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N,r;
  string s;
  cin >> N;
  cin >> s;
  for(int i=0; i<N; i++){
   if(s[i] == 'B'){
     r--;
   }
    else{
      r++;
    }
  }
  if(r>0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int u[2000][2000] = {0}, d[2000][2000] = {0}, r[2000][2000] = {0}, l[2000][2000] = {0};

int main() {
    int h, w; cin >> h >> w;
    char s[2000][2000];

    for (int i = 0; i < h; i++) {
        for (int k = 0; k < w; k++) {
            cin >> s[i][k];
            if (s[i][k] == '#') {
                u[i][k] = 0; l[i][k] = 0;
            } else {
                if (i == 0) u[i][k] = 1;
                else u[i][k] = 1 + u[i - 1][k]; 
                if (k == 0) l[i][k] = 1;
                else l[i][k] = 1 + l[i][k - 1]; 
            }
        }
    }

    for (int i = h - 1; i >= 0; i--) {
        for (int k = w - 1; k >= 0; k--) {
            if (s[i][k] == '#') {
                d[i][k] = 0; r[i][k] = 0;
            } else {
                if (i == h - 1) d[i][k] = 1;
                else d[i][k] = 1 + d[i + 1][k]; 
                if (k == w - 1) r[i][k] = 1;
                else r[i][k] = 1 + r[i][k + 1]; 
            }
        }
    }

    int ans = 0;
    REP(i, h) {
        REP(k, w) {
            ans = max(u[i][k] + d[i][k] + r[i][k] + l[i][k] - 3, ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 66688
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  string s;
  while(cin >> s){
    int n = s.size();
    int c = 15-n;

    c += count(ALL(s), 'o');

    cout << (c>=8 ? "YES" : "NO") << endl;
  }
  
  return 0;
}


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


int main()
{
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(3));
  rep(i, n)
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  vector<vector<int>> dp(n, vector<int>(3));
  rep(i, 3)
    dp[0][i] = a[0][i];
  for (int i=1; i<n; i++)
  {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i][0];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + a[i][1];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + a[i][2];
  }
  cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
  return 0;
}

Measured memory_bytes: 11136
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int i,j,k,x,y,n,m,flag,s;
    scanf("%d%d",&n,&m);
    flag=0;
    s=100000;
    for(i=1;i<=n;i++)
    {
        scanf("%d%d",&x,&y);
        if(y<=m&&x<s)
        {
            s=x;
            flag=1;
        }
    }
    if(flag==0)
    {
        printf("TLE\n");
        return 0;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================
/*
vi g[N];
int a[N];

int main() {
    ios_base::sync_with_stdio(0);
    int t, i, j, k, p, q, r, x, y, u, v, n, m;

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

*/
int main()
{
	int n;
	cin>>n;
	int t = n%10;
	if(t==2||t==4||t==5||t==7||t==9)
	{
		cout<<"hon"<<endl;
	}
	if(t==0||t==1||t==6||t==8)
	{
		cout<<"pon"<<endl;
	}
	if(t==3)
	{
		cout<<"bon"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

#define rep(i,n) for(int i = 0; i < (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 30; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline void maxch(int& a, int b) { if (a < b) a = b; }

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

	ll ans = 0;
	vector<vector<ll>> a(n,vector<ll>(n));
	vector<vector<ll>> b(n, vector<ll>(n));
	rep(i,n) rep(j,n)  { cin >> a[i][j]; b[i][j] = a[i][j]; ans += a[i][j]; }

	vector<vector<bool>> done(n, vector<bool>(n,false));

	ans /= 2;

	rep(k, n) rep(i, n) rep(j, n) {
		if(b[i][j] > b[i][k] + b[k][j]) b[i][j] = b[i][k] + b[k][j];
	}

  rep(i, n) rep(j, n) rep(k, n) {
	  if (i == j || j == k || i == k) continue;
		if (a[i][j] > b[i][j]) { 
			cout << -1 << endl; 
			return 0;
		}
		else if (a[i][j] == b[i][k] + b[k][j] && !done[i][j] && !done[j][i]) {
			ans -= a[i][j];
			done[i][j] = true;
			done[j][i] = true;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n;
    long[] as;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        as = new long[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextLong();
        }
        solve();
    }

    void solve() {
        long[] ss = new long[n];
        ss[0] = as[0];
        for (int i = 1; i < n; i++) {
            ss[i] = ss[i - 1] + as[i];
        }
        long min = Long.MAX_VALUE;
        for (int i = 0; i < n - 1; i++) {
            long snuke = ss[i];
            long raccoon = ss[n - 1] - ss[i];
            long diff = Math.abs(snuke - raccoon);
            if (diff < min) {
                min = diff;
            }
        }
        System.out.println(min);
    }

    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 (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 (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> dp(n + 1, 1e9);
    dp[0] = 0;
    for(int i = 0; i <= n; i++){
        for(int p6 = 1; p6 + i <= n; p6 *= 6){
            dp[i + p6] = min(dp[i + p6], dp[i] + 1);
        }
        for(int p9 = 1; p9 + i <= n; p9 *= 9){
            dp[i + p9] = min(dp[i + p9], dp[i] + 1);
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n) :fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

mint ans = 0;

int main() {
	ll n, k;
	cin >> n >> k;
    combination c(n);
    rep(i, min(n, k + 1))ans += c(n, i) * c(n - 1, i);
    cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#define MAX 100

int m[MAX][MAX],M[MAX],n;

int min(int x,int y)
{
    if( x <= y ) return x;
    else return y;
}

void MatrixChain(){
    int i,j,k,l,q;
    for( i = 1 ; i <= n ; i++ ) {
        m[i][i] = 0;
    }
    for( l = 2 ; l <= n ; l++ ){
        for( i = 1 ; i <= n-l+1 ; i++ ){
            j = i + l - 1;
            m[i][j] = 100000000;
            for( k = i ; k <= j-1 ; k++ ){
                q = m[i][k] + m[k+1][j] + M[i-1]*M[k]*M[j];
                m[i][j] = min(m[i][j],q);
            }
        }
    }
    
}

int main(){
    int i;
    scanf("%d",&n);
    
    for( i = 1  ; i <= n ; i++ ){
        scanf("%d%d",&M[i-1],&M[i]);
    }    
    
    MatrixChain();
    
    printf("%d\n",m[1][n]);
    
    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
 
typedef long long  ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
    string s;
    string t;
    cin>>s>>t;
    for(int i=s.size()-t.size();i>=0;i--){
        int flag=0;
        //cout<<u<<endl;
        for(int j=0;j<t.size();j++){
           
            if(s[i+j]==t[j] || s[i+j]=='?') continue;
            else {
            flag=1;
            break;
            }
        }
        if(!flag) {
            //cout<<s<<endl;
            for(int k=0;k<t.size();k++) s[i+k]=t[k];
            for(int i=0;i<s.size();i++){
                if(s[i]=='?')s[i]='a';
            }
            cout<<s<<endl;
            return 0;
        }
    }
            cout<<"UNRESTORABLE"<<endl;
            return 0;
        
    }
   
    
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef vector<int> VI;

pii vol[4];

bool cmp(pii a, pii b){
	return 1ll * a.fi * b.se < 1ll * b.fi * a.se;// < (double)b.fi / b.se;
}

int main(){
	LL a, b, c, d, n;
	cin >> a >> b >> c >> d >> n;
	LL t = min(4 * a, min(2 * b, c));
	LL ans = 0;
	if (d < t * 2){
		ans = n / 2 * d;
		if (n & 1) ans += t;
	} else ans = n * t;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256