akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+7;
const ll mod = 1e9+7;
int n,m,k;
int ar[maxn];

int main()
{
    cin>>n>>m;
    m = m*2+1;
    printf("%d\n", (n+m-1)/m);


    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int x,n;
    scanf("%d %d", &x, &n);
    if(n == 0){
        printf("%d", x);
    } else {
        int aP[n];
        for(int i = 0; i < n; i++){
            scanf("%d", &aP[i]);
        }
        bool bExist = false;
        for(int i = 0; i < n; i++){
            if(x == aP[i]){
                bExist = true;
            }
        }
        if(!bExist){
            printf("%d", x);
        } else {
            for(int i = 1; i < n + 1; i++){
                bExist = false;
                for(int j = 0; j < n; j++){
                    if(x - i == aP[j]){
                        bExist = true;
                    }
                }
                if(!bExist){
                    printf("%d", x - i);
                    break;
                }
                bExist = false;
                for(int j = 0; j < n; j++){
                    if(x + i == aP[j]){
                        bExist = true;
                    }
                }
                if(!bExist){
                    printf("%d", x + i);
                    break;
                }
            }
        }
  
    }
    return 0;
}


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

int main(){
    int cnt = 0, sum = 0;
    int n, k; cin >> n >> k;
    vector<int> a;
    map<int,int> mp;

    rep(i,n){
        int tmp; cin >> tmp;
        mp[tmp]++;
        sum++;
    }

    for(auto x:mp){
        a.push_back(x.second);
    }

    sort(a.begin(),a.end());
    
    for(int i = 0; i < n; i++){
        if(a.size()-i <= k){
            put(cnt);
            return 0;
        }

        cnt += a[i];
        sum -= a[i];
    }
}

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

int main(){
	int y,m,d;
	scanf("%d/%d/%d", &y, &m, &d);
	if(y<=2018 || (y==2019 && m<=4)){
		cout << "Heisei" << endl;
	}else{
		cout << "TBD" << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
  string S;
  cin >> S;
  if(S[0] == S[1] && S[1] == S[2]) {
    cout << "Yes" << endl;
  } else if(S[1] == S[2] && S[2] == S[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
//by Top1
#include <bits/stdc++.h>
     
#define f first
#define s second
#define int long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define pll pair <long, long>
#define mp make_pair
#define pb push_back
#define pf push_front
#define pp pop_back
#define rev reverse
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define forn(i, a, b) for (int i = a; i <= b; i++)
#define boost ios_base::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define nxtp next_permutation
#define pvtp prev_permutation
#define KZ return 
#define x1 x21212121
#define y1 y21212121
#define sqr(x) x * x 
 
const int inf = INT_MAX;
const int mod = 1e9 + 7;
const int maxn = 6e5 + 111;
     
using namespace std;

int q, n, w, a[maxn], b[maxn], dp[maxn][200], ans;

void solve(){    
	cin >> n >> w;

	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];


	for (int i = 1; i <= n; i++){
		for (int j = w; j > 0; j--){
			dp[i][j] = dp[i - 1][j];
			if (j - a[i] >= 0)
				dp[i][j] = max(dp[i][j], dp[i - 1][j - a[i]] + b[i]);
			ans = max(ans, dp[i][j]);
		}	
	}

	/*for (int i = 0; i <= w; i++)
		cout << dp[i] << " ";
	*/
	cout << ans;
}

main(){
    boost;
	    
	q = 1;

	while (q--){
		solve();
	}
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,b[114154];
int main() {
	cin>>n;
	ll ans=0;
	for(int i=0;i<n-1;i++){
		cin>>b[i];
	}
	b[n]=1e9;
	ans+=b[0]+b[n-2];
	for(int i=1;i<n-1;i++){
		ans+=min(b[i-1],b[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - 4-adjacent
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	var a int
	ans := make([]int, 5)
	for i := 0; i < N; i++ {
		a = nextInt()
		if a%2 == 0 && (a/2)%2 != 0 {
			ans[2]++
		} else if a%2 == 0 && (a/2)%2 == 0 {
			ans[4]++
		} else {
			ans[0]++
		}
	}

	if (ans[4]+1 >= ans[0] && ans[2] == 0) || (ans[4] >= ans[0] && ans[2] != 0) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
int main(){
	int m1,d1;int m2,d2;
	cin>>m1>>d1>>m2>>d2;
	if(m2==1 && m1==12){cout<<1<<endl;return 0;}
	
	if(m2-m1==1)cout<<1<<endl;
	else cout<<0<<endl;
	
	return 0;
}

Measured memory_bytes: 256
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int mod;
int Arr[100005];
void seive(){
		Arr[0]=Arr[1]=1;
		for(int i=2;i<100005;++i){
			if(Arr[i]==0)
			for(int j=2*i;j<100005;j+=i)
			Arr[j]=1;
		}
}

bool isprime(int a){
	if(a==2)
	return true;
	if(a%2==0)
	return false;
	for(int i=3;i*i<=a;i+=2)
	if(a%i==0)
	return false;
	return true;
}

void merge(int arr[],int brr[], int l, int m, int r) 
			{ 
			  int i, j, k; 
			  int n1 = m - l + 1; 
			  int n2 = r - m; 
			  int L[n1], R[n2]; 
			  int l1[n1] ,r1[n2];
			  for (i = 0; i < n1; i++) 
				{L[i] = arr[l + i];l1[i]=brr[l+i];} 
			  for (j = 0; j < n2; j++) 
				{R[j] = arr[m + 1+ j];r1[j]=brr[m+1+j];} 
			  i = 0;  
			  j = 0; 
			  k = l;  
			  while (i < n1 && j < n2) 
			  { 
				if (L[i] <= R[j]) 
				{ 
				  arr[k] = L[i];
				  brr[k]=l1[i]; 
				  i++; 
				} 
				else
				{ 
				  arr[k] = R[j];
				  brr[k]=r1[j]; 
				  j++; 
				} 
				k++; 
			  } 
			  while (i < n1) 
			  { 
				arr[k] = L[i]; 
				brr[k]=l1[i];
				i++; 
				k++; 
			  } 
			  while (j < n2) 
			  { 
				arr[k] = R[j];
				brr[k]=r1[j]; 
				j++; 
				k++; 
			  } 
			} 
			void mergeSort(int arr[],int brr[], int l, int r) 
			{ 
			  if (l < r) 
			  { 
				int m = l+(r-l)/2; 
				mergeSort(arr,brr, l, m); 
				mergeSort(arr,brr, m+1, r); 
				merge(arr,brr, l, m, r); 
			  } 
			}
			
// -----------------------------------------------------------------------



int fre[26];

void stt(){
	char c;
	cin>>c;
	c++;
	cout<<c;
	
}
void spp(){
	int n,k;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;++i)
	cin>>arr[i];
	sort(arr,arr+n);
	bool choose[n];
	for(int i=0;i<n;++i)
	choose[i]=false;
	int ret=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n;++j){
			if(arr[j]>arr[i] && !choose[j]){
				ret++;
				choose[j]=true;
				break;
			}
		}
	}
	cout<<ret;
}

void solve(){	
	int n; cin>>n;
	int k; cin>>k;
	string s; cin>>s;
	for(int i=0;i<sz(s);++i)
	fre[s[i]-'A']++;
	sort(fre,fre+26);	
	int ans=0;
	for(int i=25;i>=0;--i){
		if(k>=fre[i]){
			ans+=fre[i]*fre[i];
			k-=fre[i];	
		}
		else{
			ans+=k*k;
			k=0;
			break;
		}
	}
	cout<<ans;
}

// -----------------------------------------------------------------------


int32_t main()
{
	mod=1e+7;
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	stt();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
 
int main() {
	vector<pair<int, int>> v;
	vector<pair<int, int>> c;
	int n, m;
	cin>>n>>m;
	while(n--){
		int x,y;
		cin>>x>>y;
		v.emplace_back(x,y);
	}
	
	while(m--){
		int x,y;
		cin>>x>>y;
		c.emplace_back(x,y);
	}
	
	for(auto& u:v){
		int min=1000000000;
		int count=0,t;
		for(auto& p:c){
			count++;
			int x=abs(u.first-p.first)+abs(u.second-p.second);
			if(x<min){
				min=x;
				t=count;
			}
		}
		cout<<t<<endl;
	}
	
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(int, char**) {
    int X,A;
    scanf("%d %d", &X, &A);
    if(X < A){
        std::cout << 0;
    }else{
        std::cout << 10;
    }
    
    

}


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

const long long charbase = '0';
struct RollingHash {
  long long Mod[2], Base[2];
  long long ssize, maxssize;
  string s;
  vector<long long> pow[2];
  vector<long long> hash[2];
  RollingHash(string inis = "") {
    Mod[0] = 1000000007;
    Mod[1] = 1000000009;
    Base[0] = 1009;
    Base[1] = 1007;
    maxssize = inis.size() + 10;
    for(int t = 0; t < 2; ++t) {
      pow[t].assign(maxssize, 0);
      pow[t][0] = 1;
      for(int i = 1; i < maxssize; ++i)
        pow[t][i] = pow[t][i - 1] * Base[t] % Mod[t];
    }
    init(inis);
  }
  void init(string inis = "") {
    s = inis;
    ssize = s.size();
    sethash();
  }
  void sethash() {
    ssize = s.size();
    for(int t = 0; t < 2; ++t) {
      hash[t].assign(ssize + 1, 0);
      for(int i = 0; i < ssize; ++i) {
        if(i != 0)
          hash[t][i + 1] = hash[t][i] * Base[t] % Mod[t];
        hash[t][i + 1] += (s[i] - charbase);
        hash[t][i + 1] %= Mod[t];
      }
    }
  }
  // [l,r),0-indexed
  pair<long long, long long> calchash(int l, int r) {
    long long ans[2];
    for(int t = 0; t < 2; ++t) {
      ans[t] = hash[t][r];
      ans[t] -= hash[t][l] * pow[t][r - l] % Mod[t];
      while(ans[t] < 0) ans[t] += Mod[t];
      ans[t] %= Mod[t];
    }
    return make_pair(ans[0], ans[1]);
  }
};

string s, t, ns;
RollingHash rh[2];
bool memo[500005] = {0};
long long used[500005] = {0};
long long tsize, ssize;

long long solve();

int main() {
  cin >> s >> t;
  tsize = t.size();
  ssize = s.size();
  ns = s + s;
  while((long long)ns.size() <
        (long long)2 * (long long)max(t.size(), s.size()))
    ns += s;
  rh[0] = RollingHash(ns);
  rh[1] = RollingHash(t);
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(int i = 0; i < ssize; ++i)
    memo[i] = rh[0].calchash(i, i + tsize) ==
              rh[1].calchash(0, tsize);
  for(int i = 0; i < ssize; ++i) used[i] = -(memo[i]);
  for(int i = 0; i < ssize; ++i)
    if(used[i] == -1) {
      long long cnt = 0, now = i;
      stack<long long> st;
      while(used[now] == -1) {
        st.push(now);
        used[now] = -2;
        if(memo[now])
          now = (now + tsize) % ssize;
        else
          break;
      }
      if(used[now] == -2) return -1;
      cnt = used[now];
      while(st.size() > 0) {
        used[st.top()] = max(used[st.top()], ++cnt);
        cnt = used[st.top()];
        st.pop();
      }
      ans = max(ans, cnt);
    }
  return ans;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    int x,y;
    cin>>x>>y;
    cout<<x+y/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);
ll cache[100005][3];
ll A[100005], B[100005], C[100005], n;
ll solve(ll i, ll lst){
    if(lst==-1){
        return max(A[i] + solve(i+1,1), max(B[i] + solve(i+1,2), C[i] + solve(i+1,3)));
    }
    if(cache[i][lst]>0){
        return cache[i][lst];
    }
    ll ans;
    if(i>n){
        return 0;
    }
    if(lst==1){
        ans = max(B[i]+solve(i+1,2),C[i]+solve(i+1,3));
    }
    else if(lst==2){
        ans = max(A[i]+solve(i+1,1),C[i]+solve(i+1,3));
    }
    else{
        ans = max(B[i]+solve(i+1,2),A[i]+solve(i+1,1));
    }
    cache[i][lst] = ans;
    return ans;
}
int main(){
    init(cache,-1);
    cin>>n;
    ll ans = 0;
    loop(i,0,n){
        cin>>A[i]>>B[i]>>C[i];
    }
    ans = solve(0,-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9600
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll x;
	cin >> x;

	while(true){
		bool flg = true;
		REP(i, 2, x){
			if(i*i > x) break;
			if(x%i == 0){
				flg = false;
				break;
			}
		}
		if(flg){
			co(x);
			break;
		}
		x++;
	}

	return 0;
}


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

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

   if(n%2==1){
      cout<< 0 <<endl;
   }
   else{
      ll cnt=0;
      for(ll k=5; k<=n; k*=5){
         ll k2=k*2;
         cnt+= n/k2;
      }
      cout<<cnt<<endl;
   }
   return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=3010,Mod=998244353;
int n,S,a[N],f[N];
int main()
{
	n=gi();S=gi();
	for(int i=1;i<=n;i++)a[i]=gi();
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=S;j>a[i];j--)
		{
			f[j]=(f[j]+f[j-a[i]])%Mod;
		}
		f[a[i]]=(f[a[i]]+i)%Mod;
		ans=(ans+1ll*f[S]*(n-i+1)%Mod)%Mod;
		f[S]=0;
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
vector<int>A(5);
int sum=0, k=0, x;
  for(int i=0; i<5; i++){
   cin>>A[i];
    x=(A[i]+9)/10*10;  // +9はA[i]%10==0の場合の対応
    sum+=x;  // 調理時間xの合計
   if(x-A[i]>k){k=x-A[i];} // 調理時間xと実際の調理時間A[i]の時間差の最大値
  }

 cout<<sum-k; // sumから最大の時間差kを引く
}

Measured memory_bytes: 256
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-10-30 08:36:15
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int K;

int main()
{
  cin >> K;
  int odd = 0;
  int even = 0;
  for (auto i = 1; i <= K; i++)
  {
    if (i % 2 == 0)
    {
      even++;
    }
    else
    {
      odd++;
    }
  }
  cout << even * odd << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
 
using namespace std;

int min( int p, int q ){
	if( p < q ) return p;
	return q;
}

int main(void){

	int N;
	cin >> N;
	
	vector< vector< int > > C( N, vector< int >( N, 0 ) );

	for( int i = 0; i < N; i++ )
		for( int j = 0; j < N; j++ )
			cin >> C[i][j];
	
	unsigned long long int ans = 0;
	for( int i = 0; i < N; i++ )
		for( int j = 0; j < i; j++ ) 
			ans += min( C[i][j], C[j][i] );
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1248
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n;
    cin >> n;
    vector<int> c(n - 1), s(n - 1), f(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> c[i] >> s[i] >> f[i];
    }

    for (int i = 0; i < n; i++) {
        int t = 0;

        for (int j = i; j < n - 1; j++) {
            if (t <= s[j]) {
                t = s[j];
            } else {
                if (t % f[j] != 0) {
                    t += f[j] - (t % f[j]);
                }
            }

            t += c[j];
        }

        cout << t << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
using ll = long long;

int main() {
    int N,M,C;
    cin >> N >> M >> C;
    vector<int>B(M);
    for (int i = 0; i < M; ++i) {
      cin >> B[i];
    }
    int A[N][M];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            cin >> A[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int sum = C;
        for (int j = 0; j < M; ++j) {
            sum += A[i][j]*B[j];
        }
        if(sum > 0) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
l=[[1]*(w+2)]+[[1]+[1 if i=="#" else 0 for i in input()]+[1] for i in range(h)]+[[1]*(w+2)]
c=[[0]*(w+2) for i in range(h+2)]
q=[(1,1)]
e=[(0,1),(0,-1),(1,0),(-1,0)]
kyori=1
while len(q)>0 and c[h][w]==0:
    tl=q
    q=[]
    for x,y in tl:
        for X,Y in e:
            if(l[y+Y][x+X]==0 and c[y+Y][x+X]==0):
                q.append((x+X,y+Y))
                c[y+Y][x+X]=1
    kyori+=1
if  c[h][w]==0:
    print(-1)
else:
    print(sum([i.count(0) for i in l])-kyori)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
using namespace std;
int n;
string s;
int main()
{
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++)
	{
		s[i] += n;
		if (s[i] > 'Z')
			s[i] = s[i] - ('Z' - 'A')-1;
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    int a,b,c,x,y;
    unsigned ans = 0;
    scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);
    c*=2;
    if(a+b<=c)ans = a*x+b*y;
    else{
        ans += c*(x<y?x:y);
        if((x<y?b:a) > c)ans += c*(x<y?y-x:x-y);
        else ans += (x<y?b:a)*(x<y?y-x:x-y);
    }     
    printf("%u",ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int S, A, B;
bool ymflag, myflag;
int main(){
  cin >> S;
  A = S/100;
  B = S - A * 100;
  if (B<=12 && B>=1){
    ymflag = true;
  }
  else ymflag = false;
  if (A<=12 && A>=1){
    myflag = true;
  }
  else myflag = false;
  if (ymflag && myflag){
    cout << "AMBIGUOUS" << endl;
  }
  else if (ymflag && !myflag){
    cout << "YYMM" << endl;
  }
  else if (!ymflag && myflag){
    cout << "MMYY" << endl;
  }
  else {
    cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = input()
D = map(int, raw_input().split())
if D[0]!=0 or N==1 or min(D[1:])==0:
  print 0
  exit(0)

D = D[1:]
D.sort()
C = [0]*N
C[0] = 1
ans = 1
for d in D:
  ans *= C[d-1]
  ans %= 998244353
  C[d] += 1
print ans


Measured memory_bytes: 11208
#include <stdio.h>

#define N 50

int issorted(int *aa, int n) {
	int i;

	for (i = 0; i < n - 1; i++)
		if (aa[i] > aa[i + 1])
			return 0;
	return 1;
}

int main() {
	static int pp[N];
	int n, i, j;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &pp[i]);
	if (issorted(pp, n)) {
		printf("YES\n");
		return 0;
	}
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++) {
			int tmp;

			tmp = pp[i];
			pp[i] = pp[j];
			pp[j] = tmp;
			if (issorted(pp, n)) {
				printf("YES\n");
				return 0;
			}
			tmp = pp[i];
			pp[i] = pp[j];
			pp[j] = tmp;
		}
	printf("NO\n");
	return 0;
}


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

using namespace std;

#define int		long long

void solve()
{
	int n,ans=0,sum=0;
	cin >>n;
	std::vector<int> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i =0;i<n;i++){
		ans += a[i] * sum % 1000000007;
		sum += a[i];
		sum %= 1000000007;
		ans %= 1000000007;
	}
	cout << ans << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	//int t;cin >> t ;while(t--)
	 	solve();
}

Measured memory_bytes: 4820
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

/*
vector<int> gen(int n, const vector<int> & p) {
  vector <int> it(n, 0);
  vector<int> res;
  res.reserve(3 * n);
  for (int i = 0; i < 3 * n; ++i) {
    int best = -1, next = -1;
    for (int j = 0; j < n; ++j) {
      if (it[j] == 3) { continue; }
      int cur = p[3 * j + it[j]];
      if (best == -1 || cur < next) {
        best = j;
        next = cur;
      }
    }
    res.push_back(next);
    it[best]++;
  }
  return res;
}

bool good(int n, const vector<int> &p) {
  for (int i = 0; i < p.size(); ++i) {
    int j = 0;
    while (i + j + 1 < int(p.size()) && p[i] > p[i + j + 1]) {
      ++j;
    }
    if (j >= 3) return false;
  }
  {
    int cnt = 0;
    for (int i = 1; i < int(p.size()); ++i) {
      if (p[i - 1] > p[i]) {
        cnt++;
        i++;
      }
    }
    if (cnt > n) return false;
  }
  return true;
  for (int i = 3; i < p.size(); ++i) {
    if (p[i - 3] > p[i - 2] && p[i - 2] > p[i - 1] && p[i - 1] > p[i]) {
      return false;
    }
  }
  int cnt = 0;
  for (int i = 1; i < p.size(); ++i) {
    if (p[i - 1] > p[i]) {
      cnt++;
    }
  }
  return (cnt <= 2 * n);
}

void brute(int n) {
  vector <int> p(3 * n);
  for (int i = 0; i < 3 * n; ++i) {
    p[i] = i;
  }
  set<vector<int>> perms;
  set<vector<int>> perms2;
  do {
    perms.insert(gen(n, p));
    if (good(n, p)) {
      perms2.insert(p);
    }
  } while (next_permutation(p.begin(), p.end()));

  printf("%d\n", int(perms.size()));
  printf("%d\n", int(perms2.size()));
  for (const auto & p : perms2) {
    if(perms.count(p) == 0) {
      break;
      for (int x : p) {
        dbg("%d ", x);
      }
      dbg("\n");
    }
    assert(good(n, p));
  }
}*/

int MOD;

int &add(int &a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
  return a;
}

int prod(int a, int b) {
  return ll(a) * b % MOD;
}

bool solve() {
  int n;
  if (scanf("%d%d", &n, &MOD) != 2) { return false; }
  //brute(n);
  vector<vector<int>> dp(3 * n + 1, vector<int>(n + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= 3 * n; ++i) {
    for (int j = 0; j <= n; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (i > 1 && j > 0) {
        add(dp[i][j], prod(i - 1, dp[i - 2][j - 1]));
      }
      if (i > 2 && j > 0) {
        add(dp[i][j], prod(prod(i - 1, i - 2), dp[i - 3][j - 1]));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    add(ans, dp[3 * n][i]);
  }
  printf("%d\n", ans);
  return true;
}

int main() {
  int tt = -1;
  //scanf("%d", &tt);
  while (tt-- && solve());
  return 0;
}


Measured memory_bytes: 47488
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int i,j,line,k,l,input1,input2,input3;
    scanf("%d",&line);
    for(l=1;l<=line;l++)
    {
        scanf("%d %d %d",&input1,&input2,&input3);
        if((input1*input1+input2*input2)==(input3*input3) || (input3*input3+input2*input2)==(input1*input1) || (input1*input1+input3*input3)==(input2*input2))
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N; cin >> N;
	int lb = 0, ub = N + 1;
	vector<int> ans;
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		int x = N;
		vector<int> unko;
		for (int i = mid; i >= 1; i--)
			if (i <= x) {
				x -= i;
				unko.pb(i);
			}
		if (x) lb = mid;
		else {
			ub = mid;
			ans = unko;
		}
	}
	for (int i: ans) cout << i << endl;
}


Measured memory_bytes: 764
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            total = i*500+j*100+k*50
            if total == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a <= 12) b /= 2;
	if(a <= 5) b = 0;
	cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        call(n);
        System.out.println();
        sc.close();
    }
    public static void call(int n) {
        for (int i = 1; i <= n; i++) {
            if(((i % 3) == 0) || ((i % 10) == 3)) {
                System.out.print(" " + i);
            } else {
                int x = i / 10;
                while (x != 0) {
                    if ((x % 10) == 3) {
                        System.out.print(" " + i);
                        break;
                    }
                    x /= 10;
                }
            }
        }
    }
}


Measured memory_bytes: 28860
object Main extends App {
  val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)
  val against = (for(_ <- 0 until m toList) yield
    io.StdIn.readLine().split(' ').map(_.toInt) match {
      case Array(a, b) => (a-1, b-1)
    }).sortWith{case (x, y) => x._2 < y._2}

  @scala.annotation.tailrec
  def solver(against: List[(Int, Int)], end: Int = 0, count: Int = 0): Int = against match {
    case Nil => count
    case p :: rest if end <= p._1 => solver(rest, p._2, count+1)
    case _ :: rest => solver(rest, end, count)
  }

  println(solver(against))
}

Measured memory_bytes: 78332
main = do
    dice <- getLine
    let (n1:n2:n3:n4:n5:n6:_) = map (\x -> read x :: Int) $ words dice
    qcount <- getLine
    oqs <- getContents
    let qs = map (map (\x -> read x :: Int)) $ map words $ lines oqs
    let ans = map (solve (n1,n2,n3,n4,n5,n6)) qs
    mapM_ putStrLn $ map show ans

type Dice = (Int, Int, Int, Int, Int, Int)



sides :: Dice -> Int -> [Int]
sides (n1,n2,n3,n4,n5,n6) top
  | top == n1 = [n2,n3,n5,n4,n2]
  | top == n2 = [n1,n4,n6,n3,n1]
  | top == n3 = [n1,n2,n6,n5,n1]
  | top == n4 = [n1,n5,n6,n2,n1]
  | top == n5 = [n1,n3,n6,n4,n1]
  | top == n6 = [n2,n4,n5,n3,n2]
  | otherwise = sides (n1,n2,n3,n4,n5,n6) n1 -- NOT EXPECTED CASE

solve :: Dice -> [Int] -> Int
solve dice (top:front:_) = getRight dice top front

getRight :: Dice -> Int -> Int -> Int
getRight dice top front = next (sides dice top) front

next (x:xs) y
  | x == y && length xs > 0 = head xs
  | length xs == 0          = y         -- NOT EXPECTED CASE
  | otherwise               = next xs y



Measured memory_bytes: 3980
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main() {
    string s;
    cin >> s;
    set<char> st{'A','G','C','T'};
    int ans = 0;
    int tmp = 0;
    rep(i, s.size()){
        if(find(all(st), s[i])!=st.end()){
            tmp++;
        }else{
            tmp =0;
        }
        chmax(ans, tmp);
    }

    cout << ans << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    int n;
    cin>>n;
    vl a(n);
    ll main = 0;
    rep(i,0,n)
        cin>>a[i],main ^= a[i];
    for(int i = 0;i<n;i++)
    {
        cout<<(main^a[i])<<" ";
    }
    return 0;
}

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n, k;
  cin >> n >> k;
  string ans;
  if(500*n>=k) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        long[][] f = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
        long[][] p = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
        long[] sister = new long[10];
        long ans = -10000000 * 100 - 1;
        for (int i = 1; i <= 1023; i++)
        {
            long tmp = 0;
            string binary = String.Format("{0:0000000000}", int.Parse(Convert.ToString(i, 2)));
            for(int j = 0; j < 10; j++)
            {
                    sister[j] = binary[j] - '0';
            }
            for(int j = 0; j < n; j++)
            {
                int cnt = 0;
                for(int k = 0; k < 10; k++)
                {
                    if(f[j][k] == 1 && sister[k] == 1) cnt++;
                }
                tmp += p[j][cnt];
            }
            ans = Math.Max(ans, tmp);
        }
        Console.WriteLine(ans);
    }
}

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

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

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());

  int ans= 0;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      for(int k=j+1; k<N; k++){
        if((data.at(i) != data.at(j) && data.at(j) != data.at(k)) && (data.at(i)+ data.at(j) > data.at(k))){
          ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(ll i=0; i<n; i++)
#define loopo(i,n) for(ll i=0; i<n; i++)
using namespace std;

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

int main(){
    fast;
    
    // int t=1;
    // while(t--)solve();
    
     int s,w;cin>>s>>w;
    
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

struct UnionFind
{
    vector<int> data;
    UnionFind() {}
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);

        if (x != y)
        {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }

    int size(int x)
    {
        return -data[root(x)];
    }
};

struct edge {
    int u, v, cost;
    edge(int u, int v, int cost) : u(u), v(v), cost(cost) {}
    bool operator<(const edge& rhs) const
    {
        return cost < rhs.cost;
    }
};

struct State {
  int x, y, num;
  State(int x, int y, int num) : x(x), y(y), num(num) {}
};

vector<edge> g;
int n;
vector<State> v;

int kruskal() {
    sort(g.begin(), g.end());
    UnionFind uni(g.size());
    int res = 0;
    for (auto &&e : g)
    {
        if (!uni.same(e.u, e.v))
        {
           uni.unite(e.u, e.v);
            res += e.cost;
        }
    }

    return res;
}

int main()
{
    int n;
    gc(n);

    v.reserve(n);

    for (int i = 0; i < n; i++)
    {
        int x, y;
        gc(x);
        gc(y);
        v.emplace_back(x, y, i);
    }

    sort(v.begin(), v.end(), [](State& lhs, State& rhs) {
      return lhs.x < rhs.x;
    });

    for (int i = 0; i < n - 1; i++)
    {
        g.emplace_back(v[i].num, v[i + 1].num, abs(v[i].x - v[i + 1].x));
    }

    sort(v.begin(), v.end(), [](State& lhs, State& rhs) {
      return lhs.y < rhs.y;
    });

    for (int i = 0; i < n - 1; i++)
    {
        g.emplace_back(v[i].num, v[i + 1].num, abs(v[i].y - v[i + 1].y));
    }

    printf("%d\n", kruskal());
}


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

int main() {
    int n; cin >> n;
    vector<int> x[n], y[n];
    for (int i = 0; i < n; i++) {
        int q; cin >> q;
        while (q--) {
            int a, b; cin >> a >> b;
            x[i].emplace_back(--a);
            y[i].emplace_back(b);
        }
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        int cnt = 0; bool ok = true;
        for (int i = 0; i < n; i++) {
            if (!(bit & (1 << i))) continue;
            cnt++;
            for (int j = 0; j < x[i].size(); j++) {
                if (y[i][j] && (bit & (1 << x[i][j]))) continue;
                if (!y[i][j] && !(bit & (1 << x[i][j]))) continue;
                ok = false; 
            }
        }
        if (ok) ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
const int MAX_DP = 5005;
ll dp[MAX_DP];

int main() {
  int N, P;
  cin >> N >> P;
  fill(dp, dp+MAX_DP, 0);
  dp[0] += 1;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int sum = MAX_DP-1; sum >= 0; sum--) {
      if (sum - a >= 0) {
	dp[sum] += dp[sum-a];
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < MAX_DP; i++) {
    if (i % 2 == P) {
      ans += dp[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

map<pair<int, int>, int> ma;
int ans[10];
signed main() {
	int H, W, N;
	cin >> H >> W >> N;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		for (int dx = -1; dx <= 1; dx++) {
			for (int dy = -1; dy <= 1; dy++) {
				int y = a + dy;
				int x = b + dx;
				if (y <= 1 || x <= 1 || y >= H || x >= W) continue;
				pair<int, int> p = make_pair(x, y);
				ma[p]++;
			}
		}
	}
	int sum = 0;
	for (pair<pair<int,int>,int> p : ma) {
		ans[p.second]++;
		sum++;
	}
	ans[0] = (H - 2)*(W - 2) - sum;

	for (int i = 0; i < 10; i++) {
		cout << ans[i] << "\n";
	}

	return 0;
}

Measured memory_bytes: 56448
h, w = map(int, input().split())
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    ans = float("inf")
    for i in range(h):
        choco = [i * w, (h - i) * (w // 2), (h - i) * (w - w // 2)]
        ans = min(ans, max(choco) - min(choco))
    for i in range(w):
        choco = [i * h, (w - i) * (h // 2), (w - i) * (h - h // 2)]
        ans = min(ans, max(choco) - min(choco))
    for i in range(h):
        choco = [i * w, w * ((h - i) // 2), w * ((h - i) - (h - i) // 2)]
        ans = min(ans, max(choco) - min(choco))
    for i in range(w):
        choco = [i * h, h * ((w - i) // 2), h * ((w - i) - (w - i) // 2)]
        ans = min(ans, max(choco) - min(choco))
    print(ans)

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

int main() {
  int A, B; cin >> A >> B;
  
  bool flag = true;
  
  if (A > 8 || B > 8) flag = false;
  
  if (flag) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

const int kMaxV = 100010;
const int kInf = 0x3F3F3F3F;

using namespace std;

struct Edge {
  int from;
  int to;
  int dist;

  Edge(int from, int to, int dist): from(from), to(to), dist(dist) {}
};

struct BellmanFord {
  int v, e;
  vector<Edge> edges;
  vector<int> g[kMaxV];
  int dist[kMaxV];
  int parent[kMaxV];
  bool has_negative_cycle;

  BellmanFord(int v): v(v) {}

  void AddEdge(int from, int to, int dist) {
    edges.emplace_back(from, to, dist);
    g[from].push_back(edges.size() - 1);
  }

  void Solve(int source) {
    queue<int> q;
    for (int i = 0; i < v; ++i) {
      dist[i] = kInf;
      q.push(i);
    }
    dist[source] = 0;
    for (int i = 0; i < v - 1; ++i) {
      for (auto e: edges) {
        if (dist[e.to] > dist[e.from] + e.dist && dist[e.from] != kInf) {
          dist[e.to] = dist[e.from] + e.dist;
          parent[e.to] = e.from;
        }
      }
    }
    has_negative_cycle = false;
    for (auto e: edges) {
      if (dist[e.to] > dist[e.from] + e.dist && dist[e.from] != kInf) {
        has_negative_cycle = true;
      }
    }
  }
};

int main() {
  int v, e, r;
  scanf("%d %d %d", &v, &e, &r);
  auto solver = new BellmanFord(v);
  for (int i = 0; i < e; ++i) {
    int s, t, d;
    scanf("%d %d %d", &s, &t, &d);
    solver->AddEdge(s, t, d);
  }
  solver->Solve(r);
  if (solver->has_negative_cycle) {
    printf("NEGATIVE CYCLE\n");
  } else {
    for (int i = 0; i < v; ++i) {
      if (solver->dist[i] == kInf) {
        printf("INF\n");
      } else {
        printf("%d\n", solver->dist[i]);
      }
    }
  }
}



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

#define int long long

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	string str;
	cin >> str;
	if (str[str.length() - 1] != 's') {
		str += 's';
	}
	else if (str[str.length() - 1 ] == 's') {
		str += 'e';
		str += 's';
	}
	cout << str;
	return 0;
}

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

int get_digit(int n) {
    int d = 0;
    while (n > 0) {
        n /= 10;
        d++;
    }
    return d;
}

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

    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (get_digit(i) % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int r;
    cin >> r;
    cout << r*r << endl;

    return 0;
}

Measured memory_bytes: 256