akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#define inf 1e18
int n;
long long a[405];
long long dp[405][405];
long long sum[405];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++){
			if(i==j)dp[i][j]=0;
			else dp[i][j]=inf;
		}
	for(int l=2;l<=n;l++){
		for(int i=1;i+l-1<=n;i++){
			int j=i+l-1;
			for(int k=i;k<j;k++){
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]-sum[i-1]+sum[j]);
			}
		}
	}
	cout<<dp[1][n];
}

Measured memory_bytes: 1536
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int n;
string s;
bool c;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>s;
	n=s.length();
	for(int i=0;i<n;++i)
	{
		if(s[i]=='C')
		{
			c=true;
		}
		if(s[i]=='F'&&c)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
#define MAX_N  23
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
ll n;
ll dp[MAX_N][1ll<<MAX_N]={};
ll a[MAX_N][MAX_N];
bool flag[MAX_N][1ll<<MAX_N]={};
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll solve(ll v,ll pair){
  if(flag[v][pair]){
    return dp[v][pair];
  }
  flag[v][pair] = true;
  if(v==0){
    if(pair==0) return dp[v][pair] = 1;
    else return dp[v][pair] = 0;
  }
  ll res = 0,bt;
  for(ll i=0;i<n;i++){
    if(pair&((1ll<<i))){
      if(a[v-1][i]==1){
        bt = pair - (1ll<<i);
        res += solve(v-1,bt);
        res %= MOD;
      }
    }
  }
  return dp[v][pair] = res;
}
signed main(){
  init_io();
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> a[i][j];
    }
  }
  cout << solve(n,(1<<n)-1)<<endl;
}


Measured memory_bytes: 395520
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int Z = S.size();
	vector<char>al(26);
	al = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
	vector<int>F(26);
	rep(i, Z) {
		rep(j, 26) {
			if (S[i] == al[j]) {
				F[j] ++;
			}
		}
	}
	vector<int>f(26);
	int cnt = 0;
	int ans = 0;
	rep(t, Z) {
		rep(i, t) {
			rep(j, 26) {
				if (S[i] == al[j]) {
					f[j] ++;
				}
			}
		}
		rep(j, 26) {
			if (F[j] > f[j] && f[j] != 0) {
				cnt++;
			}
		}
		ans = max(ans, cnt);
		cnt = 0;
		rep(j, 26) {
			f[j] = 0;
		}
	}
	cout << ans << endl;
}

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


int main() {
	
	int n;
	cin >> n;
	vector<int>a(n);
	for(auto& e:a) cin >> e;
	ll ans = 0;
	for(int i=0; i<n; i++) {
		for (int j=i+1; j<n; j++) {
			ans += a[i]*a[j];
		}
	}
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll A, B, K;
	cin >> A >> B >> K;
	ll d = min(A, K);
	A -= d;
	K -= d;
	d = min(K, B);
	B -= d;
	K -= d;
	cout << A << " " << B << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int func(int x){
  if(x%100!=0) return 0;
  return func(x/100)+1;
}

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  rep(i,n) a[i]--;
  int sum=0;
  rep(i,n) sum+=a[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 3608
sx, sy, tx, ty = gets.split.map(&:to_i)

M = Hash.new {|h,k| h[k] = {}}
D = [['U', 0, 1], ['D', 0, -1], ['R', 1, 0], ['L', -1, 0]]

def walk(x, y, tx, ty)
  return '' if x == tx && y == ty 
  M[x][y] = true
  nx = D.map{|v| [v[0], x + v[1], y + v[2]]}.reject{|v| M[v[1]][v[2]]}
  w = nx.sort{|a, b| (a[1] - tx) ** 2 + (a[2] - ty) ** 2 <=> (b[1] - tx) ** 2 + (b[2] - ty) ** 2}.first
  w[0] + walk(w[1], w[2], tx, ty)
end

all = ""
all << walk(sx, sy, tx, ty)
M[sx][sy] = false
all << walk(tx, ty, sx, sy)
M[tx][ty] = false
all << walk(sx, sy, tx, ty)
M[sx][sy] = false
all << walk(tx, ty, sx, sy)

puts all

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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

string s;
bool iskai(int b, int e){
   while(b<e){
      if(s[b]!=s[e]) return false;
      b++;
      e--;
   }
   return true;
}

int main(){
   cin>>s;
   int n=s.size();

   if(iskai(0, n-1) && iskai(0, (n-1)/2-1) && iskai((n+3)/2-1, n-1))
      cout<<"Yes"<<endl;
   else
      cout<<"No"<<endl;

   return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
#define f0(i, n) for (int i = 0; i < n; i++)
#define fs(i, s) for (int i = 0; i < s.size(); i++)
#define ll long long int
#define nl endl
int main()
{
	ll n,k;
	cin>>n>>k;
	n=n%k;
	cout<<min(n,k-n);
}


Measured memory_bytes: 3528
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
//using ll = long long;
using ll = unsigned long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[1000006] = {};
	ll y[200005] = {};
	ll z[200005] = {};
	string s;

	//IntStack yStack;
	//charStack Stack;

	cin >> a;
	cin >> b;
	for (int i = 0; i < b; i++)
	{
		cin >> y[i];
		cin >> z[i];
		if (y[i]==1)
		{
			x[z[i]]++;
		}

	}
	for (int i = 0; i < b; i++)
	{
		if (z[i]==a&&x[y[i]]>=1)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	/*
	for (int i = 0; i < b; i++)
	{
		cin >> x[i];
		cin >> y[i];
		if (x[i]>y[i])
		{
			c = x[i];
			x[i] = y[i];
			y[i] = c;
		}
	}
	for (int i = 0; i < b; i++)
	{
		if (x[i] == 1)
		{
			for (int k = 0; k < b; k++)
			{
				if (x[k] == y[i] && y[k] == a)
				{
					cout << "POSSIBLE" << endl;
					return 0;
				}
			}
		}
	}
	*/
	cout << "IMPOSSIBLE" << endl;


	//cout << a << endl;


	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 11136
import java.util.*;

class Main{

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

		int x= n/3600,  y= n%3600/60,  z= n%60;

		System.out.println(x +":"+ y +":"+ z);
	}
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

template <typename T,typename E>
struct SegmentTree{
	typedef function<T(T,T)> F;
	typedef function<T(T,E)> G;
	typedef function<E(E,E)> H;
	typedef function<E(E,int)> P;
	int n;
	F f;
	G g;
	H h;
	P p;
	T d1;
	E d0;
	vector<T> dat;
	vector<E> laz;

	SegmentTree(int n_,
				F f,//要素と要素をマージする関数
				G g,//要素に作用素を作用させる関数
				H h,//作用素と作用素をマージする関数
				T d1,//要素のモノイド
				E d0,//作用素のモノイド
				vector<T> v=vector<T>(),
				P p=[](E a,int b){return a;})://区間に対する操作が要素数に比例して変化する場合
	f(f),g(g),h(h),d1(d1),d0(d0),p(p){
		init(n_);
		if(n_==(int)v.size()) build(n_,v);
	}
	
	void init(int n_){
		n=1;
		while(n<n_) n*=2;
		dat.clear();
		dat.resize(2*n-1,d1);
		laz.clear();
		laz.resize(2*n-1,d0);
	}
	
	void build(int n_, vector<T> v){
		for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--){
			dat[i]=f(dat[i*2+1],dat[i*2+2]);
		}
	}
	
	inline void eval(int len,int k){
		if(laz[k]==d0) return;
		if(k*2+1<n*2-1){
			laz[k*2+1]=h(laz[k*2+1],laz[k]);
			laz[k*2+2]=h(laz[k*2+2],laz[k]);
		}
		dat[k]=g(dat[k],p(laz[k],len));
		laz[k]=d0;
	}
	
	
	T update(int a,int b,E x,int k,int l,int r){
		eval(r-l,k);
		if(r<=a||b<=l) return dat[k];
		if(a<=l&&r<=b){
			laz[k]=h(laz[k],x);
			return g(dat[k],p(laz[k],r-l));
		}
		return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
				update(a,b,x,k*2+2,(l+r)/2,r));
	}
	
	T update(int a,int b,E x){
		return update(a,b,x,0,0,n);
	}
	
	T query(int a,int b,int k,int l,int r){
		eval(r-l,k);
		if(r<=a||b<=l) return d1;
		if(a<=l&&r<=b) return dat[k];
		T vl=query(a,b,k*2+1,l,(l+r)/2);
		T vr=query(a,b,k*2+2,(l+r)/2,r);
		return f(vl,vr);
	}
	
	T query(int a,int b){
		return query(a,b,0,0,n);
	}
};
/**
	SegmentTree(int n_,
				F f,//要素と要素をマージする関数
				G g,//要素に作用素を作用させる関数
				H h,//作用素と作用素をマージする関数
				T d1,//要素のモノイド
				E d0,//作用素のモノイド
				vector<T> v=vector<T>(),//初期配列
				P p=[](E a,int b){return a;})://区間に対する操作が要素数に比例して変化する場合
**/

int main(){
	
	int n,q;cin >> n >> q;
	
	SegmentTree<ll,ll> seg(n,
	[](ll a,ll b){return a + b;},
	[](ll a,ll b){return a + b;},
	[](ll a,ll b){return a + b;},
	0,
	0,
	vector<ll>(n,0),
	[](ll a,int b){return a * b;});
	
	REP(i,q){
		int type;cin >> type;
		if(type == 0){
			int a,b,c;cin >> a >> b >> c;
			a--;b--;
			seg.update(a,b+1,c);
		}
		else {
			int a,b;cin >> a >> b;
			a--;b--;
			cout << seg.query(a,b+1) << endl;
		}
	}
	
	return 0;
}



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

int main() {
  char ch;
  bool a=false, b=false, c=false;
  for (int i=0; i<3; i++) {
    cin >> ch;
    if (ch == 'a') a = true;
    if (ch == 'b') b = true;
    if (ch == 'c') c = true;
  }
  if (a && b && c) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>

using namespace std;

int n, q;
char S[1048576];
vector<pair<char, char>> spells;

int goneLeft() {
  int ans = -1;
  int low = 0, high = n - 1;
  while (low <= high) {
    int mid = (low + high) / 2;

    int ind = mid;
    for (const auto &spell : spells) {
      if (S[ind] == spell.first) {
        if (spell.second == 'L') {
          ind--;
        } else {
          ind++;
        }
        if (ind < 0 || ind >= n) {
          break;
        }
      }
    }
    if (ind < 0) {
      ans = mid;
      low = mid + 1;
    }
    else {
      high = mid - 1;
    }
  }
  return ans;
}
int goneRight() {
  int ans = n;
  int low = 0, high = n - 1;
  while (low <= high) {
    int mid = (low + high) / 2;

    int ind = mid;
    for (const auto &spell : spells) {
      if (S[ind] == spell.first) {
        if (spell.second == 'L') {
          ind--;
        } else {
          ind++;
        }
        if (ind < 0 || ind >= n) {
          break;
        }
      }
    }
    if (ind >= n) {
      ans = mid;
      high = mid - 1;
    }
    else {
      low = mid + 1;
    }
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &q);
  scanf("%s", S);
  for (int i = 0; i < q; i++) {
    char letter[30], direction[30];
    scanf("%s%s", letter, direction);
    spells.emplace_back(letter[0], direction[0]);
  }
  int L = goneLeft();
  int R = goneRight();
  int ans = R - L - 1;
  if (ans < 0) ans = 0;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1148
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
#define double long double

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

vector<int>A;
ll S, N, M;
ll sum_r(int x) {
	int K = 0, L = x, I = 0;
	while (I < N) {
		auto itr = lb(A, L);
		if (itr == A.end())break;
		I = itr - A.begin();//0-indexedでのA[I]>=Lとなる最小のI
							//print(I);
		K += N - I;
		L += x;
	}
	return S - K * x;
}
vector<int>B;
ll ret[2001];
signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/

	S = 0;
	cin >> N >> M;
	A.resize(N);
	B.resize(M);
	REP(i, N) {
		//int a; cin >> a;
		cin >> A[i];
		FOR(j, 1, 801) {
			ret[j] += A[i] % j;
		}
		//A.pb(a);
		S += A[i];
	}
	VSORT(A);
	REP(i, M) {
		/*int b; cin >> b;
		B.pb(b);*/
		cin >> B[i];
	}
	ll ans = 0;
	REP(i, M) {
		if (B[i] <= 800) {
			ans += ret[B[i]];
		}
		else ans += sum_r(B[i]);
	}
	print(ans);
}


Measured memory_bytes: 5944
def Traveling(n , txyl):

    ans = "No"
    count = 0
    for i in range(n):
        if txyl[i][0] >= txyl[i][1] + txyl[i][2] and txyl[i][0] % 2 == (txyl[i][1] + txyl[i][2]) % 2:
            count += 1

    if count == n:
        ans = "Yes"

    return ans

def main():
    n = int(input())
    txyl = [list(map(int , input().split())) for i in range(n)]
    print(Traveling(n , txyl))

if __name__ == '__main__':
    main()


Measured memory_bytes: 60760
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

void preParse(int u) {
	if (u == NIL) return;
	printf(" %d", u);
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u) {
	if (u == NIL) return;
	inParse(T[u].l);
	printf(" %d", u);
	inParse(T[u].r);
}

void postParse(int u) {
	if (u == NIL) return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d", u);
}

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

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) T[i].p = NIL;

	for (int i = 0; i < n; ++i) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if (l != NIL) T[l].p = v;
		if (r != NIL) T[r].p = v;
	}

	for (int i = 0; i < n; ++i) if (T[i].p == NIL) root = i;

	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
}


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

#define FasterIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(), v.end()
const int MOD = 1e9+7;

int main(){
    FasterIO;

    int a, b, c;

    while(cin>>a>>b>>c){
        if((c>=a && c<=b) || (c>=b && c<=a))
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void) {
	
	int a,b,c;
	cin >>a >>b >>c;
	
	int max,ans;
	max=b/a;
	if (max>c) {
		ans=c;
	} else {
		ans=max;
	}
	
	cout <<ans <<endl;
	
	return 0;
}

Measured memory_bytes: 256
while 1:
	n=input()
	if n==0:break
	s=[map(int,raw_input().split()) for i in range(n)]
	sh=set([min(s[i]) for i in range(n)])
	tl=set([max([s[j][i] for j in range(n)]) for i in range(n)])
	print list(sh&tl)[0] if len(sh&tl)>0 else 0
	

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

using namespace std;

int main(){
	string str;
	cin>>str;
	int m,b;
	while(str!="-"){
		cin>>m;
		int sum=0;
		for(int i=0;i<m;i++){
			cin>>b;
			sum+=b;
		}
		sum%=str.size();
		str=str.substr(sum,str.size()-sum)+str.substr(0,sum);
		cout<<str<<endl;
		cin>>str;
	}
	return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    string a, b, c;
    cin >> a >> b >> c;
    string ans = "A";
    ans += b[0];
    ans += "C";
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


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

int main(void)
{
	int w, h, k, n1;
	long *n;
	long mod=1000000007;
	long b[9] = {0, 1, 1, 2, 3, 5, 8, 13, 21};
	scanf("%d%d%d", &h, &w, &k);
	n1 = w*(h+1);
	n = (long *)malloc(sizeof(long)*n1);

	n[0]=1;
	for (int i = 1; i < w; ++i)
	{
		n[i]=0;
	}
	for (int i = 1; i <= h; ++i)
	{
		for (int j = 0; j < w; ++j)
		{
			if (i<j)
			{
				n[w*i+j]=0;
			}
			else if (j==0)
			{
				n[w*i+j]=(n[w*(i-1)+j]*b[w]+n[w*(i-1)+j+1]*b[w-1]+mod)%mod;
			}
			else if (j==w-1)
			{
				n[w*i+j]=(n[w*(i-1)+j]*b[w]+n[w*(i-1)+j-1]*b[w-1]+mod)%mod;
			}
			else
			{
				n[w*i+j]=(n[w*(i-1)+j]*b[j+1]*b[w-j]+n[w*(i-1)+j-1]*b[j]*b[w-j]+n[w*(i-1)+j+1]*b[w-j-1]*b[j+1]+mod)%mod;
			}
		}
	}

	printf("%ld\n", n[w*h+k-1]);
	return 0;
}


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

int main() {
    int k, x;
    cin >> k >> x;
    for (int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++) {
        cout << i << " ";
    }
    cout << 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 N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
        }
        for(int i = N - 1; i >= 0; i--){
            System.out.print(a[i]);
            if(i != 0){
                System.out.print(" ");
            }
        }
        System.out.println("");
    }
}


Measured memory_bytes: 26268
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vi a(n);
    double tot = 0.0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        tot += a[i];
    }
    tot /= n;
    int ret     = -1;
    double mini = INF;
    for (int i = n - 1; i >= 0; --i) {
        if (mini >= abs(a[i] - tot)) {
            mini = abs(a[i] - tot);
            ret  = i;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int num[128][128]={0};
    int r,c,sum=0;
    int rsum[128]={0};
    int csum[128]={0};
    scanf("%d %d",&r,&c);
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            scanf("%d",&num[i][j]);
            rsum[i]+=num[i][j];
            csum[j]+=num[i][j];
            sum+=num[i][j];
        }
    }
    for(int i=0;i<r;i++){
        for(int j=0;j<c+1;j++){
            if(j==c)printf("%d\n",rsum[i]);
            else printf("%d ",num[i][j]);
        }
    }
    for(int i=0;i<c;i++)printf("%d ",csum[i]);
    printf("%d\n",sum);
}



Measured memory_bytes: 2108
n, tx = input().strip().split(' ')
n, tx = [int(n),int(tx)]

c_ans = 1001
for i in range (n):
    c, t = input().strip().split(' ')
    c, t = [int(c),int(t)]
    if c < c_ans and t <= tx:
        c_ans = c
if c_ans == 1001:
    print('TLE')
else:
    print(c_ans)


Measured memory_bytes: 38256
package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	l := 4 * 4 * 4 * 4
	fp := os.Stdin

	fmt.Fscan(fp, &n)

	dp := make([]last3, n+1)

	for i := 0; i < l; i++ {
		l1 := i / 64 % 4
		l2 := i / 16 % 4
		l3 := i / 4 % 4
		a := i % 4
		if validate(l1, l2, l3, a) {
			dp[3].acgt[l2][l3][a] = 1
		} else {
			dp[3].acgt[l2][l3][a] = 0
		}
	}

	for d := 4; d <= n; d++ {
		for i := 0; i < l; i++ {
			l1 := i / 64 % 4
			l2 := i / 16 % 4
			l3 := i / 4 % 4
			a := i % 4
			if validate(l1, l2, l3, a) {
				dp[d].acgt[l2][l3][a] += dp[d-1].acgt[l1][l2][l3]
			} else {
				dp[d].acgt[l2][l3][a] = 0
			}
			dp[d].acgt[l2][l3][a] = dp[d].acgt[l2][l3][a] % 1000000007
		}
	}

	sum := 0
	for i := 0; i < l/4; i++ {
		l1 := i / 16 % 4
		l2 := i / 4 % 4
		l3 := i % 4
		sum += dp[n].acgt[l1][l2][l3]
		sum = sum % 1000000007
	}

	fmt.Println(sum)

}

type last3 struct {
	acgt [4][4][4]int
}

func validate(l1 int, l2 int, l3 int, add int) bool {
	switch add {
	case 1:
		if l2 == 0 && l3 == 2 {
			return false
		}
	case 2:
		if l2 == 0 && l3 == 1 {
			return false
		}
		if l2 == 1 && l3 == 0 {
			return false
		}
		if l1 == 0 && l2 == 1 {
			return false
		}
		if l1 == 0 && l3 == 1 {
			return false
		}
	}
	return true
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,d=0;
  int c[100]={};
  for(int i=0;i<3;i++){
    cin>>a>>b;
    c[a]++;
    c[b]++;
  }
  for(int i=0;i<5;i++){
    if(c[i]>=3) d=1;
  }
  if(d==0) cout<<"YES";
  else cout<<"NO";
  cout<<"\n";
}

Measured memory_bytes: 256
n = int(input())
alist = list(map(int, input().split()))

ms, ps = 0, 0
mc, pc = 0, 0
if alist[0] < 0:
  ms = alist[0]
  ps = 1
  pc = abs(ms) + 1
elif alist[0] > 0:
  ps = alist[0]
  ms = -1
  mc = ps + 1
else:
  ps = 1
  pc = 1
  ms = -1
  mc = 1

for a in alist[1:]:
  if a < 0:
    if ms < 0:
      mc += abs(a + ms) + 1
      ms = 1
    else:
      if a + ms < 0:
        ms += a
      else:
        mc += abs(a + ms) + 1
        ms = -1
    if ps < 0:
      pc += abs(a + ps) + 1
      ps = 1
    else:
      if a + ps < 0:
        ps += a
      else:
        pc += abs(a + ps) + 1
        ps = -1
  elif a > 0:
    if ms > 0:
      mc += abs(a + ms) + 1
      ms = -1
    else:
      if a + ms > 0:
        ms += a
      else:
        mc += abs(a + ms) + 1
        ms = 1
    if ps > 0:
      pc += abs(a + ps) + 1
      ps = -1
    else:
      if a + ps > 0:
        ps += a
      else:
        pc += abs(a + ps) + 1
        ps = 1
  else:
    if ms > 0:
      mc += abs(ms) + 1
      ms = -1
    else:
      mc += abs(ms) + 1
      ms = 1
    if ps > 0:
      pc += abs(ps) + 1
      ps = -1
    else:
      pc += abs(ps) + 1
      ps = 1

print(min(pc, mc))


Measured memory_bytes: 14332
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define MAXN 500005
#define LL long long
using namespace std;

int n, k, a[MAXN];

bool check(int mid)
{
	for(int i=k; i<=n; i++)
		if(a[i]-a[i-k+1]<=mid) return true;
	return false;
}

int main()
{
	scanf("%d%d", &n, &k);
	for(int i=1; i<=n; i++) scanf("%d", &a[i]);
	sort(a+1, a+n+1);
	int l=0, r=1e9, ans=0;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1, ans=mid;
		else l=mid+1;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define WM 1e5
using namespace std;

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

    double ans = (N / 3) * (N / 3) * (N / 3);

    cout << fixed << setprecision(10) << ans << endl;
    //cout << ans << endl;
    
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> avec(N);
  for (auto &a : avec)
  {
    cin >> a;
  }
  int ans = 0;
  bool exist = false;
  while (!exist)
  {
    bool exist2 = false;
    for (int i = 0; i < N; i++)
    {
      if (avec[i] % 2 != 0)
      {
        exist2 = true;
        break;
      }
    }
    if (exist2)
    {
      exist = true;
      break;
    }
    for (int i = 0; i < N; i++)
    {
      avec[i] /= 2;
    }
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
* @author:  codancer
* @createTime:  2020-02-17, 09:39:06
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
ll n,k,ans,L,R;
ll a[200010];
// bool check(ll x){
// 	ll cnt=0;// the number that less than x
// 	for(int i=1;i<=n;i++){
// 		ll num=0;
// 		if(a[i]==0){
// 			if(x>0) cnt+=n-1;
// 		}else{
// 			if(a[i]>0){
// 				ll h=x/a[i];
// 				if(x%a[i]&&(x>0)){
// 					++h;
// 				}
// 				num=lower_bound(a+1,a+n+1,h)-a-1;
// 			}
// 			else{
// 				ll h=x/a[i];
// 				if(x%a[i]&&(x>0)){
// 					h--;
// 				}
// 				ll great=upper_bound(a+1,a+n+1,h)-a-1;
// 				num=n-great;
// 			}
// 			cnt+=num;
// 			if(a[i]*a[i]<x) --cnt;
// 		}
// 	}
// 	cnt/=2;
// 	return cnt<k;
// }
bool chk(ll x)
{
	ll cnt=0,t1,t2;
	for(int i=1;i<=n;++i)
		if(a[i])
		{
			t1=t2=x/a[i];
			if(x%a[i])
			{
				if((x<0 && a[i]>0) || (x>0 && a[i]<0)) --t1;
				else ++t2;
			}
			if(a[i]<0) cnt+=n+1-(upper_bound(a+1,a+n+1,t1)-a);
			if(a[i]>0) cnt+=lower_bound(a+1,a+n+1,t2)-a-1;
			if(a[i]*a[i]<x) --cnt;
		}else if(x>0) cnt+=n-1;cnt>>=1;return cnt<k;
}
int main()
{
	scanf("%lld %lld",&n,&k);L=-1e18;R=1e18;
	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);sort(a+1,a+n+1);
	while(L<=R) {ll mid=L+R>>1;if(chk(mid)) L=mid+1,ans=mid;else R=mid-1;}
	printf("%lld\n",ans);return 0;
}
// int main(){
// 	cin>>n>>k;
// 	for(int i=1;i<=n;i++) cin>>a[i];
// 	sort(a+1,a+n+1);
// 	ll l=-1e18,r=1e18;
// 	ll ans;
// 	// cout<<check(-6)<<endl;
// 	while(l<=r){
// 		ll mid=(l+r)/2;
// 		if(chk(mid)){
// 			 l=mid+1;
// 			 ans=mid;
// 		}
// 		else{
// 			r=mid-1;
// 		}
// 	}
// 	cout<<ans<<endl;
// 	return 0;
// }

Measured memory_bytes: 1792
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n,k;
  cin>>n>>k;
  cout << 180*(n-2)<< endl;
  return 0;
}


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

#define LL long long

map<string,bool> mp;

int main(){
	

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

	int n;
	cin>>n;

	string prev;
	cin>>prev;
	mp[prev]=true;

	for(int i=1;i<n;i++){
		string s;cin>>s;
		if(mp[s] || prev[(int)prev.length()-1]!=s[0]){cout<<"No"<<endl;return 0;}
		prev=s;
		mp[s]=true;
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
a=int(input())
c=[input().split(" ")for i in range(0,a)]
for i in c:
    i[1]=int(i[1])
#print(c)
d=sorted(c,key=lambda x:(x[0],-x[1]))
#print(d)
for j in d:
    print(c.index(j)+1)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int a,b;
    char c;
    cin >> a >> c >> b;
    if(c == '+'){
        cout << a+b << endl;
    }else{
        cout << a-b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//Utkarsh.25dec
#include <bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,w;
    cin>>n>>w;
    vector <pair<ll,ll>> v;
    ll dp[w+1]={0};
    rep(i,n)
    {
        ll a,b;
        cin>>a>>b;
        for(int j=w;j>=max((ll)0,a);j--)
        {
            dp[j]=max(dp[j],dp[j-a]+b);
        }
    }
    cout<<dp[w];
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
}

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

using namespace std;

#define oo (1L<<62)
#define ll long long int

int h[100005];
ll memo[100005];
char visitado[100005];
int N;

ll memoiter[3];

ll costo(int  n){
    if(!n) return n;
    if(n == 1) return abs(h[0]-h[1]);
    if(visitado[n]) return memo[n];
    visitado[n] = 1;
    return memo[n]= min(costo(n-1)+abs(h[n]-h[n-1]), 
                    costo(n-2)+abs(h[n]-h[n-2])); 
}

ll iterativo(){
    memoiter[0] = 0;
    memoiter[1] = abs(h[0]-h[1]);
    for(int i = 2; i<N; i++)
        memoiter[i%3] = min(memoiter[(i-1)%3]+abs(h[i]-h[i-1]),
                      memoiter[(i-2)%3]+abs(h[i]-h[i-2]));
    return memoiter[(N-1)%3];
}
    

int main()
{
    cin>>N;
    for(int i = 0; i<N;i++)
        cin>>h[i];
    cout<<costo(N-1)<<"\n";
}


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

int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		int x, y, b, p;
			cin >> x >> y >> b >> p;
			double s = x*b + (y*p);
			if (s >= ((x*max(5, b) + (y*max(2, p)))*0.8)) {
				s = ((x*max(5, b) + (y*max(2, p)))*0.8);
			}
			cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3244
N = int(input())
A = list(map(int, input().split()))

a4 = 0
a2 = 0
a0 = 0
for a in A:
    if a % 4 == 0:
        a4 += 1
    elif a % 4 == 2:
        a2 += 1
    else:
        a0 += 1

if a2 == 0:
    if a4 >= a0-1:
        print('Yes')
    else:
        print('No')
elif a0 == 0:
    print('Yes')
else:
    if a4 >= a0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 14252
N = int(input())
H = list(map(int,input().split()))

dp = [0]*N
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
  dp[i] = min(abs(H[i]-H[i-1])+dp[i-1], abs(H[i]-H[i-2])+dp[i-2])
print(dp[N-1])

Measured memory_bytes: 13928
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
  string S;
  cin >> S;
  
  int Smax_size = 0;
  int cnt = 0;
  
  for(auto it = S.begin(); it < S.end(); it++){

    if( *it == 'A' || *it == 'T' || *it == 'G' || *it == 'C' ){
      
      for(auto jt = it; jt < S.end(); jt++){
        if( *jt != 'A' && *jt != 'T' && *jt != 'G' && *jt != 'C' ){
          break;
        }
        else{
          cnt++;
        }
      }
      
      if( Smax_size < cnt ){ 
        Smax_size = cnt;
      }
      
      cnt = 0;
    }
    
  }
  
  cout << Smax_size;
  
  return 0;
}

Measured memory_bytes: 256
s = gets.chomp.split("").to_a
Q = gets.chomp.to_i
Query = Q.times.map do
  gets.chomp.split(" ")
end
flag = true

(0..Q-1).each do |i|
  if Query[i][0] == "1"
    flag = !flag
  else
    if flag
      if Query[i][1] == "1"
        s = s.unshift(Query[i][2])
      else
        s = s.push(Query[i][2])
      end
    else
      if Query[i][1] == "1"
        s = s.push(Query[i][2])
      else
        s = s.unshift(Query[i][2])
      end
    end
  end
end

if flag
  puts s.join.to_s
else
  puts s.reverse.join.to_s
end

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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(10)





void solve() {

	map<string, int> mp;
	string a, b;
	cin >> a >> b;
	int x, y;
	cin >> x >> y;
	mp[a] = x;
	mp[b] = y;
	string s;
	cin >> s;
	mp[s]--;
	cout << mp[a] << " " << mp[b] << "\n";




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	solve();

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

struct Info{
	Info(ll arg_value,int arg_loc){
		value = arg_value;
		loc = arg_loc;
	}
	bool operator<(const struct Info &arg) const{
			return value < arg.value;
	};
	ll value;
	int loc;
};

int main(){

	int N;
	scanf("%d",&N);

	ll sum = 0,tmp;
	priority_queue<Info> Q;

	Q.push(Info(0,0));

	for(int i = 1; i <= N; i++){
		scanf("%lld",&tmp);
		sum += tmp;
		Q.push(Info(sum,i));
	}

	ll pre = -1;
	int maximum = 0,min_index = -1,max_index = -1;

	while(!Q.empty()){
		if(pre == Q.top().value){
			min_index = min(min_index,Q.top().loc);
			max_index = max(max_index,Q.top().loc);
		}else{
			if(min_index != max_index){
				maximum = max(maximum,max_index - min_index);
			}
			min_index = Q.top().loc;
			max_index = Q.top().loc;
		}

		pre = Q.top().value;
		Q.pop();
	}
	if(min_index != max_index){
		maximum = max(maximum,max_index - min_index);
	}

	printf("%d\n",maximum);

	return 0;
}

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


struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL){
    x= x->left;}
  return x;

}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x= x->right;}
  return x;

}

Node treeSearch(Node u, int k){
  while(u!=NIL&&k!=u->key){
    if(k < u->key){
      u = u->left;}
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if(x->right!=NIL)
    return treeMinimum(x->right);
  Node y = x->parent;
  while(y!=NIL&&x == y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right==NIL){
    y=z;}
  else y = treeSuccessor(z);
  if(y->left!=NIL){
    x=y->left;
  }else{
    x=y->right;}

  if(x!=NIL){
    x->parent = y->parent;
  }

  if(y->parent == NIL){
    root = x;
  }else{
    if(y==y->parent->left){
      y->parent->left=x;
    }else{
      y->parent->right=x;
    }
  }
  if(y!=z){
    z->key = y->key;
  }
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y==NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
    y->right=z;
  }
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25168
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

def bfs(x,y,c):
    global MAP
    global ans
    global q
    if MAP[x][y] != 0 or c > t:
        return
    else:
        q.append((x,y+1,c+1))
        q.append((x,y-1,c+1))
        q.append((x+1,y,c+1))
        q.append((x-1,y,c+1))
        q.append((x+1,y+1,c+1))
        q.append((x-1,y-1,c+1))

while True:
    t,n = inpl()
    if t == 0 and n == 0:
        break
    else:
        MAP = defaultdict(lambda:defaultdict(int))
        for _ in range(n):
            x,y = inpl()
            MAP[x][y] = -1

        sx,sy = inpl()
        ans = 0
        q = deque([(sx,sy,0)])
        while q:
            x,y,c = q.popleft()
            if MAP[x][y] == 0 and c <= t:
                ans += 1
                bfs(x,y,c)
                MAP[x][y] = -1

        print(ans)



Measured memory_bytes: 7424
using System;
using System.Collections.Generic;


public class Contest
{
	public static void Main()
	{
		int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));

//		int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] c = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
//		int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
*/

		Array.Sort(a);



		string ans = (a[0]*a[1]/2).ToString();

		Console.WriteLine(ans);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}


Measured memory_bytes: 13140
N, K = map(int, input().split())
h = []
for i in range(N):
    h.append(int(input()))

h.sort()
# print(h)
ans = 10**9+1
for i in range(N-1, K-2, -1):
    # print(h[i], h[i-(K-1)])
    ans = min(h[i]-h[i-(K-1)], ans)

print(ans)

Measured memory_bytes: 7384
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Frags [][]int

func (a Frags) Len() int           { return len(a) }
func (a Frags) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Frags) Less(i, j int) bool { return a[i][0] < a[j][0] }

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)

	var sum int
	var l, r Frags
	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(reader, &s)
		var d, min int
		for j := 0; j < len(s); j++ {
			if s[j] == '(' {
				d++
			} else {
				d--
			}
			if min > d {
				min = d
			}
		}
		if d > 0 {
			l = append(l, []int{min, d})
		} else {
			r = append(r, []int{min - d, -d})
		}
		sum += d
	}

	sort.Sort(sort.Reverse(l))
	sort.Sort(sort.Reverse(r))

	t := func(frags Frags) bool {
		var h int
		for _, f := range frags {
			if h+f[0] < 0 {
				return false
			}
			h += f[1]
		}
		return true
	}

	if sum == 0 && t(l) && t(r) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 90316
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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()
{
	int N;
	cin >> N;

	ll ans = 1;

	vll A(N);
	rep(i, N) cin >> A[i];

	sort(all(A));

	rep(i, N)
	{
		ll a = A[i];

		if (a == 0)
		{
			cout << 0 << endl;
			return 0;
		}

		if (ans > 1000000000000000000 / a)
		{
			cout << -1 << endl;
			return 0;
		}

		ans *= a;
	}

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


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

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

using i64=int64_t;

void solve(){
    i64 N,M;
    cin >> N >> M;

    vector<vector<int>> graph(N);
    rep(i,0,M){
        int A,B;
        cin >> A >> B;
        --A;
        --B;
        graph[A].push_back(B);
        graph[B].push_back(A);
    }

    i64 b=0,w=0;
    vector<int> color(N);
    function<bool(int,int)> dfs=[&](int u,int c){
        color[u]=c;
        if(c==1) ++b;
        else ++w;

        for(int v:graph[u]){
            int c_=c==1?2:1;
            if(color[v]){
                if(color[v]!=c_) return false;
            }else if(!dfs(v,c_)) return false;
        }
        
        return true;
    };

    if(!dfs(0,1)) cout << N*(N-1)/2-M << endl;
    else cout << b*w-M << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 6656
<?php
// Your code here!
list($a,$b) = explode(" ",fgets(STDIN));
$s = (int)($a.$b);
for($i=0;$i<1000;$i++)
{
    if($s == pow($i,2))
    {
        echo("Yes");
        exit;
    }
}
echo("No");
?>


Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int i;
  if(b-a+1<=2*k){
    for(i=a;i<b+1;i++){
      cout << i <<endl;
    }
  }else{
    for(i=a;i<a+k;i++){
      cout << i << endl;
    }
    for(i=b-k+1;i<=b;i++){
      cout << i << endl;
    }
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsinged long long
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a))
#define inf (1LL<<62)
#define sf scanf
#define pf printf
#define repi(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define depi(i,a,b) for(int i=a;i>=b;--i)
#define dep(i,a,b) for(ll i=a;i>=b;--i)
#define mod 1000000007

using namespace std;

int main()
{
    //std::ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int flag=1;
    for(int i=0;i<(int)s.size();++i)
    {
        if(i%2==0 && s[i]=='L')
        {
            flag=0;
            break;
        }
        if(i%2==1 && s[i]=='R')
        {
            flag=0;
            break;
        }
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
info=[]
num_zero=0
for i in range(n):
    x,y,h=map(int,input().split())
    info.append([h,x,y])
    if h==0:
        num_zero+=1
info2=sorted(info,reverse=True)

for i in range(101):
    for j in range(101):
        check=0
        cx,cy=i,j
        H=abs(info2[0][1]-cx)+abs(info2[0][2]-cy)+info2[0][0]
        for k in range(1,n-num_zero): #hi!=0のとき
            if abs(info2[k][1]-cx)+abs(info2[k][2]-cy)+info2[k][0]!=H:
                check=1
                break
        if check==0: #Hの候補があるとき
            for k in range(n-num_zero,n):
                if H-(abs(info2[k][1]-cx)+abs(info2[k][2]-cy))>0:
                    check=1
                    break
        if check==0:
            break
    if check==0:
        break
print(str(cx)+" "+str(cy)+" "+str(H))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  int a[n][d];
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>a[i][j];
    }
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double sum=0;
      for(int k=0;k<d;k++){
        sum+=(a[j][k]-a[i][k])*(a[j][k]-a[i][k]);
      }
      sum=sqrt(sum);
      //cout<<sum<<"\n";
      if(sum==ceil(sum) && sum==floor(sum)){
        cnt++;
      }
    }
  }
  cout<<cnt;
  return 0;
}


Measured memory_bytes: 256