akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
struct Dijkstra{
  ll INF=1000000000000000000, c = 10000000000;
  ll MAX_V=1000000, st = -1, L;
  struct edge{ll to, cost;};
  typedef pair<ll, ll> p;
  vector<vector<edge>> G;
  vector<ll> pre, d;
  priority_queue<p, vector<p>, greater<p> > que; //class, inner, compair
  Dijkstra(ll s, ll l){
    L = l;
    G.resize(s+2);
    pre.resize(s+2, -1);
    d.resize(s+2, INF);
  }
  inline void insert(ll a, ll b, ll c){
    G[a].push_back(edge{b, c});
  }
  void init(){
    for(int i=0;i<d.size();i++) pre[i] = -1, d[i] = INF;
  }
  void dijkstra(int start){
    init();
    st = start;
    d[start]=0;
    que.push(p(0, start));
    while(!que.empty()){
      p p_now=que.top(); que.pop();
      ll v = p_now.second;
      if(d[v]<p_now.first) continue;
      for(int i=0;i<G[v].size();i++){
        edge e = G[v][i];
        ll x = d[v]%c, y = e.cost, ne;
        if(x+y>L) ne = (d[v]/c+1)*c+y;
        else ne = d[v] + y;
        if(d[e.to]>ne){
          d[e.to]=ne;
          que.push(p(d[e.to], e.to));
        }
      }
    }
  }
};
int main(int argc, char const *argv[]) {
  ll a, b, c, n, m, l;std::cin >> n >> m >> l;
  Dijkstra dj(n+1, l);
  vvl dis = vv(n+1, n+1, 0, ll);
  re(i, m){
    std::cin >> a >> b >> c;
    if(c>l) continue;
    dj.insert(a, b, c);
    dj.insert(b, a, c);
  }
  for(int i=1;i<=n;i++){
    dj.dijkstra(i);
    for(int j=1;j<=n;j++) dis[i][j] = dj.d[j];
  }
  ll q;std::cin >> q;
  re(i, q){
    std::cin >> a >> b;
    ll t = dis[a][b]/10000000000 + (dis[a][b]%10000000000==0?-1:0);
    std::cout << (dis[a][b]==dj.INF?-1:t) << '\n';
  }
  return 0;
}


Measured memory_bytes: 4216
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	cin >> N >> L >> R;
	L--, R--;
	vector<vector<int>>edge(N);
	for (int i = 0; i < N - 1; i++) {
		edge[i].push_back(i + 1);
		edge[i + 1].push_back(i);
	}
	edge[L].push_back(R);
	edge[R].push_back(L);
	vector<int>ans(N-1);
	for (int i = 0; i < N; i++) {
		vector<int>dis(N, MOD);
		Calculate_Depth(edge, dis, i);
		for (int j = i + 1; j < N; j++) {
			ans[dis[j]-1]++;
		}
	}
	for (auto i : ans)cout << i << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
ll n;
cin>>n;
ll ans[101];
ans[0] = 2;
ans[1] = 1;
for(int i = 2; i < 100; i++ ){
    ans[i] = ans[i-1] + ans[i-2];
}

cout<<ans[n]<<endl;
   return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
int main(){
	char a[13]; scanf("%s", a); int i;
	for(i = 0; i < 4; i++)	printf("%c", a[i]);
	printf(" ");
	for(; i < strlen(a); i++)	printf("%c", a[i]);
	printf("\n");
	return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

int main(){
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    ll max_div = ll(sqrt(M)) + 5;
    ll ans = 1;
    
    vector<ll> div;
    FOR(i, 1, max_div) {
        if (M % i == 0) {
            div.pb(i);
            div.pb(M/i);
        }
    }
    sort(div.begin(), div.end());
    REP(i, div.size()) {
        if (div[i] >= N) {
            ans = M / div[i];
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> v(N); 
    for(int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    for(int i = 1; i < v.size(); i++) {
        ans = (ans + v[i]) / 2;
    }
    std::cout << ans << std::endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

ll a, b, n;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b >> n;
    ll x = min(n, b - 1);
    cout << floor(1.0 * a * x / b) - a * floor(1.0 * x / b) << "\n";
    return 0;
}


Measured memory_bytes: 3808
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

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

    int a = 1;
    rep(i,0,n){
	a = min(a*2,a+k);
    }

    P(a);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps=1e-8;
int main()
{
	ll a;
	double b;
	cin>>a>>b;
	b+=eps;
	ll c=b*100;
	ll ans=a*c/100;
	cout<<ans;
	return 0;
 } 

Measured memory_bytes: 3672
import sys
row = sys.stdin.readline
def read_int(row):
    return int(row().rstrip())

def read_string(row):
    return row().rstrip()
  
N = read_int(row)
S = read_string(row)

cnt = 0
for i in range(0, len(S) -2):
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C":
        cnt +=1
print(cnt)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


class Magatoro {
    static void Main() {
        string s = Console.ReadLine();
        for(int i = 0; i < 12; i++) {
            Console.Write(s[i]);
            if (i == 3) {
                Console.Write(' ');
            }
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 2648
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
MOD = 10**9+7
INF = MOD-1
dp = [INF]*(n+1)
if n == 1:
    if 1 in a:
        print(0)
    else:
        print(1)
    exit()

dp[0] = dp[1] = 1

for x in a:
    dp[x] = 0

for i in range(2, n+1):
    if dp[i] == 0:
        continue

    dp[i] = dp[i-1]+dp[i-2]
    dp[i] %= MOD


print(dp[n] if dp[n] != INF else 0)

Measured memory_bytes: 7848
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

ll H,W;
ll a[1010][1010];
ll dp[1010][1010];
bool used[1010][1010];

ll solve(ll s,ll t){
  if(s==H && t==W) return 1;
  if(s>H || t>W) return 0;
  if(a[s][t]==-1) return dp[s][t]=0;
  if(used[s][t]) return dp[s][t];
  used[s][t]=true;
  dp[s][t]=(solve(s+1,t)%MOD+solve(s,t+1)%MOD)%MOD;
  return dp[s][t];
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,K;
  cin >> N >> K;
  int N_MAX=110;
  int K_MAX=110000;
  int a[N_MAX];
  bool dp[K_MAX];
  for(int i=0;i<K_MAX;i++){
    dp[i]=false;
  }
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  for(int i=0;i<=K;i++){
    for(int j=0;j<N;j++){
      if(i-a[j]>=0){
        dp[i]=dp[i]|!dp[i-a[j]];
      }
    }
  }
  if(dp[K]) cout << "First" << endl;
  else cout << "Second" << endl;
  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+5;
const int M=1e6+5;
const int INF=0x3f3f3f3f;
const ull sed=31;
const ll mod=1e9+7;
const double eps=1e-9;
typedef pair<int,int>P;
typedef pair<double,double>Pd;

int n,m,ans;
bool vis[N];
vector<int>E[N];

void dfs(int x)
{
    if(vis[x]) return ;
    vis[x]=true;
    for(int i=0;i<E[x].size();i++) dfs(E[x][i]);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        E[x].push_back(y);
        E[y].push_back(x);
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i]) continue;
        ans++;
        dfs(i);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    string s;
    std::cin >> s;
    int n=s.size();
    string ss;
    rep(i,n){
        if(i%2==0)ss.pb('g');
        else ss.pb('p');
    }
    itn ans=0;
    rep(i,n){
        if(s[i]=='g'&&ss[i]=='p')ans++;
        if(s[i]=='p'&&ss[i]=='g')ans--;
    }
    std::cout << ans << std::endl;
}

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

int main() {
    int n; ll d;
    cin >> n >> d;
    int cnt = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

const int MAXN=1100;
const int MAXE=2100;
const long long MOD=1000000007;

struct Edge
{
	int next,to;
};
Edge edge[MAXE];
int head[MAXN];
int countedge;

void addedge(const int& start,const int& end)
{
	edge[countedge].to=end;
	edge[countedge].next=head[start];
	head[start]=countedge;
	countedge++;
}

int node,road;

int low[MAXN],dfn[MAXN];
int ind,cnt;
int belong[MAXN];

int stack[MAXN];
int top;
void dfs(int u)
{
	dfn[u]=low[u]=++ind;
	stack[++top]=u;
	int temp;
	for(temp=head[u];temp!=-1;temp=edge[temp].next)
	{
		if(!dfn[edge[temp].to])
		{
			dfs(edge[temp].to);
			low[u]=min(low[u],low[edge[temp].to]);
		}
		else if(!belong[edge[temp].to])low[u]=min(low[u],dfn[edge[temp].to]);
	}
	if(low[u]==dfn[u])
	{
		int now=u;
		cnt++;
		do
		{
			now=stack[top--];
			belong[now]=cnt;
		}
		while(now!=u);
	}
}

void solve()
{
	ind=0,cnt=0,top=0;
	memset(dfn,0,sizeof(dfn));
	memset(belong,0,sizeof(belong));
	int i;
	for(i=1;i<=node;i++)
	{
		if(!dfn[i]){dfs(i);}
	}
}

bool vis[MAXN];
int s[MAXN],e[MAXN];
int in[MAXN];
long long dp[MAXN][2];
void gao(int u)
{
	dp[u][0]=1;
	dp[u][1]=1;
	
	int temp;
	for(temp=head[u];temp!=-1;temp=edge[temp].next)
	{
		gao(edge[temp].to);
		dp[u][1]*=(dp[edge[temp].to][0]+dp[edge[temp].to][1]);
		dp[u][1]%=MOD;
	}
}

int main()
{
	scanf("%d%d",&node,&road);
	
	countedge=0;
	memset(head,-1,sizeof(head));
	
	int i;
	int start,end;
	for(i=0;i<road;i++)
	{
		scanf("%d%d",&s[i],&e[i]);
		addedge(s[i],e[i]);
	}
	solve();
	
	memset(head,-1,sizeof(head));
	countedge=0;
	
	memset(vis,0,sizeof(vis));
	for(i=0;i<road;i++)
	{
		int from=belong[e[i]];
		int to=belong[s[i]];
		if(from==to)continue;
		addedge(from,to);
		in[to]++;
	}

	long long ret=1;
	for(i=1;i<=cnt;i++)
	{
		if(in[i]==0)
		{
			gao(i);
			ret*=(dp[i][0]+dp[i][1]);
			ret%=MOD;
		}
	}
	
	printf("%lld\n",ret);
	
	return 0;

}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  char v[10][10];
  rep(i, 2) rep(j, 3) cin >> v[i][j];
  if(v[0][0] == v[1][2] && v[0][1] == v[1][1] && v[0][2] == v[1][0]){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  system("pause");
}

Measured memory_bytes: 504
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int a; cin >> a;
    int A = a / 1000;
    int B = a % 1000 / 100;
    int C = a % 100 / 10;
    int D = a % 10;
    if (A + B + C + D == 7)cout << A << "+" << B << "+" << C << "+" << D << "=" << 7 << endl;
    else if (A + B + C - D == 7)cout << A << "+" << B << "+" << C << "-" << D << "=" << 7 << endl;
    else if (A + B - C - D == 7)cout << A << "+" << B << "-" << C << "-" << D << "=" << 7 << endl;
    else if (A + B - C + D == 7)cout << A << "+" << B << "-" << C << "+" << D << "=" << 7 << endl;
    else if (A - B - C + D == 7)cout << A << "-" << B << "-" << C << "+" << D << "=" << 7 << endl;
    else if (A - B + C + D == 7)cout << A << "-" << B << "+" << C << "+" << D << "=" << 7 << endl;
    else if (A - B - C - D == 7)cout << A << "-" << B << "-" << C << "-" << D << "=" << 7 << endl;
    else cout << A << "-" << B << "+" << C << "-" << D << "=" << 7 << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <string.h>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;


string s;


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	reverse(s.begin(), s.end());
	s += '0';
	vector<vector<int>> dp(s.size() + 1	, vector<int>(2, INT32_MAX));
	dp[0][0] = s[0] - '0';
	dp[0][1] = 10 - (s[0] - '0');
	for (int i = 0; i < s.size() - 1; i++) {
		for (int carry = 0; carry <= 1; carry++) {
			int val = s[i + 1] - '0' + carry;
			if (val < 10) {
				dp[i + 1][0] = min(dp[i + 1][0], dp[i][carry] + val);
			}
			dp[i + 1][1] = min(dp[i + 1][1], dp[i][carry] + 10 - val);
		}

	}
	/*for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < 2; j++) {
			cout << dp[i][j] << " ";
		}
		cout << "\n";
	}*/
	cout << min(dp[s.size() - 1][0], dp[s.size() - 1][1]);
}



Measured memory_bytes: 55964
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m=map(int,input().split())
U=UnionFind(n)

for i in range(m):
  x,y,z=map(int,input().split())
  U.union(x-1,y-1)
ans=0
for i,j in enumerate(U.par):
  if i==j:
    ans+=1
print(ans)


Measured memory_bytes: 7856
#include <iostream>
#include <cstdint>

using namespace std;

int main() {
  int64_t K, X;
  cin >> K >> X;
  
  if (500 * K >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
n = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

Acum = list(accumulate(A))
ans = 0
for i, a in enumerate(reversed(A[1:])):
    ans += Acum[n-i-2]*a
    ans %= MOD


print(ans)


Measured memory_bytes: 31252
import heapq
n = int(input())
a = list(map(int, input().split()))

first = []
second = []
for i in range(n):
    first.append(a[i])
for i in range(2*n, 3*n):
    second.append(-a[i])
heapq.heapify(first)
heapq.heapify(second)


sumfirst = [0]*(n+1)
sumsecond = [0]*(n+1)
sumfirst[0] = sum(first)
sumsecond[n] = -sum(second)

for i in range(1, n+1):
    k = 0
    k += a[n-1+i]
    heapq.heappush(first, a[n-1+i])
    k -= heapq.heappop(first)
    sumfirst[i] = sumfirst[i-1]+k

for i in range(n-1, -1, -1):
    k = 0
    k += a[n+i]
    heapq.heappush(second, -a[n+i])
    k -= -heapq.heappop(second)
    sumsecond[i] = sumsecond[i+1]+k

res = sumfirst[0]-sumsecond[0]
for i in range(n+1):
    res = max(res, sumfirst[i]-sumsecond[i])
print(res)

Measured memory_bytes: 39260
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
/*======================================================================*/
int main()
{
  /*
	ios_base::sync_with_stdio(0);
	cin(tie);
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  int a,b;
  cin>>a>>b;
  if(a>=10||b>=10)
  {
  	cout<<-1<<endl;
  	return 0;
  }
  cout<<a*b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    printf("%d\n", min(b/a, c));
}

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

using ll = long long;

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

    ll a,b,c;cin>>a>>b>>c;

    ll f=4*a*b;

    ll d=c-a-b;

    bool ans=d>0&&d*d>f;

    puts(ans?"Yes":"No");

    return 0;
}


Measured memory_bytes: 3656
#define _GLIBCXX_DEBUG

#include"bits/stdc++.h"
using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

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

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

////////////////////

void Main() {
    //code here
    int n = gi;
    vec<vec<int>> days;
    REP(i,n) days.add(gim(3));

    vec<vec<int>> dp;
    REP(i,n) dp.add({0,0,0});
    dp[0] = days[0];

    OneToN(i, n-1) {
        //print(i);
        dp[i][0] = days[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = days[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = days[i][2] + max(dp[i-1][0], dp[i-1][1]);
    }
    print(*max_element(ALL(dp[n-1])));
}

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


Measured memory_bytes: 23212
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto L = RD;
	auto S = new string[](N);
	foreach (i; 0..N)
		S[i] = RD!string;
	S.sort();
	
	writeln(S.join);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	string a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)
		cout<<a[i];
	cout<<endl;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    double x,t;cin>>x>>t;
    cout<<x/t<<endl;

    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

const int M=30000;
int n;

int a[M],A,b[M],B,c[M],C;
int main(){
#ifdef flukehn
	freopen("g.in","r",stdin);
#endif
	cin>>n;
	if(n==3)puts("2 5 63");
	else if(n==4)puts("2 5 20 63");
	if(n<=4)return 0;
	n-=5;
	printf("2 3 4 6 9 ");
	a[++A]=8;
	int i,m,t,x,y;
	for(i=10;i<=M;++i)
		if(i%6==0)c[++C]=i;
		else if(i%2==0)a[++A]=i;
		else if(i%3==0)b[++B]=i;
	m=min(n,C);
	if((n-m)%2)--m;
	for(i=1;i<=m;++i)
		printf("%d ",c[i]);
	if(!(n-=m))return 0;
	x=min(A,n),n-=x;
	for(i=1;i<=x;++i)
		printf("%d ",a[i]);
	for(i=1;i<=n;++i)
		printf("%d ",b[i]);
}

Measured memory_bytes: 384
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    if n % 2:
        print(2 * n)
    else:
        print(n)
    return

#B
def B():
    n = II()
    a = LI()
    a.sort()
    print(a[n-1]-a[0])
    return

#C
def C():
    return

# D
# 解説AC
# BCDEのC,Dの仕切り位置を右に移動させていくと
# B,CとD,Eの仕切り位置について右にしか移動しないこと
# がわかれば終わりだった。
# わかりたい
def D():
    n = II()
    a = LI()
    for i in range(n - 1):
        a[i + 1] += a[i]
    l, r = 0, 0
    ans = inf
    for center in range(1, n - 2):
        r = max(r, center + 1)
        while center - l > 1:
            if abs(a[center] - 2 * a[l]) > abs(a[center] - 2 * a[l + 1]):
                l += 1
            else:
                break
        while n - 1 - r > 1:
            if abs(a[n - 1] - a[r] - (a[r] - a[center])) > abs(a[n - 1] - a[r + 1] - (a[r + 1] - a[center])):
                r += 1
            else:
                break
        b = a[l]
        c = a[center] - a[l]
        d = a[r] - a[center]
        e = a[n - 1] - a[r]
        ans = min(ans, max(b, c, d, e) - min(b, c, d, e))
    print(ans)

        
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 85892
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  if(a+b == 15) cout << "+" << endl;
  else if(a*b == 15) cout << "*" << endl;
  else cout << "x" << endl;

  return 0;
}

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int x, y;
  cin >> x >> y;
  int ans = abs(abs(x) - abs(y));
  int sx = (x > 0) - (x < 0);
  int sy = (y > 0) - (y < 0);
  if (sx == sy && x > y) {
    ans += 2;
  } else if (!y && x > 0 || !x && y < 0) {
    ++ans;
  } else if (x < 0 && y > 0 || x > 0 && y < 0) {
    ++ans;
  }
  cout << ans << endl;
  return 0;
}



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

int main()
{
  int n,sum,ans;
  cin>>n;
  ans=1000000;
  vector<int> address(n);
  for(int i=0;i<n;i++)
  {
    cin>>address.at(i);
  }
  for(int i=1;i<=100;i++)
  {
    sum=0;
    for(int j=0;j<n;j++)
    {
      sum+=((address.at(j)-i)*(address.at(j)-i));
    }
    if(sum<ans)
    {
      ans=sum;
    }
  }
  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 k = 0;
		int s = 0;
		int l = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(a % c == 0) k = a / c;
		else k = a / c + 1;
		if(b % d == 0) s = b / d;
		else s = b / d + 1;
		if(k >= s) System.out.println(l - k);
		else System.out.println(l - s);
	}
}

Measured memory_bytes: 26000
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            int x = sc.nextInt();

            if(n == 0 && x == 0)break;
            int answer = 0;
            for(int i=1;i<=n;i++){
                for(int j=i+1;j<=n;j++){
                    for(int k=j+1;k<=n;k++){
                        if(i+j+k == x)answer++;
                    }
                }
            }
            System.out.println(answer);
        }
    }
}


Measured memory_bytes: 26572
# coding: utf-8
# Here your code !

import math

def func():
    try:
        line = input().rstrip()
        r = float(line)
    except:
        print("input error")
        return -1
        
    print("{0:f} {1:f}".format(r**2*math.pi,2*r*math.pi))

func()
    

Measured memory_bytes: 7548
#include<bits/stdc++.h>
using namespace std;
int N,a,b,c,d;
char str[200003];
int main(void){
    cin >> N >> a >> b >> c >> d >> str;
    a--;
    b--;
    c--;
    d--;
    if (str[c]=='#' || str[d]=='#'){
        cout << "No" << endl;
        return 0;
    } 
    for (int i=a+1;i<c;i++){
        if (str[i]=='#' && str[i+1]=='#'){
            cout << "No" << endl;
            return 0;
        }
    }
    for (int i=b+1;i<d;i++){
        if (str[i]=='#' && str[i+1]=='#'){
            cout << "No" << endl;
            return 0;
        }   
    }
    if (d==c){
        cout << "No" << endl;
        return 0;
    }
    if (d>c){
        cout << "Yes" << endl;
    }else{
        bool mk=false;
        for (int i=b;i<=d;i++){
            if (str[i-1]=='.'&&str[i]=='.'&&str[i+1]=='.'){
                mk=true;
                break;
            }
        }
        if (mk){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//typedef long long ll;
int main(void)
{
  int n,m,x,ans=0;
  scanf("%d%d%d",&n,&m,&x);
  int c[n],a[n][m],tmp[m];
  for(int i=0;i<n;i++){
    scanf("%d",&c[i]);
    for(int j=0;j<m;j++) scanf("%d",&a[i][j]);
  }
  for(int i=0;i<m;i++) tmp[i]=0;
  int i=0,flag=0,tmp1=0,tmp2=0;
  //i=i>>3;
  while(((i>>n)&1)!=1){
    for(int j=0;j<n;j++){
      if(((i>>j)&1)==1){
        for(int u=0;u<m;u++){
          tmp[u]+=a[j][u];
        }
        tmp1+=c[j];
      }
    }
    for(int j=0;j<m;j++){
      if(tmp[j]<x) flag=1;
      tmp[j]=0;
    }
    if(flag==0)
      if((tmp2>tmp1)||(tmp2==0)) tmp2=tmp1;
    tmp1=0;
    flag=0;
    i++;
  }
  if(tmp2>0) printf("%d",tmp2); 
  else printf("-1"); 
  return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>

int N, W;
int max = 0;
long long int wv[102][2];
long long int x[102][100004];

long long int getWeight(int i, int v) {
	if (v == 0)
		return 0;
	if (i >= N || v < 0)
		return 1000000004;
	if (x[i][v] != 0)
		return x[i][v];
	long long a = getWeight(i + 1, v);
	long long b = getWeight(i + 1, v - wv[i][1]) + wv[i][0];
	x[i][v] = a < b ? a : b;
	return x[i][v];
}

int getBest() {
	int z;
	for (long long int i = max; i >= 0; i--) {
		z = getWeight(0, i);
		if (z <= W && z > 0)
			return i;
	}
	return 0;
}

int main()
{
	scanf("%d %d", &N, &W);
	for (int i = 0; i < N; i++) {
		scanf("%d %d", &wv[i][0], &wv[i][1]);
		max += wv[i][1];
	}

	printf("%d", getBest());
}

Measured memory_bytes: 78080
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-11;
const int mod=1000000007;
typedef long long ll;
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,m,q,l,r,u,d;
string s,t;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m>>q;
	int x,y;cin>>x>>y;l=r=y;u=d=x;
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		if(s[i]=='L'){
			if(l==1)return puts("NO")&0;
			l--;
		}
		if(s[i]=='R'){
			if(r==m)return puts("NO")&0;
			r++;
		}
		if(s[i]=='D'){
			if(d==n)return puts("NO")&0;
			d++;
		}
		if(s[i]=='U'){
			if(u==1)return puts("NO")&0;
			u--;
		}
		if(t[i]=='L'){
			if(r>1)r--;
		}
		if(t[i]=='R'){
			if(l<m)l++;
		}
		if(t[i]=='U'){
			if(d>1)d--;
		}
		if(t[i]=='D'){
			if(u<n)u++;
		}
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 920
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n;
vp reds, blues;
vvi cands;

int main()
{
    cin >> n;
    rep(i, n){ int a, b; cin >> a >> b; reds.pb(mp(a, b)); }
    rep(i, n){ int a, b; cin >> a >> b; blues.pb(mp(a, b)); }
    vi unmatchedBlue; rep(i, n) unmatchedBlue.pb(i);
    vi unmatchedRed; rep(i, n) unmatchedRed.pb(i);

    int ans = 0;

    while(1){
        int mnB = INF; int mnpB = -1;
        for(int i: unmatchedBlue){
            if(mnB > blues[i].fi){ mnB = blues[i].fi; mnpB = i; }
        }
        if(mnpB == -1) break;
        unmatchedBlue.erase(find(all(unmatchedBlue), mnpB));

        int mxR = -1010; int mxpR = -1;
        for(int i: unmatchedRed){
            if(reds[i].se > blues[mnpB].se || reds[i].fi > blues[mnpB].fi) continue;
            if(mxR < reds[i].se) { mxR = reds[i].se; mxpR = i; }
        }
        if(mxpR != -1) {
            unmatchedRed.erase(find(all(unmatchedRed), mxpR));
            ans++;
        }
    }
    cout << ans << endl;

    return 0;

}


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

using namespace std;
#define pb push_back
#define db(x) //cerr << #x << " = " << x << endl;
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<pii>
#define ll long long
#define ull unsigned long long
typedef long double ld;

#define MAXN 112
#define MAXK 112345

const int MOD = 1e9+7;

int n, k;
int a[MAXN];
int vis[MAXN][MAXK];
ll dp[MAXN][MAXK];
ll prefix[MAXN][MAXK];

ll sub_mod(ll a, ll b)
{
    return ((a % MOD) - (b % MOD) + MOD) % MOD;
}

ll add_mod(ll a, ll b)
{
    return ((a % MOD) + (b % MOD)) % MOD;
}

ll get_prefix(int i, int l, int r)
{
    ll res = prefix[i][min(r, MAXK - 1)];
    if (l > 0)
        res = sub_mod(res, prefix[i][l - 1]);
    return res;
}

void solve(int idx)
{
    if (idx == n)
    {
        for (int i = k; i < MAXK; i++)
        {
            prefix[idx][i] = 1;
        }
        return;
    }

    solve(idx + 1);
    for (int i = 0; i < MAXK; i++)
    {
        dp[idx][i] = get_prefix(idx + 1, i, i + a[idx]);
    }

    //prefix
    db(idx);
    prefix[idx][0] = dp[idx][0];
   // printf("%d ", prefix[idx][0]);
    for (int i = 1; i < MAXK; i++)
    {
        prefix[idx][i] = add_mod(prefix[idx][i - 1], dp[idx][i]);
        //printf("%d ", prefix[idx][i]);
    }
   // printf("\n");
    
}

int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    
    solve(0);
    printf("%lld\n", dp[0][0]);
    
}

Measured memory_bytes: 178432
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <deque>
using namespace std;

int main() {
    //input
    int n; cin >> n;
    long tm = 0;
  	vector<int> a(n + 2,0);
  	for(int i = 1; i < n + 1; i++) cin >> a[i]; 

    vector<int> m(n + 1,0);
    for(int i = 0; i < n + 1; i++){
       m[i] = abs(a[i + 1] - a[i]);
       tm += m[i];
    } 

    //output
    for(int i = 1; i < n + 1;i++){
        cout << tm - m[i - 1] - m[i] + abs(a[i + 1] - a[i - 1]) << endl;
    }
}

Measured memory_bytes: 4008
#include<iostream>
#include<cstdlib>

#include<cmath>
#include<map>
#include<string>
#include<vector>
#include<algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;
# define rep(n,i) for(i = 0 ; i < n ; i++)

int main()
{
    char s1[101],s2[101],s3[101];cin >> s1 >> s2 >>s3;
    int ia=0,ib=0,ic=0;

    char next='a';
    char tmp;
    while(1){
        if(next=='a') tmp=s1[ia++];
        if(next=='b') tmp=s2[ib++];
        if(next=='c') tmp=s3[ic++];
        if(!tmp) {
            cout << (char)(next-0x20) << endl;
            return 0;
        } else {
            next = tmp;
        }
    }
}

Measured memory_bytes: 256