akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define DEBUG
#ifdef DEBUG
    #define IFD(...) __VA_ARGS__
    #define IFN(...)
    #define L cout<<__LINE__<<"\n";
    #define PRINT(...) __VA_ARGS__ cout<<__LINE__<" : "<<#__VA_ARGS__<<"\n"
    #define PRT(x) cout<<__LINE__<<" : "<<#x<<" = "<<x<<"\n"
#else // DEBUG
    #define IFD(...)
    #define IFN(...) __VA_ARGS__
    #define L
    #define PRINT(...) __VA_ARGS__
    #define PRT(x)
#endif // DEBUG

#define it iterator
#define rit reverse_iterator
#define mp make_pair
#define mems(a,b) memset(a,b,sizeof(a))
#define mem0(a) mems(a,0)
#define mem1(a) mems(a,1)
#define mem255(a) mems(a,255)
#define halt exit(0)
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front
#define fort0(i,a,b) for(ll i=a,i##_TO=b;i<i##_TO;i++)
#define for0(i,n) fort0(i,0,n)
#define fort1(i,a,b) for(ll i=a,i##_TO=b;i<=i##_TO;i++)
#define for1(i,n) fort1(i,1,n)
#define ford(i,a,b) for(ll i=a,i##_TO=b;i>=i##_TO;i--)

using namespace __gnu_pbds;
using namespace std;

#define int ll

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

signed main()
{
  string s;
  int k;
  cin>>s>>k;
  //assert(s.size()<=50);
  set<string> ss;
  for(int i=0;i<s.size();i++)
    for(int j=1;j<=min<int>(k,s.size()-i);j++)
      ss.insert(s.substr(i,j));
  k--;
  while(k--)
    ss.erase(ss.begin());
  cout<<*ss.begin();
}


Measured memory_bytes: 1664
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b;
	cout<<(a+b+1)/2;
	return 0;
}


Measured memory_bytes: 256
n,a = map(int,input().split())
x = list(map(int,input().split()))
x= sorted(x)
sho = sum(x)//a
dp = [[[[0]*(sho+1) for _ in range(a)]for _ in range(n+1)] for _ in range(n+1)]
#dp[i枚目まで選ぶ][選んだ枚数][aで割ったときの余り][aで割った商]=通り数

dp[0][0][0][0]=1 #何も選ばない

for i in range(0,n):
  j = x[i]%a
  kuwaeru = x[i]//a
  num = 0
  while num<=i:
    for k in range(a):
      for l in range(sho+1):
        if k+j<a and l+kuwaeru <= sho:
          dp[i+1][num+1][(k+j)%a][l+kuwaeru] += dp[i][num][k][l]  #i番目のカードを選ぶ
        elif k+j>=a and l+kuwaeru+1 <= sho:
          dp[i+1][num+1][(k+j)%a][l+kuwaeru+1] += dp[i][num][k][l]  #i番目のカードを選ぶ
  
        dp[i+1][num][k][l] += dp[i][num][k][l]  #i番目のカードを選ばない
    num +=1

ans = 0
for i in range(1,min(sho+1,n+1)):
  ans +=  dp[n][i][0][i]
print(ans)

Measured memory_bytes: 105436
def solve(n, a):
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            ans = max(ans, abs(a[i]-a[j]))
    return ans

assert solve(4, [1,4,6,3]) == 5
assert solve(2, [1000000000, 1]) == 999999999
assert solve(5, [1, 1, 1, 1, 1]) == 0

n = input()
a = map(int, raw_input().split())
print solve(n, a)



Measured memory_bytes: 2568
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
const int N = 2e5+5,mod = 1e9+7;
it add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
it mul(int x,int y){return 1ll*x*y%mod;}
il inc(int &x,int y){x=add(x,y);}
int n,u,v,dp[N],ans[N],sz[N],fac[N],ifac[N];
vector<int> G[N];
il DFS1(int u,int fa){
	dp[u]=1,sz[u]=1;
	for(auto v:G[u]){
		if(v==fa) continue;
		DFS1(v,u),dp[u]=mul(dp[u],dp[v]);
		sz[u]+=sz[v],dp[u]=mul(dp[u],ifac[sz[v]]);
	}
	dp[u]=mul(dp[u],fac[sz[u]-1]);
}
il DFS2(int u,int fa){
	ans[u]=dp[u];
	for(auto v:G[u]){
		if(v==fa) continue;
		int tu=dp[u];
		dp[u]=mul(dp[u],ifac[n-1]);
		dp[u]=mul(dp[u],qpow(dp[v],mod-2,mod));
		dp[u]=mul(dp[u],fac[sz[v]]);
		dp[u]=mul(dp[u],fac[n-sz[v]-1]);
		
		dp[v]=mul(dp[v],ifac[sz[v]-1]);
		dp[v]=mul(dp[v],dp[u]);
		dp[v]=mul(dp[v],ifac[n-sz[v]]);
		dp[v]=mul(dp[v],fac[n-1]);
		DFS2(v,u),dp[u]=tu;
	}
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),fac[0]=1;
	for(ri i=1;i<n;++i){
		read(u),read(v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(ri i=1;i<=n;++i) fac[i]=mul(fac[i-1],i);
	ifac[n]=qpow(fac[n],mod-2,mod);
	for(ri i=n-1;i>=0;--i) ifac[i]=mul(ifac[i+1],i+1);
	DFS1(1,0),DFS2(1,0);
	for(ri i=1;i<=n;++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 17780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
signed main(){
  ll ans=0;
  ll w,h;
  vector<ll> p,q;
  p.push_back(0);
  q.push_back(0);
  cin>>w>>h;
  for(int i=0;i<w;i++){
    ll x;
    cin>>x;
    p.push_back(x);
    ans+=x;
  }
  for(int i=0;i<h;i++){
    ll y;
    cin>>y;
    q.push_back(y);
    ans+=y;
  }
  vector<ll> rsum;
  rsum.push_back(0);
  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  for(int i=1;i<=w;i++) rsum.push_back(rsum[i-1]+p[i]);
  p.push_back(174417441744);
  for(int i=1;i<=h;i++){
    ll pos=lower_bound(p.begin(),p.end(),q[i])-p.begin();
    pos--;
    ll use_q=w-pos;
    ans+=rsum[pos]+(q[i]*use_q);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
    int a,s,d;
	cin>>a>>s>>d;
    cout<<d<<" "<<a<<" "<<s<<endl;
}


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

import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			String[] line = input.readLine().split(" ");
			String lb = System.getProperty("line.separator");
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);
			double c = toRadians(Integer.parseInt(line[2]));
			
			double area = (a * b * sin(c)) / 2;
			double perimeter = a + b + pow(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(c), 0.5);
			double height = b * sin(c);
			
			System.out.println(new StringBuilder().append(String.valueOf(area)).append(lb).append(String.valueOf(perimeter)).append(lb).append(String.valueOf(height)).toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int sum = 0;
    int A[5];
    for(int i = 0; i < 5; i++){
        int p; scanf("%d", &p);
        sum += p; A[i] = (10-p%10)%10;
    }
    sort(A, A+5);
    for(int i = 0; i < 4; i++)
        sum += A[i];
    printf("%d\n", sum);
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}



Measured memory_bytes: 764
n = int(input())
rate = [int(input()) for _ in range(n)]
maxProfit = rate[1] - rate[0]
minRate = rate[0]  # 最小レートを記録
maxRate = rate[0]  # 最小レート更新後の最大レートを記録
for i in range(1, n):
    # 最小レートを更新したらそれ以降の最大レートとの最大利益と前の最大利益を比べる
    if rate[i] < minRate:
        minRate = rate[i]
        maxRate = rate[i]
    elif rate[i] >= maxRate and rate[i] - minRate > maxProfit:
        maxProfit = rate[i] - minRate
print(maxProfit)



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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n,k,x;
    cin >> n;
    map<string,ll> mp;
    string s;
    for(ll i=0;i<n;i++){
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ret=0;
    for(auto& x:mp){
        ret+=x.second*(x.second-1)/2;
    }
    cout << ret << endl;
    return 0;
}

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

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

} // namespace null_null

#include <string>

namespace null_null {

void main_() {
  std::string S;
  std::cin>>S;

  if(S[0]=='S'){
    std::cout<<"Cloudy"<<std::endl;
  }else if(S[0]=='C'){
    std::cout<<"Rainy"<<std::endl;
  }else{
    std::cout<<"Sunny"<<std::endl;
  }
}

} // namespace null_null

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  null_null::main_();
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 805
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int H,W,K;
char str[MAXN][MAXN];
int d[MAXN][MAXN];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
int get_up(int x)
{
    return (x+K-1)/K;
}
int find_ans(int x,int y)
{
    int ret=INF;
    ret=min(ret,get_up(x-1));
    ret=min(ret,get_up(H-x));
    ret=min(ret,get_up(W-y));
    ret=min(ret,get_up(y-1));
    return ret;
}
int main()
{
    scanf("%d%d%d",&H,&W,&K);
    for(int i=1;i<=H;i++) scanf("%s",str[i]+1);
    int x=0,y=0;
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
        {
            if(str[i][j]=='S')
            {
                x=i;y=j;
                break;
            }
        }
    for(int i=1;i<=H;i++) for(int j=1;j<=W;j++) d[i][j]=INF;
    queue<P> que;
    que.push(P(x,y)); d[x][y]=0;
    while(que.size())
    {
        P p=que.front(); que.pop();
        int x=p.F,y=p.S;
        if(d[x][y]==K) continue;
        for(int i=0;i<4;i++)
        {
            int nx=x+dx[i],ny=y+dy[i];
            if(nx>=1&&nx<=H&&ny>=1&&ny<=W&&d[nx][ny]>d[x][y]+1&&str[nx][ny]!='#')
            {
                d[nx][ny]=d[x][y]+1;
                que.push(P(nx,ny));
            }
        }
    }
    int ans=INF;
    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
            if(d[i][j]!=INF)
                ans=min(ans,1+find_ans(i,j));
    printf("%d\n",ans);
    return 0;
}



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

typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N];

string X[4] = {"dream", "dreamer", "erase","eraser"};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  string s; cin >> s;
  
  int n = s.length();
  vector<int> A(n+10,0);
  A[n] = 1;
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<4;j++){
      if(A[i+X[j].length()] && s.substr(i,X[j].length()) == X[j]){
        A[i] = true;
        break;
      }
    }
  }

  cout << (A[0] ? "YES" : "NO") << endl;
  
  return 0;
}


Measured memory_bytes: 848
#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;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int a[110];

  for(int i=0;i<110;i++){
    a[i]=0;
  }

  for(int i=2;i<=N;i++){
    int m=i,l=2;
      while(m>1){
        if(m%l==0){
          a[l]++;
          m/=l;
        }else{
          l++;
        }
      }
  }

  int p=0,q=0,r=0,s=0,t=0;
  for(int i=0;i<110;i++){
      if(a[i]>=74) p++;
      if(a[i]>=24) q++;
      if(a[i]>=14) r++;
      if(a[i]>=4) s++;
      if(a[i]>=2) t++;
  }
  int ans=p+q*(t-1)+r*(s-1)+s*(s-1)/2*(t-2);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    ll int n,m,res=0,a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;

}



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

int main(){
    char a,b;
    cin >> a >> b;
    if(a == b) cout << "H" << endl;
    else cout << "D" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i,0,n)
#define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define BREP(bit,n) BFOR(bit,0,n)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector<int> a(100001);
  
  REP(i,n){
    int b;
    cin >> b;
    if(b > 100000) ans++;
    else a[b]++;
  }
  
  REP(i,100001){
    if(a[i] != 0){
      if(a[i] != i){
        if(a[i] > i) ans += a[i]-i;
        else ans += a[i];
      }
    }
  }
  
  cout << ans << endl;

}

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

#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl; 
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
#define mod 1000000007
#define MAX LLONG_MAX
 
ll dp[405][405];

vector<ll> A;
ll min(ll a,ll b){
    a=a<b?a:b;
    return a;
}

ll solve(){
    ll n=A.size();

   for(int d = 1;d<n;d++){
        ll i = 0,j=d;
        while(j<n){
            ll ans = MAX;
            for(int k = i;k<j;k++){ 

                ans = min(ans,dp[i][k]+dp[k+1][j]+(A[j]-(i>0?A[i-1]:0)));
            }
            dp[i][j] = ans;
            i++;j++;
        }
    }
    return dp[0][n-1];
}
int main(){
    memset(dp,0,sizeof dp);
	fastIO;
	
	ll n;
	cin>>n;
	
	for (ll i = 0; i < n; ++i)
	{
        int tmp;
        cin>>tmp;
        if(i!=0)
		 A.pb(tmp+A[i-1]);
        else
         A.pb(tmp);
	}
	cout<<solve() << '\n';
	return 0;
}

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

int main(){
  int n,score[100],i,sum,k=1;
  int max,min;

  while(k<=20){
    sum=0;
    max=0;
    min=1000;
    
    cin >> n;
    if(n==0)break;
    for(i=0;i<n;i++){
      cin >> score[i];
      if(max<score[i])max=score[i];
      if(score[i]<min)min=score[i];
      sum+=score[i];
    }
    sum-=(max+min);
    n-=2;
    cout<<(sum/n)<<endl;
    k++;
  }
  return 0;
}


Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main(){
 ll t=1;
 //cin>>t;
 while(t--){
ll a;
string s;
cin>>a>>s;
if(a<3200){
    cout<<"red";
}
else{
    cout<<s<<endl;
}
 }
}


Measured memory_bytes: 256
using System;
using System.Threading;

namespace ABC088
{
    /// <summary>
    /// A - Infinite Coins
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());

            float rslt = N % 500;

            if (rslt - A <= 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27532
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
int n;
int ans = 0;
void dfs(int x){
    if(x > n)return;
    int tmp = x;
    map<int,int> mp;
    mp[3] = 0;mp[5] = 0;mp[7] = 0;
    while(tmp > 0){
        mp[tmp%10]++;
        tmp /= 10;
    }
    if(mp[3]*mp[5]*mp[7])ans++;
    dfs(x*10+3);
    dfs(x*10+5);
    dfs(x*10+7);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n; dfs(3);dfs(5);dfs(7);
    ANS;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

		// define variables & initialize
	private static int cnt = 0;	// how many bubbleSort is used
	
	// sort method :: sort given array using insertion Sort
	public static void sort(int[] _A, int _n) {
		for (int i = 0; i <= _n - 1; ++i) {
			int p_min = i;
			for (int j = i; j <= _n - 1; ++j) {
				if (_A[j] < _A[p_min])
					p_min = j;
			}
			if (i != p_min) {
				_A[i] = _A[i] ^ _A[p_min];
				_A[p_min] = _A[i] ^ _A[p_min];
				_A[i] = _A[i] ^ _A[p_min];
				++cnt;
			}
		}
		
	}
	
	// print method :: print array
	public static void print(int[] _A) {
		for (int i = 0; i < _A.length; ++i) {
			System.out.print(_A[i]);
			if (i != _A.length - 1)
				System.out.print(" ");
		}
		System.out.println();
	}
	
	// get method :: get cnt (how many bubbleSort was used)
	public static int get() {
		return cnt;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		////////////////////////////////////
		int n = 0;
		int[] A;
		
		n = sc.nextInt();
		A = new int[n];
		
		for (int i = 0; i < n; ++i) {
			A[i] = sc.nextInt();
		}
		
		sort(A, n);
		print(A);
		System.out.println(get());
		
		////////////////////////////////////
		sc.close();
	}
	
}

Measured memory_bytes: 26332
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DHarlequin solver = new DHarlequin();
        solver.solve(1, in, out);
        out.close();
    }

    static class DHarlequin {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] a = in.ints(n);
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 == 1) {
                    out.println("first");
                    return;
                }
            }
            out.println("second");
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



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

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

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

int main(){

    int k, n, i, length0, length1, length1_buf, ans;

    length0 = 0;
    length1 = 0;
    ans = k;

    cin >> k >> n;

    int a[n];

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

    for (i=1; i<n; i++){

        length1_buf = a[i] - a[i-1];

        if (length1 <= length1_buf){
            length1 = length1_buf;
        }
    }

    length1_buf = a[n-1] - a[0];

    if (k/2 < length1_buf){
        length1_buf = k - length1_buf;
    }

    if (length1 <= length1_buf){
        length1 = length1_buf;
    }

    cout << k - length1 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll n;
  cin >> n;

  int maxv = 10000001;
  vector<ll> div(maxv, 0);
  rep(i, 1, maxv) {
    for (ll j = 1; i * j < maxv; j++) {
      div[i * j]++;
    }
  }

  ll ans = 0;

  rep(i,1,n+1){
    ans += div[i] * i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 81300
a=input()
b=input()

def fn(a,b):
	if len(a)+1!=len(b):
		return 0
	else:
		for i in zip(a,b[:-1]):
			if i[0]!=i[1]:
				return 0
	return 1
if fn(a,b)==0:
	print("No")
else:
	print("Yes")

Measured memory_bytes: 8984
n = int(input())

a_list = []
for _ in range(n):
    a = int(input())
    a_list.append(a)
b_list = sorted(a_list, reverse=True)

for a in a_list:
    ans = b_list[0] if a != b_list[0] else b_list[1]
    print(ans)

Measured memory_bytes: 14112
fun main() {
    val mod = 1e9.toLong() + 7
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    var ans = 0L
    for (i in k..n + 1L) {
        val min = i * (i - 1) / 2
        val max = i * (n + n - i + 1) / 2
        ans += max - min + 1
        ans %= mod
    }
    println(ans)
}


Measured memory_bytes: 36480
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
#define REP(i,n) for(li i=0;i<(li)(n);i++)
typedef int64_t li;
const li VMAX = 4096, INF = 1000000000;
typedef pair<li, li> P;
typedef pair<P, li> Tuple;

struct edge { li to, cap, cost, rev; };

vector<edge> G[VMAX];
li dist[VMAX];
li prevv[VMAX], preve[VMAX];
li V;

void init() {
  REP(i, V) {
    G[i].clear();
    dist[i] = INF;
    prevv[i] = preve[i] = 0;
  }
}

Tuple T(li begin, li end, li cost) {
  return Tuple(P(begin, end), -cost);
}

void add_edge(li from, li to, li cap, li cost) {
  G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
  G[to].push_back((edge){from, 0, -cost, (int)G[from].size() - 1});
}

li min_cost_flow(li s, li t, li f) {
  li res = 0;
  while (f > 0) {
    fill(dist, dist + V, INF) ;
    dist[s] = 0;
    bool update = true;

    while (update) {
      update = false;
      REP(v, V) {
        if (dist[v] == INF) continue;
        REP(i, G[v].size()) {
          edge &e = G[v][i];
          if (e.cap > 0 and dist[e.to] > dist[v] + e.cost) {
            dist[e.to] = dist[v] + e.cost;
            prevv[e.to] = v;
            preve[e.to] = i;
            update = true;
          }
        }
      }
    }

    if (dist[t] == INF) {
      return -1;
    }

    li d = f;
    for (li v = t; v != s; v = prevv[v]) {
      d = min(d, G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d * dist[t];
    for (li v = t; v != s; v = prevv[v]) {
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap  += d;
    }
  }
  return res;
}

int main() {
  li n;
  while (cin >> n and n) {
    V = 2 * n + 3;
    init();
    vector<Tuple> events;
    REP(k, n) {
      li i, j, w;
      cin >> i >> j >> w;
      events.push_back(T(i, j, w));
    }

    const int SOURCE = 0, SINK = 2, BEGIN = 1;

    add_edge(SOURCE, BEGIN, 2, 0);
    add_edge(BEGIN, SINK, 2, 0);
    
    REP(i, events.size()) {
      add_edge(BEGIN, 2 * i + 3, 1, 0);
      add_edge(2 * i + 4, SINK, 1, 0);
      add_edge(2 * i + 3, 2 * i + 4, 1, events[i].second);
    }

    REP(i, events.size()) {
      REP(j, events.size()) {
        li end = events[i].first.second;
        li begin = events[j].first.first;
        if (end < begin) {
          add_edge(2 * i + 4, 2 * j + 3, 1, 0);
        }
      }
    }


    li min = -min_cost_flow(SOURCE, SINK, 2);
    cout << min << endl;
  }
}

Measured memory_bytes: 44032
D,G = map(int,input().split()) #Gは達成すべきスコア。Dは100D点問題まであるって事を示す。
L = []
minimum = 0 #解くべき最低問題数
candidate = 0 #あるループで解いた問題数
score = 0
for _ in range(D):
    p,c = map(int,input().split())
    L.append([p,c]) #k個目の問題はpk個あって、全部正解するとc点もらえる。
#2 700
#3 500
#5 800の場合：[[3, 500], [5, 800]]を得る。
#方針：全部ACの線で問題探して行って、それでダメならgreedyに全完してないやつから難易度順にACして行く。
#まず全完難易度帯を2^D通り決め打ちする。
for i in range(2**D):
    for j in range(len(L)): #list L に対応したフラグ立ってるか見る。
        if ((i>>j)& 1): #立っていれば：
            score += L[j][0] * (j+1) * 100 + L[j][1] #全完した
            candidate += L[j][0]
    if score >= G:#目標達成
        if minimum == 0:
            minimum = candidate #minimum初期化
            candidate = 0 #candidateリセット
            score = 0
        elif candidate != 0 and candidate < minimum:
            minimum = candidate #minimum更新
            candidate = 0 #リセット
            score = 0
    else: #失敗
        for j in range(len(L)-1,-1,-1):
            if ((i>>j) & 1):#立っていれば：
                continue #次の処理はしないでください。
            for k in range(L[j][0]):#全完されてない難易度を見つけた。L[j][0] = k問でリサーチ。
                score += 100*(j+1) #j問目正解
                candidate += 1
                if score >= G:
                    if minimum == 0:
                        minimum = candidate #minimum初期化
                        candidate = 0 #candidateリセット
                        score = 0
                    elif candidate != 0 and candidate < minimum:
                        minimum = candidate #minimum更新
                        candidate = 0 #リセット
                        score = 0
    candidate = 0 #リセット
    score = 0
print(minimum)

Measured memory_bytes: 3064
like = 753; s = gets; arr = []
(s.length - 3).times do |i|
		arr[i] = (s[i] + s[i+1] + s[i+2]).to_i
end
num = 0
arr.each do |i|
	if (like-i).abs < (like-num).abs
		num = i
	end
end
puts (like-num).abs



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

namespace ProconTemplate
{
    class Doing
    {
        public static void Main(string[] args)
        {
            var startUser = long.Parse(Console.ReadLine());
            var moveUser = new List<long>();
            for (int iLoop = 0; iLoop < 5; iLoop++)
            {
                moveUser.Add(long.Parse(Console.ReadLine()));
            }

            var minMoveUser = moveUser.Min();
            var maxTurn = startUser / minMoveUser;
            if (startUser % minMoveUser != 0)
            {
                maxTurn++;
            }

            Console.WriteLine(maxTurn + 4);
        }
    }
}


Measured memory_bytes: 13268
package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)
	sLength := len(S)
	mid := sLength / 2
	diffCount := 0
	for i := 0; i < mid; i++ {
		if S[i] != S[sLength-i-1] {
			diffCount++
		}
	}

	fmt.Println(diffCount)
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
    int N,M,X,Y,x[100],y[100],z;
    cin>>N>>M>>X>>Y;
    for(int i=1;i<=N;i++){
        cin>>x[i-1];
    }
    for(int i=1;i<=M;i++){
        cin>>y[i-1];
    }
    z=x[0];
    for(int i=1;i<=N-1;i++){
        if(z<x[i])z=x[i];
    }
    z++;
    if(z<=X){
        z=X+1;
    }
    if(z>Y){
        cout<<"War"<<endl;
        return 0;
    }
    for(int i=1;i<=M;i++){
        if(y[i-1]<z){
            cout<<"War"<<endl;
            return 0;
        }
    }
    cout<<"No War"<<endl;
    return 0;
}

Measured memory_bytes: 256
# ABC106D - AtCoder Express 2
from itertools import accumulate as acc


def main():
    # 2D cumulative sum
    N, M, Q, *X = map(int, open(0).read().split())
    LR, PQ = X[: 2 * M], X[2 * M :]
    rails = [[0] * (N + 1) for _ in range(N + 1)]
    for l, r in zip(*[iter(LR)] * 2):
        rails[l][r] += 1
    rails = [list(acc(a)) for a in rails]
    rails = [list(acc(a[::-1]))[::-1] for a in zip(*rails)]
    ans = []
    for p, q in zip(*[iter(PQ)] * 2):
        ans.append(rails[q][p])
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 57672
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <map>
#include<stack>
#include<fstream>

using namespace std;
const long long INF = 1LL << 60;  // どういう意味だろうか

const string write_file("");

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

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

	int K[35] = { };
	int A[35][35] = { };

	int count = 0;
	vector<int> all_menu(35, 0);

	for (int i = 0; i < N; i++) {
		cin >> K[i];

		for (int j = 0; j < K[i]; j++) {
			cin >> A[i][j];
			all_menu[A[i][j]]++;
		}
	}

	for (int i = 1; i <= (int)all_menu.size(); i++) {
		if(all_menu[i] == N){
			count++;
		}
	}

	cout << count << endl;

}


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

#define int long long

signed main() {

    int r, d, x;
    cin >> r >> d >> x;
    for ( int i = 0; i < 10; i++ ) {
        x = r*x - d;
        cout << x << endl;
    }

    return 0;
}

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

using namespace std;


int main() {
    int N; cin>>N;
    vector<double> x(N);
    vector<string> u(N);
    
    for(int i=0;i<N;i++){
        cin>>x[i]>>u[i];
        }
    double ans=0;
    for(int i=0;i<N;i++){
        if(u[i][0]=='J' && u[i][1]=='P' &&u[i][2]=='Y'){
            ans+=x[i];
        }
        else{
        ans+=x[i]*380000;
        }
        
    }
    cout << ans <<endl;
    
    
}



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

int main() {
  int H, N, P;
  cin >> H >> N;
  int sum=0;
  for (int i=0; i<N; i++) {
    cin >> P;
    sum+=P;
  }
  if (sum < H) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
  
  
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	string com;
	int key;
	list <int> va;
	for(int i=0;i<n;i++){
		cin >> com;
		if(com=="insert"){
			cin >> key;
			va.push_front(key);
		}
		if(com=="deleteLast")
			va.pop_back();
		if(com=="deleteFirst")
			va.pop_front();
		if(com=="delete"){
			cin >> key;
			for(auto itr=va.begin();itr!=va.end();itr++)
				if(*itr==key){
					va.erase(itr);
					break;
				}
		}
	}
	for(auto itr=va.begin();itr!=va.end();++itr){
		cout << *itr;
		if(itr!=--va.end())
			cout << " ";
		else
			cout << endl;
	}
	return 0;
}

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

int main() {
  double A, B;
  int H, M;
  cin >> A >> B >> H >> M;
  
  double long_, short_;
  
  long_ = H*30 + M*0.5;
  short_ = M*6;
  
  double difference;
  
  if (long_ >= short_) {
    difference = long_ - short_;
  }
  else {
    difference = short_ - long_;
  }
  
  difference = difference*M_PI/180;
  
  double x;
  
  x = A*A + B*B - 2*A*B*cos(difference);
  x = sqrt(x);
  
  cout << setprecision(30) << x << endl;
}

Measured memory_bytes: 4172
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char X,Y;cin>>X>>Y;
  cout<<(X==Y? "=":X<Y?"<":">")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i + a <= b) {
			cout << i + a << endl;
		}
	}
	for (int i = k - 1; i >= 0; i--) {
		if (b - i > a + k - 1) {
			cout << b - i<<endl;
		}
	}
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
int main()
{
    fast;
   ll t=1;
   //std::cin >> t;
   while(t--)
   {
       ll n,i,j=0;
       std::cin >> n;
       cout<<n/3<<"\n";
   }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int a,b;
#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) For(i,0,n)

#define F first
#define S second
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


int main(){
  int cnt=0;
  string s;
  cin>>s;
  rep(i,s.size()){
  if(s[i]=='R'&&(i+1)%2!=1)cnt++;
  if(s[i]=='L'&&(i+1)%2!=0)cnt++;
  }
  if(cnt==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  int N,A[2][100],Sum[100] = {0};
  cin >> N;
  for(int i=0;i<N;i++) cin >> A[0][i];
  for(int i=0;i<N;i++) cin >> A[1][i];
  for(int i=0;i<N;i++){
    for(int j=0;j<=i;j++) Sum[i] += A[0][j];
    for(int j=i;j<N;j++) Sum[i] += A[1][j];
  }
  sort(Sum,Sum + N);
  cout << Sum[N-1];
}


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

using namespace std;

#define N 200005

int len, n, ans[N], c[N], a[N], u, v, i;
vector<int> b[N];

void dfs(int u,int v)
{
	int i, x, d;
	pair<int, pair<int,int> > flag;
	
	for (i=0; i<b[u].size(); i++) {
		x=b[u][i];
		if (x!=v) {
			if (a[x]>c[len]) {
				c[++len]=a[x];
				flag=make_pair(1,make_pair(0,0));
			}
			else {
			    d=lower_bound(c+1,c+len+1,a[x])-c;
			    flag=make_pair(2,make_pair(d,c[d]));
			    c[d]=a[x];
			}
			ans[x]=len;
			dfs(x,u);
			if (flag.first==1) len--;
			else {
				c[flag.second.first]=flag.second.second;
			}
		}
	}
}

int main (void)
{
	scanf("%d",&n);
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	for (i=1; i<n; i++) {
		scanf("%d%d",&u,&v);
		b[u].push_back(v),b[v].push_back(u);
	}
	c[1]=a[1]; len=1; ans[1]=len; dfs(1,0);
	for (i=1; i<=n; i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 30516
//F5で実行 Shift+F5で停止
//F9でブレークポイント
#include<cmath>
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
//Shift+PageUpで上部の大半を選択できる
// 1e18 = 10の18乗

int N;
int d[100];
int K, M;
string S;
bool ok = false;
int ans;

//ｎ科目のテスト、ｋ点満点、目標ｍ点以上
//ｎ－１科目のテストはすでに受けて、Ai点だった。
//あと１科目のテストが何点なら、平均点がｍ点以上になるか
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> d[i];

	rep(i, 0, N) {
		rep(j, 0, i) {
			ans += d[i]*d[j];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
if x == 1 or x == (2 * n - 1):
    print("No")
    exit()

print("Yes")

r = [x - 1, x, x + 1]
tmp = list(range(1, x - 1)) + list(range(x + 2, 2 * n))

ans = tmp[n - 2:] + r + tmp[:n - 2]

for i in ans:
    print(i)


Measured memory_bytes: 15292
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    A = readInts()
    res = 0
    ans = 0
    while True:
        if res == 0:
            res += k
        else:
            res += k-1
        ans += 1
        if res >= n:
            break
    print(ans)
if __name__ == '__main__':
  main()


Measured memory_bytes: 15900
import math

N = int(input())
li = list(map(int,input().split()))

min_diff = sum(li)

for i in range(N):
    #print(li[i])
    l_sum = sum(li[:i])
    r_sum = sum(li[i:])
    #print(l_sum, r_sum)
    diff = math.fabs(l_sum - r_sum)
    if diff < min_diff:
        min_diff = int(diff)

print(min_diff)

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

int main() {
  int n; cin >>n;
  vector<ll> t(n);
  for (int i=0; i<n; i++) cin >>t.at(i);
  sort(t.begin(), t.end());
  ll time = t.at(n-1); //一番時間がかかるやつを基準にする
  ll buf;
  
  for (int i=0; i<n-1; i++){
    buf = time;
    while(true){
      if (time%t.at(i)==0) break;
      time += buf;
    }
  }
  ll ans = time;
  cout <<ans;
  cout <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define Boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void Crack() {
    long n;
    string S;
    cin >> n >> S;
    long ans=0,cnt=0,cntR=0,cntW;
    for(int i=0;i<n;i++) {
        if(i>0 && S[i]=='R' && S[i-1]=='W') cnt++;
        if(S[i]=='R') cntR++;
    }
    cntW = n-cntR;
    long c=0;
    for(int i=0;i<cntR;i++) {
        if(S[i]=='W') c++;
    }
    ans = min(c,cntR);
    ans = min(ans,cntW);
    cout << ans << endl;
}

int main()
{
    Boost;
    Crack();
    return 0;
}

Measured memory_bytes: 3760
S = input()
Q = (int)(input())

mae = ""
usiro =""

r_num=0

for i in range(Q):
    query = (input())
    if query=="1":
        #kari = mae
        #mae=usiro[::-1]
        #usiro=kari[::-1]
        r_num+=1
    else:
        query = query.split(" ")
        if query[1] == "1":
            if r_num%2==0:
                mae = query[2]+mae
            else:
                usiro += query[2]
        else:
            if r_num %2 ==0:
                usiro += query[2]
            else:
                mae = query[2]+mae
if r_num%2 == 1:
    print(usiro[::-1]+S[::-1]+mae[::-1])
else:
    print(mae+S+usiro)

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

using ll = long long;

ll a, b, n;

int main()
{
    cin >> a >> b >> n;
    ll k = (n+1)/b;
    ll ans = 0;
    ll x = k*b - 1;
    ans = max(ans, (a*x)/b - a*(x/b));
    ans = max(ans, (a*n)/b - a*(n/b));
    cout << ans << endl;
}


Measured memory_bytes: 3596
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;

int main() {

	int K;

	cin >> K;
	if (K % 2 == 0) {
		cout << pow(K / 2, 2) << endl;
	}
	else {
		cout << (K / 2)*(K / 2 + 1) << endl;
	}






	return(0);
}

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

using namespace std;

int main() {
  int p, q, r;
  cin >> p >> q >> r;

  vector<int> v;

  v.push_back(p);
  v.push_back(q);
  v.push_back(r);

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

  cout << v[0] + v[1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(void){
	int r,g,b,n,i,j,k,count,rr,g2,b2;
  	cin >> r >> g >> b >> n;
  	if(g>r){
    	swap(r,g);
    }
  	if(b>g){
    	swap(b,g);
    }
  	count = 0;
  	g2 = g;
  	b2 = b;
  	rr = g2 % b2;
  	while(rr!=0){
      g2 = b2;
      b2 = rr;
      rr = g2 % b2;
  	}
  	for(i=0;r*i<=n;i++){
           if(n< r*i){
                break; 
           }else if(n== r*i){
                count += 1;
                break;
           }
      		if((n-r*i)%b2!=0){
            	continue;
            }
            for(j=0;r*i+g*j<=n;j++){
                if(n== r*i+g*j){
                	count += 1;
                    break;
                }else if((n- (r*i+g*j))%b==0){
                	count += 1;
                }
          	}
    }
  	cout << count;
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
struct R{
	vector<int> v;
	string s;
	bool operator<(const R &a)const{
		return v<a.v;
	}
};
int main(){
	int n,t; vector<int> v(3); string s; R r;
	while(cin>>n,n){
		vector<R> vr;
		rep(i,n){
			cin>>s;
			v[0]=0,v[1]=0,v[2]=i;
			rep(j,n-1)cin>>t,t?t==1?v[1]++:0:v[0]--;
			r.v=v,r.s=s; vr.push_back(r);
		}
		sort(vr.begin(),vr.end());
		rep(i,n)cout<<vr[i].s<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int k;
char str[1000];

int main()
{
	cin >> str;
	k = strlen(str);
	int cnt = 0;
	for(int i=0; i<k; i++) cnt += (str[i]=='o');
	cnt += 15-k;
	if(cnt >= 8) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
loopNum = gets
(1..loopNum.to_i).each do |i|
	arrstr = gets
	arr =  arrstr.split
	grpA = 0
	grpB = 0
	(1..10).each do |j|
		if arr[j].to_i > grpA then
			grpA = arr[j].to_i
		elsif arr[j].to_i > grpB then
			grpB = arr[j].to_i
		elsif j == 10 then
			puts "YES"
		else
			puts "NO"
			break
		end
	end
end

Measured memory_bytes: 6100
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long N;
    cin >> N;
    for(int i = 1; i <= 3500; i++){
        for(int l = 1; l <= 3500; l++){
            double calc = (N*i*l)/(4.0*i*l-N*i-N*l);
            if(calc > 0 && calc == (int)calc){
                cout << (int)calc << " " << i << " " << l << "\n";
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256