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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll n;
	cin >> n;

	ll x[n], y[n], h[n];
	rep(i, n){
		cin >> x[i] >> y[i] >> h[i];
	}

	ll anscx = -1, anscy = -1, ansh = 0;
	for(ll cx = 0; cx <= 100; cx++){
		for(ll cy = 0; cy <= 100; cy++){
			bool ok = true;
			ll saveh = 0;
			ll uph = 1e11;

			rep(i, n){
				if(h[i] == 0){
					uph = min(uph, abs(cx - x[i]) + abs(cy - y[i]));
					if(saveh > 0 && saveh > uph){
						ok = false;
						break;
					}else{
						continue;
					}
				}
				if(saveh == 0) {
					saveh = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
					if(saveh > uph) {
						ok = false;
						break;
					}
				}
				ll nowh = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
				if(nowh != saveh) {
					ok = false;
					break;
				}
			}
			if(ok){
				anscx = cx;
				anscy = cy;
				ansh = saveh;
			}
		}
	}

	cout << anscx << " " << anscy << " " << ansh;
}


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

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

    vector<ll> F(100000);

    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                ll tmp = x * x + y * y + z * z + x * y + x * z + y * z;
                if (tmp <= 10000)
                    F[tmp]++;
            }
        }
    }

    for (int i = 1; i <= n; i++)
    {
        cout << F[i] << endl;
    }
}

Measured memory_bytes: 4044
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n;
  scan(n);
  vi a(n);
  scan(a);
  sort(all(a));
  double ans = a[0];
  FOR (i, 1, n) {
    ans = (ans + a[i]) / 2;
  }
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n,x,ans = 0;
    cin >> n >> x;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        ans = gcd(ans,abs(a-x));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 09.01.2018 10:40:48       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << (a % 2 == b % 2 ? "Alice" : "Borys") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<vector>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pi;
///////////////////////////////

int const N = 1e5 + 41;
int n, root, deg[N];
vector<int> e[N];
ll a[N], dp[N];

void bad(){
	printf("NO\n");
	exit(0);
}

void ok(){
	printf("YES\n");
	exit(0);
}

vector<ll> cur[N];

bool can(int id, ll mini){
	sort(cur[id].begin(), cur[id].end());
	ll sum = 0;
	fi(0, sz(cur[id])){
		sum += cur[id][i];
	}
	ll maxi = cur[id].back();
	ll cnt;
	if(maxi >= sum - maxi){
		cnt = sum - maxi;
	}else{
		cnt = sum / 2;
	}
	if(cnt >= mini){
		return true;
	}else{
		return false;
	}
}

void dfs(int u, int p){
	if(sz(e[u]) == 1){
		dp[u] = a[u];
		return;
	}

	ll S = 0;
	fi(0, sz(e[u])){
		int to = e[u][i];
		if(to == p){
			continue;
		}
		dfs(to, u);
		S += dp[to];
		cur[u].pb(dp[to]);
	}
	ll k = a[u] * 2 - S;
	if(k < 0){
		bad();
	}
	if(k > S){
		bad();
	}
	if(S % 2 != k % 2){
		bad();
	}
	if(!can(u, (S - k) / 2)){
		bad();
	}
	if(u == root){
		if(k != 0){
			bad();
		}
	}

	dp[u] = k;
}

void solve(){
	if(n == 2){
		if(a[0] == a[1]){
			ok();
		}else{
			bad();
		}
	}
	fi(0, n){
		if(deg[i] >= deg[root]){
			root = i;
		}
	}
	dfs(root, -1);
	ok();
}

void read(){
	cin >> n;
	fi(0, n){
		cin >> a[i];
	}
	fi(0, n-1){
		int u, v;
		cin >> u >> v;
		--u;--v;
		e[u].pb(v);
		e[v].pb(u);
		++deg[u];
		++deg[v];
	}
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();


	return 0;
}

Measured memory_bytes: 21632
#include "iostream"
#include "algorithm"
using namespace std;

int main() {
  int n;
  cin>>n;
  int a[100100];
  for (int i = 0; i < n; i++) {
    cin>>a[i];
  }
  int even[100100]={0};
  int odd[100100]={0};
  for (int i = 0; i < n; i++) {
    if(i%2==0){
      even[a[i]]++;
    }
  else{
    odd[a[i]]++;
  }
  }
  int max_e=0;
  int max_o=0;
  int c,d;
  int sec_e=0;
  int sec_o=0;
  for (int i = 0; i < 100100; i++) {
    if (max_e<even[i]) {
      max_e=even[i];
      c=i;
    }
    if (max_o<odd[i]) {
      max_o=odd[i];
      d=i;
    }
  }
  if (c!=d){
  cout<<n-max_e-max_o<<endl;
}
else{
  for (int i = 0; i < 100100; i++) {
    if (sec_e<even[i]&&i!=c) {
      sec_e=even[i];
    }
    if (sec_o<odd[i]&&i!=d) {
      sec_o=odd[i];
    }
  }
  cout<<min({n-max_e-sec_o,n-sec_e-max_o})<<endl;
}
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdint>

using namespace std;

const static int INFTY = (1<<30);
static vector<int> A(2000000 + 1);
static int H = 0;
 
static inline int parent(int i) {
  return i / 2;
}
 
static inline int left(int i) {
  return 2 * i;
}

static inline int right(int i) {
    return 2 * i + 1;
}

static inline void maxHeapify(vector<int>& A, int i) {
  const int l = left(i);
  const int r = right(i);

  int largest = 0;
  if (l <= H && A[l] > A[i]) {
    largest = l;
  } else {
    largest = i;
  }

  if (r <= H && A[r] > A[largest]) {
    largest = r;
  }
    
  if (largest != i) {
    swap(A[i], A[largest]);  
    maxHeapify(A, largest);
  }
}

static void heapIncreaseKey(vector<int>& A, int i, int key) {
  if (key < A[i]) {
    printf("エラー：新しいキーは現在のキーより小さい\n");
    return;
  }
  A[i] = key;
  while (i > 1 && A[parent(i)] < A[i]) {
    swap(A[i], A[parent(i)]);
    i = parent(i);
  }
}

static void insert(vector<int>& A, int key) {
  H++;
  A[H] = -INFTY;
  heapIncreaseKey(A, H, key);
}

static int extract(vector<int>& A) {
  if (H < 1) {
    printf("エラー：ヒープアンダーフロー\n");
    return 0;
  }
  int max = A[1];
  A[1] = A[H--];
  maxHeapify(A, 1);

  return max;
}

int main() {
  string command;
  int v;
  while (true) {
    cin >> command;
    if (command[0] == 'i') {
      scanf("%d", &v);
      insert(A, v);
    } else if (command[0] == 'e' && command[1] == 'x') {
      cout << extract(A) << endl;
    } else {
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 10572
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const int INF = (1LL<<30);
#else
const ll INF = (1LL<<60);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int n;
int a[40010], b[40010], c[40010];
pair<double, int> p[40010], p2[40010], p3[40010];

ll con;

int bit[40010], m = 40010;

//0からi-1番目までの和
int sum(int i) {
  i++;
  int s = 0;
  while(i > 0) {
    s += bit[i];
    i -= i&-i;
  }
  return s;
}

//i番目(0-index)にxを加える
void add(int i, int x) {
  i++;
  while(i <= m) {
    bit[i] += x;
    i += i&-i;
  }
}

bool check(double mid) {
  // 数列を求める
  REP(i, n) {
    int idx = p[i].second;
    p2[i] = {-(double)a[idx]/b[idx]*mid+(double)c[idx]/b[idx], i};
  }
  sort(p2, p2+n);
  // p2.secondの転倒数を求める
  memset(bit, 0, sizeof(bit));
  ll ans = 0;
  REP(i, n) {
    ans += i - sum(p2[i].second);
    add(p2[i].second, 1);
  }
  return ans >= con;
}

bool check2(double mid) {
  // 数列を求める
  REP(i, n) {
    int idx = p3[i].second;
    p2[i] = {-(double)b[idx]/a[idx]*mid+(double)c[idx]/a[idx], i};
  }
  sort(p2, p2+n);
  // p2.secondの転倒数を求める
  memset(bit, 0, sizeof(bit));
  ll ans = 0;
  REP(i, n) {
    // cout << p2[i].second << " ";
    ans += i - sum(p2[i].second);
    add(p2[i].second, 1);
  }
  // cout << endl << "ans:" << ans << endl;
  return ans >= con;
}

signed main(void)
{
  cin >> n;
  REP(i, n) {
    cin >> a[i] >> b[i] >> c[i];
    p[i] = {-(double)a[i]/b[i], i};
    p3[i] = {(double)b[i]/a[i]*INF+(double)c[i]/a[i], i};
  }
  sort(p, p+n); sort(p3, p3+n);
  reverse(p, p+n);

  // REP(i, n) cout << p3[i].first << "," << p3[i].second << " "; cout << endl;

  con = n*(n-1)/4 + !!(n*(n-1)%4);
  double low = -1e10, high = 1e10;
  REP(_, 300) {
    double mid = (low+high)/2;
    if(check(mid)) {
      high = mid;
    } else {
      low = mid;
    }
  }
  cout << fixed << setprecision(15) << low << " ";
  low = -1e10, high = 1e10;
  REP(_, 300) {
    double mid = (low+high)/2;
    // cout << low << " " << mid << " " << high << endl;
    if(check2(mid)) {
      high = mid;
    } else {
      low = mid;
    }
  }
  cout << low << endl;

  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <complex>
#include <map>

using namespace std;

using ull = unsigned long long;
using ll = long long;

int main(){

	int N, L;
	cin >> N >> L;
	vector<string> S(N);

	for (auto&& a : S){
		cin >> a;
	}

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

	for (auto&& a : S){
		cout << a;
	}
	cout << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  map<ll,ll> div;
  ll N;
  cin>>N;
  ll now = N;
  for(ll i=2;i<=sqrt(N);++i){
    if(now%i==0){
      if(div.find(i)==div.end()){
        div[i]++;
      }else{
        div[i]++;
      }
      //cout<<i<<endl;
      now/=i;
      if(now==1)break;
      i--;
    }
  }
  if(now!=1){
    div[now]++;
  }
  function<std::pair<ll,ll>(ll,ll,map<ll,ll>::iterator)> f= 
    [&](ll a,ll b,map<ll,ll>::iterator c){
  	if(c==div.end()){
      return make_pair(a,b);
    }
    auto it = c;
    it++;
    ll min=LLONG_MAX;
    pair<ll,ll> minp=make_pair(1000000000003ll,1ll);
    for(int i=0;i<=c->second;++i){
      pair<ll,ll> tmp = f(a*pow(c->first,i),b*pow(c->first,c->second-i),it);
      if(tmp.first+tmp.second<min){
        min=tmp.first+tmp.second;
        minp=tmp;
      }
    }
    return minp;
  };
  auto ans=f(1,1,div.begin());
  cout<<ans.first-1+ans.second-1<<endl;
  return 0;
}


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

int N;
int A, B, C;
int l[9];

int dfs(int a, int b, int c, int i){
  if(i == N) {
    if(a != 0 && b != 0 && c != 0) {
      return abs(a-A) + abs(b-B) + abs(c-C) - 30;
    }else return 1e9;
  }
  int ans = dfs(a, b, c, i+1);
  ans = min(ans, dfs(a+l[i], b, c, i+1) + 10);
  ans = min(ans, dfs(a, b+l[i], c, i+1) + 10);
  ans = min(ans, dfs(a, b, c+l[i], i+1) + 10);
  return ans;
}

int main(void){
  cin >> N;
  cin >> A >> B >> C;
  for(int i=0; i<N; i++) cin >> l[i];
  
  int ans = dfs(0, 0, 0, 0);
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] tr = new int[3];

		for (int i = 0; i < 3; i++) {
			tr[i] = sc.nextInt();
		}

		int a = tr[0];
		int b = tr[1];
		int C = tr[2];

		double S = a * b * Math.sin( Math.toRadians(C) ) / 2;
		double L = a + b + Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2)
							- 2 * a * b * Math.cos( Math.toRadians(C) ));
		double h = 2 * S / a;

		System.out.println(S);
		System.out.println(L);
		System.out.println(h);

		sc.close();

	}
}


Measured memory_bytes: 26332
#include <bits/stdc++.h>
#define SLAY ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.141592653589793238
#define ll long long
#define pii pair<int , int>
#define pll pair<long long , long long>
using namespace std;
int _=1 , tc=1;
int dx[] = { 0 , 0 , 1 , -1};
int dy[] = { 1 , -1 , 0 , 0};
int getmod(int x, int y , int mod ){return (((x - y)%mod)+mod)%mod;}
int MAXN = 46341 + 1;
int spf[46341+1];
int d,x,y;
int gcd(int a , int b){
	if(b==0)return a;
	return gcd(b , a%b);
}
void sieve(){
	for(int i = 1 ; i<MAXN ; i++)spf[i]=i;
	for(int i = 4 ; i<MAXN ; i+=2)spf[i]=2;
	for(int i = 3; i*i<MAXN; i+=2){
		if(spf[i]==i){
			for(int j = i*i ; j<MAXN ; j+=i){
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}
void extended_gcd(int a , int b){
	if(b==0){
		d=a;
		x=1;
		y=0;
	}else{
		extended_gcd(b,a%b);
		int temp = y;
		y = x - y * (a/b);
		x = temp;	
	}
}
ll gcd(ll a , ll b){
	if(b==0)return a;
	return gcd(b , a%b);
}
ll lcm(ll a, ll b){  
    return (a*b)/gcd(a, b);  
}
void solve(){
	string s;
	cin>>s;
	int ans = 0;
	if(s[0]=='R')ans=1;
	if(s[1]=='R')ans=1;
	if(s[2]=='R')ans=1;
	if(s[1]=='R' && s[0]=='R')ans=2;
	if(s[1]=='R' && s[2]=='R')ans=2;
	if(s[0]=='R' && s[1]=='R' && s[2]=='R')ans=3;
	cout<<ans;
}
int main(){
	SLAY
	// cin>>_;
	while(_--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
//Warmdust Code
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#define db double
#define ll long long
#define ull unsigned long long
#define ft float
#define PI acos(-1)
#define L(i,a,b) for(int i=a;i<=b;i++)
#define R(i,a,b) for(int i=a;i>=b;i--)
#define inf 0x3f3f3f3f
#define linf  0x3f3f3f3f3f3f3f3f
#define Warmdust int main(){
#define RETURN return 0;}
#define TvT ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn = 1e5+7;
const int mod = 10000+7;
int sz[maxn];
Warmdust
	TvT;
	int n;
	cin >> n;
	L(i,1,n) {
		int x;
		cin >> x;
		sz[x] = i;
		
	}
	L(i,1,n-1) {
		cout << sz[i] << " ";
	}
	cout << sz[n] << endl;
RETURN 


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

const int mod = 1000000007;

int main(){
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) h -= a[i];
    if(h>0){
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n,d;
    cin >> n >> d;
    int i,j,k;
    int ans=0;
    int x[n][d];
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            cin >> x[i][j];
        }
    }
    for(i=0;i<n;i++){
        for(j=1;i+j<n;j++){
            ll dis[d];
            ll DIS=0;
            for(k=0;k<d;k++){
                dis[k]=x[i][k]-x[i+j][k];
                dis[k]=dis[k]*dis[k];
                DIS+=dis[k];
            }
            int sqr = 0;
            sqr=sqrt(DIS);
            if(sqr*sqr==DIS){
                ans++;
                //cout << i << "番目と"<<i+j <<"番目はOK"<<endl;
                }
            else{
                //cout << i <<" " << i+j << " " << DIS <<" "<< sqr <<endl;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

/*int ter_search(int l,int r)
{
    while((r-l)>0)
    {
        int m1=l+(r-l)/3;
        int m2=r-(r-l)/3;
        int f1=f(m1);
        int f2=f(m2);
        if(f1>f2)
         l=m1+1;
         else
          r=m2-1;
    }
    return f(l);
}*/

int32_t main()
{
    string s;
    cin>>s;
    int minn=1e9;
    int x;
    for(int i=0;i<=(s.size()-3);i++)
    {
        x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        minn=min(minn,abst(x-753));
    }
    cout<<minn<<"\n";
     return 0;
}

Measured memory_bytes: 3628
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    interview=[]
    n,m = map(int,input().split())
    interview=[list(map(int,input().split())) for _ in range(n)]
    set_data={}

    for data in interview:
        if len(set_data)==0:
            set_data  = set(data[1:])
        else:
            set_data=set_data & set(data[1:])
    print(len(set_data))


if __name__=="__main__":
    main()

Measured memory_bytes: 9112
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] a = new int[N];
		int[] ans = new int[N];
		for (int i=0;i<N;i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		for (int i=(int)Math.ceil(((double)N)/2);i<N;i++) {
			ans[i] = a[i];
		}
		for (int i=(int)Math.ceil(((double)N)/2)-1;i>=0;i--) {
			int sum = a[i];
			for (int j=2;j*(i+1)<=N;j++) {
				sum+=ans[j*(i+1)-1];
			}
			ans[i]=sum%2;
		}
		// for (int i=N-1;i>=0;i--) {
		// 	System.out.println(i);
		// 	if (a[i]==1) {
		// 		for (int num : divise(i+1)) {
		// 				if (ans[num-1]==0) {
		// 					ans[num-1] = 1;
		// 				} else {
		// 					ans[num-1] = 0;
		// 				}
		// 		}
		// 	}
		// }
		// System.out.println(divise(1));
		// System.out.println(Arrays.toString(a));
		// System.out.println(Arrays.toString(ans));
		int sum_int=0;
		for (int i=0;i<N;i++) {
			if (ans[i]==1) {
				sum_int++;
			}
		}
		System.out.println(sum_int);
		for (int i=0;i<N;i++) {
			if (ans[i]==1) {
				System.out.println(i+1);
			}
		}
	}

    static List<Integer> divise(int n) {
                List<Integer> list = new ArrayList<Integer>();
        for (int i=1;i<=Math.sqrt(n);i++) {
            if (n%i==0) {
                list.add(i);
                if (i*i!=n) {
                	list.add(n/i);
                }
            }
        }
        Collections.sort(list);
        return list;
    }
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

const int N_MAX = pow(10,5);
vector<int> adj[N_MAX+10];
vector<int> d(N_MAX+10, -1);

int dfs(int n=0, int p=-1) {
  if (d[n]!=-1) return d[n];
  if (p!=-1&&adj[n].size()==1) return d[n] = 0;
  multiset<int, greater<int>> pos;
  for (auto x: adj[n]) {
    if (x!=p) pos.insert(dfs(x,n));
  }
  int result = 0, count = 1;
  for (auto x: pos) {
    result = max(result, x+count);
    count++;
  }
  return d[n] = result;
}

int main() {
  int N; cin >> N;
  rep(i,N-1) {
    int a; cin >> a; a--;
    adj[i+1].push_back(a);
    adj[a].push_back(i+1);
  }
  dfs();
  int result = 0;
  rep(i,N) result = max(result, d[i]);
  cout << result << endl;
  // rep(i,N) cout << d[i] << " "; cout <<  endl;
  return 0;
}

Measured memory_bytes: 18560
n = int(input())
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
i = 0
c = 0
m = list()
while i < n-1:
    if a[i]==a[i+1]:
        m.append(a[i])
        i += 1
        c += 1
    i += 1
    if c == 2:
        break
if c == 2:
    print(m[0]*m[1])
else:
    print(0)

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
  if(A.size() == n + 1) {
    int now = 0;
    rep(i, q) {
      if(A[b[i]] - A[a[i]] == c[i])
        now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  A.push_back(A.back());
  while(A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  dfs(vector<int>(1, 1));

  cout << ans;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
long long fact[110000];
long long finv[110000];
long long inv[110000];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
int main(){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<110000;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<110000;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
	int a,b;scanf("%d%d",&a,&b);
	long long ret=1;
	for(int i=2;i*i<=b;i++){
		if(b%i==0){
			int cnt=0;
			while(b%i==0){
				b/=i;cnt++;
			}
			ret=ret*C(cnt+a-1,cnt)%mod;
		}
	}
	if(b>1)ret=ret*a%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
string a[100001];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		cout<<a[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
A = list(map(int, input().split()))
X = {1}
r = [1]
for i in range(0, N):
    tmp = A[r[-1]-1]
    if K == 1:
        print(tmp)
        exit(0)
    else:
        if X.isdisjoint({tmp}):
            r.append(tmp)
            X.add(r[-1])
            K -= 1
        else:
            R = r[r.index(tmp):]
            K -= 1
            break
print(R[K % len(R)])


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, l;
  cin >> n >> l;
  
  vll a(n);
  rep(i,n) cin >> a[i];
  
  ll b = -1;
  rep(i,n-1){
    if(a[i]+a[i+1] >= l){
      b = i;
    }
  }
  
  if(b==-1){
    cout << "Impossible"<<endl;
    return 0;
  }
  
  cout << "Possible"<<endl;
  
  rep(i,b){
    cout << i+1 <<endl;
  }
  for(int i=n-2;i>=b;i--){
    cout << i+1 <<endl;
  }

  return 0;
}


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

int main(){
	char s[105];
	cin >> (s + 1);
	for(int i = 1 ; ;i++){ 
		if(s[i] == '\0') break;
		if(i%2){
			if(s[i] == 'L'){ cout << "No" ; return 0;}  
		}
		else {if(s[i] == 'R' ){ cout << "No" ; return 0;}}
	
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    char a,b; cin >> a >> b;
    cout << (a==b ? 'H' : 'D') << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - '0';}
char myitoc(int N) {return '0' + N;}

struct edge
{
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};

signed main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<edge>> G(N);
  for (int i = 0; i < M; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G.at(a).push_back(edge(b, -c));
  }

  vector<int> d(N, INF);
  d.at(0) = 0;
  for (int i = 0; i < 2 * N; i++)
  {
    for (int v = 0; v < N; v++)
    {
      for (int k = 0; k < G.at(v).size(); k++)
      {
        edge e = G.at(v).at(k);
        if (d.at(v) != INF && chmin(d.at(e.to), d.at(v) + e.cost))
        {
          if (i == N - 1)
          {
            d.at(e.to) = -INF;
          }
        }
      }
    }
  }

  if (-d.at(N - 1) >= INF)
    cout << "inf" << endl;
  else
    cout << -d.at(N - 1) << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.TreeMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

class Main {
    public static void main(String[] args) {
        // Key:restranの名前 Value:indexとscoreのMap
        Map<String, Map<Integer, Integer>> scoreTree = new TreeMap<>();

        int N;
        Scanner scanner = new Scanner(System.in);

        N = scanner.nextInt();

        for(int i = 1; i <= N; i++){
            String name;
            int score;
            name = scanner.next();
            score = scanner.nextInt();

            if(scoreTree.containsKey(name)){
                scoreTree.get(name).put(score, i);
            } else {
                // Key:score Value:index
                Map<Integer, Integer> restrant = new TreeMap<>();
                restrant.put(score, i);
                scoreTree.put(name, restrant);
            }
        }

        for (String name : scoreTree.keySet()) {
            List<Integer> list = new ArrayList<>();
            for (Integer index : scoreTree.get(name).values()){
                list.add(index);
            }
            for(int i = list.size() - 1; i >= 0; i--){
                System.out.println(list.get(i));
            }
        }

        scanner.close();

    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int n;

	std::cin >> n;


	std::vector<int> v(2 * n);
	for (int i = 0; i < 2 * n; i++) {
		std::cin >> v[i];
	}

	std::sort(v.begin(), v.end());

	long long ans = 0;

	for (int i = 0; i < v.size(); i+=2) {
		ans += v[i];
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

inline int modulo(int a, int b){
  return a - floor(a / (double)b) * b;
}

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

  int N, X, D; cin >> N >> X >> D;
  if(D == 0){
    if(X == 0) cout << 1 << endl;
    else cout << N+1 << endl;
    return 0;
  }
  if(D < 0){
    X += (N-1)*D; D = -D;
  }
  map<int, vector<INTP> > mp;
  map<int, INTV> nums;
  REP(k, N+1){ // k個取る
    int md = modulo(k*X, D);
    int top    = floor(k*X / (double)D) + k*(2*N-k-1)/2 + 1;
    int bottom = floor(k*X / (double)D) + k*(k-1)/2;
    mp[md].pb({bottom, top}); // 半開
    nums[md].pb(top);
    nums[md].pb(bottom);
  }
  int ans = 0;
  for(auto itr : mp){
    map<int, int> idx;
    int md = itr.first;
    sort(ALL(nums[md]));
    REP(i, nums[md].size()){
      idx[nums[md][i]] = i;
    }
    INTV imos(nums[md].size(), 0);
    REP(i, itr.second.size()){
      int bottom = itr.second[i].first;
      int top    = itr.second[i].second;
      imos[idx[bottom]]++; imos[idx[top]]--;
    }
    RANGE(i, 1, nums[md].size()){
      imos[i] += imos[i-1];
    }
    REP(i, nums[md].size()){
      if(imos[i] > 0){
        ans += nums[md][i+1] - nums[md][i];
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 44032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int N,M;
  long long X;
  long long ans=0;
  vector<long long> xv;
  vector<long long> diff;
  cin>>N>>M;
  //N>=Mなら0でOK
  if(N>=M){
    cout<<0<<"\n";
  }
  else{
    //M-Nだけ、駒を動かしてXを回収しないといけない
    //X同士の間の距離のうち小さい方からM-Nこをとる
    for(int i=0;i<M;++i){
      cin>>X;
      xv.push_back(X);
    }
    //xvを昇順にソート 
    sort(xv.begin(),xv.end());
    //x同士の差を求める
    for(int i=0;i<M-1;++i){
      diff.push_back(xv[i+1]-xv[i]);
    }
    //　diffを昇順にソート 
    sort(diff.begin(),diff.end());
    for(int i=0;i<M-N;++i){
      ans+=diff[i];
    }
    cout<<ans<<"\n";
  }
return 0;
}


Measured memory_bytes: 2548
N = int(input())
S = [input() for _ in range(N)]
dic = {}
X = sorted(list(set(S[0])))
for i in X:
  dic[i] = 51
for i in range(N):
  for x in X:
    dic[x] = min(dic[x],S[i].count(x))
for i in X:
  print(i * dic[i],end="")

Measured memory_bytes: 3064
import sys
import itertools

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
s = sum(a)
t = list(itertools.accumulate(a))
min_ = inf
for i in range(n-1):
    x = t[i]
    min_ = min(min_, abs((s-x) - x))
print(min_)

Measured memory_bytes: 30596
n,m = map(int, input().split())
a_list = list(map(int, input().split()))


sum=[]
sum.append(0);

for i in range(0,n):
  sum.append((sum[i]+a_list[i])%m)

countDic={}
ans =0

for i in range(len(sum)):
  ans += countDic.get(sum[i],0)
  countDic[sum[i]] = countDic.get(sum[i],0)+1

print(ans)


Measured memory_bytes: 16172
#include<iostream>
#include<vector>
using namespace std;
int main(){
    long long n;cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long buf=0;
    long long ans=0;
    for(int i=0;i<n;i++){
        buf+=a[i];
        ans+=buf/2;
        buf%=2;
        if(a[i]==0)buf=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.StringTokenizer;

public final class Main{
    public static void main(String[] args){
        java.util.Scanner stdIn = new java.util.Scanner(System.in);
        
        long n = stdIn.nextLong();
        double[] v = new double[(int)n];
        for(int i=0; i<v.length; i++){
            v[i] = stdIn.nextDouble();
        }

        Union union = new Union((int)n);
        
        for(int num=0; num<((int)n)-1; num++){
            int minVal = 10000;
            int minIdx = 0;
            for(int i=0; i<v.length; i++){
                if(minVal>v[i]){
                    minVal = (int)v[i];
                    minIdx = i;
                }
            }
            int secondVal = 10000;
            int secondIdx = 0;
            for(int i=0; i<v.length; i++){
                if(secondVal>v[i] && minIdx != i){
                    secondVal = (int)v[i];
                    secondIdx = i;
                }
            }
    
            double temp = (v[minIdx] + v[secondIdx]) / 2.0;
            v[minIdx] = temp;
            v[secondIdx] = 1000000;
    
            union.add(minIdx, secondIdx);
        }
        System.out.println(v[union.pare(1)]);
    }
}

class Union{
    int[] dis;
    public Union(int n){
        dis = new int[n];
        for(int i=0; i<dis.length; i++){
            dis[i] = i;
        }
    }

    public void add(int a, int b){
        dis[b] = a;
    }

    public int pare(int a){
        int idx = a;
        while(dis[idx] != idx){
            idx = dis[idx];
        }
        return idx;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public long nextInt() {
        return Integer.parseInt(next());
    }

}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for (int row = 0; row < H; row++) {
    for (int column = 0; column < W; column++) {
      cin >> data.at(row).at(column);
    }
  }
  int press = 0;
  for (int column = 0; column < W; column++) {
    for (int row = 0; row < H; row++) {
      if (data.at(row).at(column) == '#') {
        break;
      }
      else if (row == H - 1) {
        press++;
      }
    }
  }
  int i = 0;
  vector<vector<char>> pressed(H, vector<char>(W - press));
  for (int column = 0; column < W; column++) {
    bool check = false;
    for (int row = 0; row < H; row++) {
      if (data.at(row).at(column) == '#') {
        check = true;
        break;
      }
    }
    if (check) {
      for (int row = 0; row < H; row++) {
        pressed.at(row).at(i) = data.at(row).at(column);
      }
      i++;
    }
  }
  for (int row = 0; row < H; row++) {
    bool check = false;
    for (int column = 0; column < W - press; column++) {
      if (pressed.at(row).at(column) == '#') {
        check = true;
        break;
      }
    }
    if (check) {
      for (int column = 0; column < W - press; column++) {
        cout << pressed.at(row).at(column);
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
const ll mod = 1e9+7;

int a[maxn];
int b[maxn];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&b[i]);
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(b[i]>a[i]){
            ans += a[i];
            b[i] -= a[i];
            if(b[i]>a[i+1]){
                ans += a[i+1];
                a[i+1] = 0;
                b[i] -= a[i+1];
            }else {
                ans += b[i];
                a[i+1] -= b[i];
                b[i] = 0;
            }
        }else {
            ans += b[i];
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
a=list(input())
b=list(input())
c=list(input())
next=a.pop(0)
while True:
  if next=="a":
    if not a:
      print("A")
      break
    else:
      next=a.pop(0)
  elif next=="b":
    if not b:
      print("B")
      break
    else:
      next=b.pop(0)
  else :
    if not c:
      print("C")
      break
    else:
      next=c.pop(0)

Measured memory_bytes: 61616
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair 
#define mt make_tuple
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define Mod 998244353
#define N 200001
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
/*
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}*/ 
int main()
{
	string s;
	cin>>s;
	int temp=0;
	for(int i=1;i<s.size();i+=2)
	{
		if(s[i]=='R')
		{
			temp=1;
			break;
		}
	}
	if(temp==1)
	{
		cout<<"No";
		return 0;
	}
	for(int i=0;i<s.size();i+=2)
	{
		if(s[i]=='L')
		{
			temp=1;
			break;
		}
	}
	if(temp==1){
		cout<<"No";
	}
	else
	cout<<"Yes";
	return 0;
}







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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(x) cout<<x<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
	vector<ll> Parent;
public:
	UnionFind(ll N){
		Parent = vector<ll>(N, -1);
	}

	ll root(ll A){
		if(Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	ll size(ll A){
		return -Parent[root(A)];
	}

	bool connect(ll A, ll B){
		A = root(A);
		B = root(B);
		if(A == B){
			return false;
		}
		if(size(A) < size(B)) swap(A, B);
		Parent[A] += Parent[B];
		Parent[B] = A;
		return true;
	}

	bool isSame(ll A, ll B){
		return root(A) == root(B);
	}
};

ll n,m;


signed main()
{
	cin.tie( 0 ); ios::sync_with_stdio( false );
	cin>>n>>m;
	vpll ab(m);
	rep(i,m){
		ll a,b; cin>>a>>b; a--,b--;
		ab[i]={a,b};
	}
	ll ans=0;
	rep(i,m){
		UnionFind uf(n);
		rep(j,m){
			if(i==j) continue;
			uf.connect(ab[j].first,ab[j].second);
		}
		bool ok=true;
		rep(i,n){
			if(!uf.isSame(0LL,i)) ok=false;
		}
		if(!ok) ans++;
	}
	cout<<ans<<endl;
}


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

int main(){
    string s; cin>>s;
    int ans=0;
    if(s=="SUN")
    ans=7;
    else if(s=="MON")
    ans=6;
    else if(s=="TUE")
    ans=5;
    else if(s=="WED")
    ans=4;
    else if(s=="THU")
    ans=3;
    else if(s=="FRI")
    ans=2;
    else if(s=="SAT")
    ans=1;

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


Measured memory_bytes: 256