akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
typedef long long ll;
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    for(int i=0; i<n; i++) cin >> c[i];
    sort(a.begin(), a.end()); sort(c.begin(), c.end());

    ll cnt=0;
    for(int i=0; i<n; i++) {
        cnt += distance(a.begin(), lower_bound(a.begin(), a.end(), b[i])) * 
        distance(upper_bound(c.begin(), c.end(), b[i]), c.end());
    }
    cout << cnt << endl;
    return 0;
}


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

#define rep(i,a,b) for(auto i=(a); i<(b); ++i)

const int MAXN = 3000;
const int MOD = 1000000007;
int dp[MAXN + 5];
int psum[MAXN + 5];

auto sadd(auto& a, auto b){
  a += b;
  if (a >= MOD) a -= MOD;
}

auto add(auto a, auto b){return (a + b) % MOD;}
auto sub(auto a, auto b){return (a - b + MOD) % MOD;}

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  auto sum = [&](int i, int j){return i ? sub(psum[j], psum[i - 1]) : psum[j];};

  dp[0] = 1;
  rep(i, 1, n) {
    psum[0] = dp[0];
    rep(j, 1, n + 1)
      psum[j] = add(psum[j - 1], dp[j]);
    memset(dp, 0, sizeof(dp));
    rep(j, 0, i + 1) {
      if (s[i - 1] == '<')
	sadd(dp[j], sum(0, j - 1));
      else
	sadd(dp[j], sum(j, i - 1));
    }
  }
  auto res = 0;
  rep(i, 0, n + 1)
    sadd(res, dp[i]);
  cout << res << '\n';
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int r;
    cin>>r;
    if(r<1200){
    	cout<<"ABC"<<endl;
    	return 0;
	}
	if(r>=1200&&r<2800){
		cout<<"ARC"<<endl;
		return 0;
	}
	cout<<"AGC"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;

struct node{
	long long  a,b;
	double xjb;
}x[1000001];

bool cmp(node x,node y)
{
	return x.a<y.a;
}

long long sum;

int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x[i].a,&x[i].b);
	}
	sort(x+1,x+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		if(x[i].b<m)
		{
		    sum+=x[i].a*x[i].b;	
			m-=x[i].b;		
		}
		else
		{
			sum+=x[i].a*m;
			break;
		}		
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 4352
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] a =sc.nextLine().split("");
    int count = 0;
    for (int i=0;i<a.length;i++){
        if(a[i].equals("o")){
            count=count+1;
        }
    }
    System.out.println(700+count*100);
  }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, s{}; cin >> N;
  int D[N]; for (int &d : D) cin >> d;
  for (int i{}; i < N; ++i) for (int j{i + 1}; j < N; ++j) s += D[i] * D[j];
  cout << s;}

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

int main()
{
	long long n;
	cin>>n;
	string s;
	s="1";
	n--;
	while(n)
	{
		long long k=0;
		for(long long i=s.size()-1;i>0;i--)
		{
			if(s[i]!=((s[i-1]-'0')+1)+'0'&&s[i]!='9')
			{
				k=i;
				break;
			}
		}
		if(s[k]!='9')
		{
			s[k]++;
			for(long long i=k+1;i<=s.size();i++)
			{
				if(s[i-1]=='0')
					s[i]='0';
				else
					s[i]=((s[i-1]-'0')-1)+'0';
			}
		}
		else
		{
			bool ok=true;
			for(long long i=k;i>=0;i--)
			{
				long long x=s[i]-'0';
				if(ok)
					x++;
				ok=false;
				if(x==10)
				{
					x=0;
					ok=true;
				}
				s[i]=x+'0';
				if(!ok)
					break;
			}
			for(long long i=k+1;i<=s.size();i++)
				s[i]='0';
			if(ok)
				s='1'+s;
		}
		n--;
	}
	cout<<s;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
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 P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); 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) sort(v.end(), v.begin());
#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 n;
ll a[100005] = {},b[100005] = {};
ll as = 0,bs = 0;

int main(){
    cin >> n;
    rep(i,0,n){
        cin >>a[i];
        as += a[i];
    }
    rep(i,0,n){
        cin >>b[i];
        bs += b[i];
	}

    if(bs < as){
        No;
        ret 0;
    }
    
    ll cnt = 0;
	rep(i,0,n){
        if(0 && a[i] > b[i]){
            cnt += a[i]-b[i];
        }else if(a[i] < b[i]){
            cnt += (b[i]-a[i]+1)/2;
        }
	}  
	
	if(cnt <= bs-as)Yes;
	else No;
	
	return  0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

typedef pair<int,int> P;
const int MAX = 105;
const int INF = (1<<25);
int T[MAX];
vector<P> V;
int n,m;

void input(){
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    V.push_back(P(a,b));
  }
}


void solve(){
  fill(T,T+MAX,INF);
  T[0] = 0;

  while(1){
    bool update = false;

    for(int i = 0; i < V.size(); i++){
      int now = V[i].first;
      int nex = V[i].second;
      for(int j = now+1; j <= nex; j++){
	if(T[j] > T[now]+1){
	  T[j] = T[now]+1;
	  update = true;
	}
      }

      if(T[now-1] != INF){
	for(int j = now; j <= nex; j++){
	  if(T[j] > T[now-1]+1){
	    T[j] = T[now-1]+1;
	    update = true;
	  }
	}
      }
    }

    if(!update) break;
  }

  if(T[n] == INF) cout << "Impossible" << endl;
  else cout << T[n] << endl;
}

int main(){

  input();
  solve();
  return 0;
}

Measured memory_bytes: 1200
S = input().strip()
if len(S)==1:
    print("YES")
elif len(S)==2:
    if S[0]!=S[1]:
        print("YES")
    else:
        print("NO")
elif len(S)==3:
    if S[0]!=S[1] and S[1]!=S[2] and S[2]!=S[0]:
        print("YES")
    else:
        print("NO")
else:
    C = {"a":0,"b":0,"c":0}
    for i in range(len(S)):
        C[S[i]] += 1
    if len(S)%3==0:
        if C["a"]==C["b"]==C["c"]:
            print("YES")
        else:
            print("NO")
    else:
        if max(C["a"],C["b"],C["c"])==len(S)//3+1 and min(C["a"],C["b"],C["c"])==len(S)//3:
            print("YES")
        else:
            print("NO")
        

Measured memory_bytes: 73060
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K, D = 0;
    cin >> N >> K;
    for(int i = 0; i < K; i++) {
        int dislike; cin >> dislike;
        D |= (1 << dislike);
    }
    D = ~D;
    for(int i = N; i < N*100; i++) {
        bool valid = true;
        for(int j = i; j > 0 && valid; j /= 10) {
            valid = D & (1 << (j%10));
        }
        if(valid) {
            cout << i;
            break;
        }
    }
    return 0;
}

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

int main() {
  int N;
	cin >> N;
	vector<int> height(N);
	for (int i = 0; i < N; i++) {
		cin >> height.at(i);
	}

	int CanSee = 1;

	for (int i = 1; i < N; i++) {
		bool check = true;
		for (int j = 0; j < i; j++) {
			if (height.at(i) < height.at(j)) {
				check = false;
				break;
			}
		}
		if (check) {
			CanSee++;
		}
	}
	cout << CanSee << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

ll n = 1e5+10, k;
vector<vl> g(n);
vector<ll> cnt(n);

void dfs(int i, int a, int pre = -1) {
  int cntt = 0;
  for (auto&& j : g[i]) {
    if (j != pre) {
      dfs(j, a+1, i);
      cnt[j] = min(2, a+1) + cntt;
      cntt++;
    }
  }
}

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

  cin >> n >> k;

  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    g[a-1].push_back(b-1);
    g[b-1].push_back(a-1);
  }


  dfs(0, 0);
  cnt[0] = 0;

  ll ans = 1;
  const ll mod = 1e9+7;

  rep(i, n) {
    ans = (ans * (k-cnt[i]))%mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

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



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>

using namespace std;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
string s[400];
int H,W;
long color[2];
bool list[400][400];

void dfs(int x, int y){
	char now = s[x][y];

	list[x][y] = false;

	for(int i=0;i<4;i++){
		if(x + dx[i] >= 0 && x + dx[i] < H && y + dy[i] >= 0  && y + dy[i] < W && list[x+dx[i]][y+dy[i]] && s[x+dx[i]][y+dy[i]] != now){
			if(s[x+dx[i]][y+dy[i]] == '#') color[0] += 1;
			else color[1] += 1;
			dfs(x+dx[i],y+dy[i]);
		}
	}
}

int main(void){
	cin >> H >> W;
	for(int i=0; i<H; i++){
		cin >> s[i];
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			list[i][j] = true;
		}
	}
	long ans =0;

	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(s[i][j] == '#' && list[i][j]){
				color[0] = 1;
				color[1] = 0;
				dfs(i,j);
				ans += color[0] * color[1];
			}
		}
	}

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



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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type,Name, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, k;
	cin >> n >> k;
	map<char,int> p;
	cin >> p['s'] >> p['p'] >> p['r'];
	string str; cin >> str;

	vector<bool> w(n + 1);

	int ans = 0;
	rep(i, k) {
		ans += p[str[i]];
		w[i] = true;
	}

	for (int i = k; i < n; i++) {
		if (str[i - k] == str[i] && w[i-k] == true) continue;
		ans += p[str[i]];
		w[i] = true;
	}

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


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
string s; int a, b, c, d;
int main() {
	while (cin >> s, s != "#") {
		cin >> a >> b >> c >> d; s += '/'; a--, b--, c--, d--;
		int pre = 0; vector<string> t;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '/') {
				t.push_back(s.substr(pre, i - pre));
				pre = i;
			}
		}
		vector<vector<int> > v(t.size());
		for (int i = 0; i < t.size(); i++) {
			for (int j = 0; j < t[i].size(); j++) {
				if (t[i][j] == 'b') v[i].push_back(1);
				else for (int k = 0; k < t[i][j] - 48; k++) v[i].push_back(0);
			}
		}
		v[a][b] = 0; v[c][d] = 1;
		for (int i = 0; i < v.size(); i++) {
			if (i) cout << '/';
			string ret; int pre2 = 0; v[i].push_back(-1);
			for (int j = 1; j < v[i].size(); j++) {
				if (v[i][j] != v[i][j - 1]) {
					if (v[i][j - 1] == 0) ret += (j - pre2) + 48;
					pre2 = j;
				}
				if (v[i][j - 1] == 1) ret += 'b';
			}
			cout << ret;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    local cnt = bls(1, i - 1)
    for j = 1, cnt do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.stage = {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
  end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local stagenum = self.stagenum
  local ret = self.emptyvalue
  while left <= right do
    local stage, sz = 1, bls(1, stagenum - 1)
    local len = right - left + 1
    while (left - 1) % sz ~= 0 or len < sz do
      stage, sz = stage + 1, brs(sz, 1)
    end
    ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])
    left = left + sz
  end
  return ret
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    for i = self.stagenum - 1, 1, -1 do
      local dst = brs(idx + 1, 1)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local function comp(a, b)
  return a[1] < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = mfl((min + max) / 2)
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local mod = 998244353
local function badd(x, y) return (x + y) % mod end

local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = {}
  t[i][1], t[i][2] = io.read("*n", "*n")
end
table.sort(t, function(a, b) return a[1] < b[1] end)
t[n + 1] = {3 * 1000000007, 0}

local stReach = SegTree.new(n + 1, mma, 0)
for i = 1, n + 1 do
  stReach:setValue(i, i)
end

local dp = {}
for i = 1, n + 1 do
  dp[i] = 0
end
dp[n + 1] = 1
for i = n, 1, -1 do
  local dstLen = lower_bound(t, t[i][1] + t[i][2])
  local dstPos = stReach:getRange(i, dstLen - 1)
  stReach:setValue(i, dstPos)
  dp[i] = badd(dp[dstPos + 1], dp[i + 1])
end
print(dp[1])


Measured memory_bytes: 22632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N;cin>>N;
  vector<int> vec (100001,0);
  for (int i = 0; i < N; i++)
  {
    int X; cin>>X;
    vec[X]++;
  }
  int ANS = 0;
  for (int i = 0; i < 100001-2; i++)
  {
    chmax(ANS,vec[i] +vec[i+1] + vec[i+2]);
  }
  cout<<ANS<<endl;
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 1024
"use strict";
const Main = (input) =>{
   let xs = input.trim().split('\n');
   let N = Number(xs[0].split(' ')[0]);
   let H = Number(xs[0].split(' ')[1]);
   let W = Number(xs[0].split(' ')[2]);
   let A = xs.slice(1);
   let count = 0;
   
   for(let i=0; i<N; i++){
     if(H<=Number(A[i].split(' ')[0]) && W<=Number(A[i].split(' ')[1])){
       count++
     }
   }
     console.log(count);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));




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

int main(){
  string s;
  std::cin >> s;
  int cnt=0;
  int ans=0;
  rep(i,s.size()){
    if(s[i]=='A' || s[i]== 'C' || s[i]=='G' || s[i]=='T'){
      cnt++;
    }
    else {ans=max(ans,cnt);cnt=0;}
  }
  ans=max(ans,cnt);
  std::cout << ans << '\n';
  return 0;
}


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

using namespace std;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int count = 0;
    for (int i = 0; i <= n - 3; i++) {
        if (s.substr(i, 3) == "ABC") {
            count++;
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int h, w;
  cin >> h >> w;

  vector<vector<char>> a(h, vector<char>(w));

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a.at(i).at(j);
    }
  }

  vector<bool> vh(h, false);
  vector<int> vw(w, false);

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (a.at(i).at(j) == '#') {
        vh.at(i) = true;
        vw.at(j) = true;
      }
    }
  }

  for (int i = 0; i < h; ++i) {
    bool flag = false;
    for (int j = 0; j < w; ++j) {
      if (vh.at(i) && vw.at(j)) {
        cout << a.at(i).at(j);
        flag = true;
      }
    }
    if (flag) {
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cerr << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    V<ll> a(n);
    rep(i,n) cin >> a[i];
    // if(n % 2 == 0)
    // {
    //     ll ans = 0;
    //     rep(i,2)
    //     {
    //         ll sum = 0;
    //         for(int j = i; j < n; j++) sum += a[j];
    //         chmax(ans, sum);
    //     }
    //     cout << ans << endl;
    //     return 0;
    // }
    int s = ((n % 2 == 0)? 1 : 2);

    //3つまで飛ばして選べる
    //dp[i][j][k] := i-1番目までを見て、スキップをj回使い、直前の要素を使ったときの最大値
    auto dp = make_vec(n+1, s+1, 2, -LINF);
    dp[0][0][0] = 0;
    rep(i,n) rep(j,s+1)
    {
        int ni = i+1;
        
        //直前の要素をとった
        chmax(dp[ni][j][0], dp[i][j][1]);
        //a[i]をとる
        chmax(dp[ni][j][1], dp[i][j][0] + a[i]);
        //バックレ
        if(j < s) chmax(dp[ni][j+1][0], dp[i][j][0]);
    }
    ll ans = -LINF;
    if(n%2==1) rep2(i,1,s+1) rep(j,2) chmax(ans, dp[n][i][j]);
    else rep(i,s+1) rep(j,2) chmax(ans, dp[n][i][j]);
    cout << ans << endl;
    // debug(dp);
    return 0;
}

Measured memory_bytes: 43852
n,m=map(int,input().split())
ans=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        ans[b]+=1
    if b==n:
        ans[a]+=1

bl=False
for i in range(n):
    if ans[i]>=2:
        bl=True

if bl:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 10456
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll mod = 1e9+7;

long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 1) res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}

long long mod_inv(long long a){
    return mod_pow(a, mod-2);
}

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
int n;
map<P, int> p;
vector<ll> p2;
P f(ll a, ll b){
    if(a == 0) b = 1;
    else if(b == 0) a = 1;
    else{
        ll g = gcd(abs(a), abs(b));
        a /= g;
        b /= g;
        if(b < 0){
            a *= -1;
            b *= -1;
        }
    }
    return P(a, b);
}
int main(void){
    cin >> n;
    ll ans = 1;
    ll zero = 0;
    p2.assign(n+1, 1);
    for(int i=1;i<=n;i++) p2[i] = p2[i-1]*2 % mod;

    for(int i=0;i<n;i++){
        ll a, b;
        cin >> a >> b;
        if(a == 0 && b == 0){
            zero++;
            continue;
        }
        p[f(a, b)]++;
    }
    while(!p.empty()){
        auto itr = p.begin();
        P z = itr->first;
        int x = itr->second;
        int y = 0;
        ll a = z.first;
        ll b = z.second;
        auto itr2 = p.find(f(-b, a));
        if(itr2 != p.end()){
            y = itr2->second;
            p.erase(itr2);
        }
        ans *= p2[x]+p2[y]+mod-1;
        ans %= mod;
        p.erase(itr);
    }
    ans += mod-1;
    ans += zero;

    cout << ans%mod << endl;
}


Measured memory_bytes: 16832
# -*- coding:utf-8 -*-

N, Y = map(int, input().split())
result = False

for i in range(N+1):
  if result == True:
    break
  Y_left = Y - 10000 * i
  for j in range(N-i+1):
    Y_last = Y_left - 5000 * j
    k = Y_last // 1000
    if i+j+k == N:
      result = True
      print('{} {} {}'.format(i, j, k))
      break

if result == False:
  print('-1 -1 -1')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

int yaku(int a,int b) {
	int i;
	while (a != b) {
		if (a > b) {
			if (a%b == 0) {
				return b;
			}
			i = a / b;
			a -= b * i;
		}
		else {
			if (b%a == 0) {
				return a;
			}
			i = b / a;
			b -= a * i;
		}
	}
	return a;
}

int main() {
	int n, i, j, k;
	vector<int>a, b;

	cin >> n >> j;

	a.push_back(j);
	for (i = 0; i < n; i++) {
		cin >> j;
		a.push_back(j);
	}

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

	for (i = n; i > 0; i--) {
		b.push_back(a[i] - a[i - 1]);
	}
	
	if (n == 1) {
		cout << b[0];
		return 0;
	}
	
	i = yaku(b[0], b[1]);
	for (k = 1; k < n-1; k++) {
		j = yaku(b[k], b[k + 1]);
		if (j < i)
			i = j;
	}

	cout << i;
	
	return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>

int ab(int x){
	if(x<0)return -x;
	return x;
}

int main(){
	int H,W,D;
	scanf("%d%d%d",&H,&W,&D);
	int pos[H*W+1];
	int d[H*W+1];
	
	for(int i=0;i<H*W;i++){
		int A;
		scanf("%d",&A);
		pos[A]=i;
	}
	for(int i=1;i<=H*W;i++)d[i]=0;
	for(int i=1;i<=H*W-D;i++){
		int x1=pos[i]/W,y1=pos[i]%W;
		int x2=pos[i+D]/W,y2=pos[i+D]%W;
		d[i+D]=d[i]+ab(x1-x2)+ab(y1-y2);
	}
	
	int Q;
	scanf("%d",&Q);
	int L[Q],R[Q],ans[Q];
	for(int i=0;i<Q;i++){
		scanf("%d%d",&L[i],&R[i]);
		ans[i]=d[R[i]]-d[L[i]];
	}
	for(int i=0;i<Q;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 2944
N, K = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A)

def canMake(n):
    B = [a % n for a in A]
    B.sort()

    left = 0
    right = sum(B)
    for i, b in enumerate(B, start=1):
        left += b
        right -= b
        if left == n * (N - i) - right:
            return left <= K
    return False

ans = 1
for i in range(1, int(S**0.5) + 100):
    if S % i != 0:
        continue
    k = S // i

    if canMake(i):
        ans = max(ans, i)
    if canMake(k):
        ans = max(ans, k)
        break

print(ans)


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

int main(){
  int N;
  cin >> N;
  int a[N+5];
  for(int i = 0;i<N;i++){
    cin >> a[i];
  }
  
  int num[10005] = {0};
  for(int i = 0;i<N;i++){
    num[a[i]]++;
  }
  
  int res = 0;
  for(int i = 0;i<sizeof(num)/sizeof(num[0]);i++){
    if(num[i]>0) res++;
  }
  cout << res << endl;
}

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

void _149() {
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
}

void _148() {
    int a, b;
    cin >> a;
    cin >> b;

    int c = 0;
    if ((a != 1) && (b != 1))
        c = 1;
    else if ((a != 2) && (b != 2))
        c = 2;
    else if ((a != 3) && (b != 3))
        c = 3;
    cout << c << endl;
}

void _147() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b + c >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
}

int main()
{
    _147();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;
//#define MOD 1000000007
#define MOD 998244353

class mint {
	public:
		int i;

		mint() : i(0) {}

		template<class T>
			mint(T x) {
				i = int(x % MOD);
				if (i < 0) i += MOD;
			}

		mint operator+(mint x) {
			return i + x.i;
		}

		mint operator-(mint x) {
			return i - x.i;
		}

		mint operator*(mint x) {
			return (long long)i * x.i;
		}

		mint operator/(mint x) {
			return (long long)i * x.pow(MOD - 2).i;
		}

		mint inv() {
			return pow(MOD - 2);
		}

		template<class T>
			mint pow(T p) {
				long long r = 1;
				long long t = i;
				for(; p > 0; p >>= 1) {
					if (p & 1) r = r * t % MOD;
					t = t * t % MOD;
				}
				return r;
			}

		template<class T1, class T2>
			static mint pow(T1 a, T2 b) {
				long long r = 1;
				long long t = (long long)(a % MOD);
				for(; b > 0; b >>= 1) {
					if (b & 1) r = r * t % MOD;
					t = t * t % MOD;
				}
				return r;
			}

		mint& operator+=(mint x) {
			i = (i + x.i) % MOD;
			return *this;
		}

		mint& operator-=(mint x) {
			i = i - x.i;
			if (i < 0) i += MOD;
			return *this;
		}

		mint& operator*=(mint x) {
			i = (int)((long long)i * x.i % MOD);
			return *this;
		}

		mint& operator/=(mint x) {
			i = (long long)i * x.pow(MOD - 2).i % MOD;
			return *this;
		}
};

std::ostream& operator<<(std::ostream& os, const mint& m) {
	return os << m.i;
}

int main() {	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	vector<vector<mint>> dp(c + 10, vector<mint>(d + 10));
	rep(i, a + 1) dp[i][b] = 1;
	for(int i = a + 1; i <= c; i++) {
		dp[i][b] = dp[i-1][b] * b;
	}
	rep(j, b + 1) dp[a][j] = 1;
	for(int j = b + 1; j <= d; j++) {
		dp[a][j] = dp[a][j-1] * a;
	}
	for(int i = a+1; i <= c; i++) {
		for(int j = b + 1; j <= d; j++) {
			//cout << i << " " << j << endl;
			//cout << dp[i-1][j] << dp[i][j-1] << dp[i-1][j-1] << endl;
			dp[i][j] = dp[i-1][j]*j + dp[i][j-1]*i - dp[i-1][j-1] * (i-1) * (j-1);
		}
	}
	cout << dp[c][d] << endl;

}


Measured memory_bytes: 38668
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 N, a, b;
    read(N, a, b);

    i64 ab = a + b;
    i64 ans = a * (N / ab) + min(N % ab, a);

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int num,i;
for(i=0;i<10000;i++){
scanf("%d",&num);
if(num==0)
break;
if(num<1||num>10000)
return 0;
printf("Case %d: %d\n",i+1,num);
}
return 0;
}

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

int compare(const void*,const void*);

int main(){
    int n;
    while (1) {
        scanf("%d",&n);
        if (n==0) return 0;
        long long a[n],i,count=0;
        for(i=0;i<n;i++) scanf("%lld",a+i);
        qsort(a, n, sizeof(a[0]), compare);
        for (i=0; i<n; i++) count+=a[i]*i;
        printf("%lld\n",count);
    }
}

int compare(const void* a,const void* b){
    if(*(int*)a<*(int*)b) return 1;
    else if (*(int*)a==*(int*)b) return 0;
    else return -1;
}

Measured memory_bytes: 792
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    vector<int> next(N);
    repeat(i, N) {
        cin >> next[i];
    }

    set<int> visited;
    int count = 0;
    int nextToVisit = 1;
    repeat(i, N) {
        if (nextToVisit == 2) {
            cout << count << endl;
            return 0;
        } else if (visited.find(nextToVisit) != visited.end()) {
            break;
        } else {
            count++;
            visited.insert(nextToVisit);
            nextToVisit = next[nextToVisit - 1];
        }
    }
    cout << -1 << endl;
    return 0;
}


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


int main()
{
    long long int h,n,ans,sum=0;
    cin>>h>>n;
    int a[n];
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>=h)
        cout<<"Yes";
    else
        cout<<"No";
    
    return 0;
}

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

int main(void)
{
  char c;
  std::cin >> c;

  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    std::cout << "vowel\n";
  }
  else {
    std::cout << "consonant\n";
  }

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(), (c).end()

const int N = 1000;

using Timestamp = tuple<int, int, int, int>;

Timestamp conv(const Timestamp& I, const Timestamp& O) {
    int M, D, hin, min, hout, mout;
    tie(M, D, hin, min) = I;
    tie(M, D, hout, mout) = O;
    return make_tuple(M, D, hin * 60 + min, hout * 60 + mout);
}

int solve(const vector<vector<Timestamp>>& ts) {
    vector<int> total(ts.size());
    for (int i = 0; i < ts[0].size(); i += 2) {
        int M, D, gin, gout; tie(M, D, gin, gout) = conv(ts[0][i], ts[0][i + 1]);
        for (int j = 1; j < int(ts.size()); ++j) {
            for (int k = 0; k < int(ts[j].size()); k += 2) {
                int m, d, pin, pout; tie(m, d, pin, pout) = conv(ts[j][k], ts[j][k + 1]);
                if (M != m or D != d) continue;
                total[j] += max(0, min(gout, pout) - max(gin, pin));
            }
        }
    }
    return *max_element(all(total));
}

int main() {
    for (int n; cin >> n, n;) {
        int k = 0;
        vector<int> id(N, -1); id[0] = k++;
        vector<vector<Timestamp>> ts(N);
        while (n--) {
            int M, D, h, m, p; char e;
            scanf("%d/%d %d:%d %c %d", &M, &D, &h, &m, &e, &p);
            if (id[p] == -1) id[p] = k++;
            ts[id[p]].emplace_back(M, D, h, m);
        }
        ts.resize(k);
        printf("%d\n", solve(ts));
    }
}

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

for i in range(1,3501):
    for j in range(i,3501):
        if 4*j*i-n*i-n*j != 0 and (n*i*j)%(4*j*i-n*i-n*j) == 0:
            R = (n*i*j)//(4*j*i-n*i-n*j)
            if R > 0:
                print(i,j,R)
                exit()
            

Measured memory_bytes: 41836
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int w = sc.nextInt();
		
		if(s<=w) {
			System.out.println("unsafe");
		}
		else {
			System.out.println("safe");
		}
	}
}

Measured memory_bytes: 35728
#include <iostream>
#include <vector>
#include <cmath>

void solve(long long N)
{
  long long n_square = std::sqrt(N);
  long long min_count = 1e+12;
  for (long long i = 1; i <= n_square; i++)
  {
    if(N%i == 0)
    {
      long long count = (i-1)+(N/i-1);
      if(count < min_count)
      {
        min_count = count;
      }
    }
  }
  std::cout << min_count << std::endl;
}

int main(void)
{
  long long N;
  std::cin >> N;
  solve(N);
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    s = S()
    k = I()
    l = len(s)
    a = []
    t = s[0]
    c = 1
    for u in s[1:]:
        if t == u:
            c += 1
        else:
            a.append(c)
            t = u
            c = 1
    if len(a) == 0:
        return l * k // 2
    r = 0
    if s[0] == s[-1]:
        for b in a:
            r += b // 2
        r += c // 2
        a[0] += c
        k -= 1
    else:
        a.append(c)
    o = 0
    for b in a:
        o += b // 2

    return r + o * k


print(main())





Measured memory_bytes: 6480
n = gets.to_i

i = []
i[0] = gets.split.map(&:to_i)
i[1] = gets.split.map(&:to_i)

ans = 0
n.times do |t|
  tmp = 0
  array1 = i[0]
  array1_after = array1[0..t]
  array2 = i[1]
  array2_after = array2[t..n]
  tmp = array1_after.inject(:+) + array2_after.inject(:+)
  ans = tmp if ans < tmp
end
puts ans


Measured memory_bytes: 1788
#include <stdio.h>
int main(void){
    int a,b;
    char op;
    
    for(;scanf("%d %c %d\n",&a,&op,&b) != EOF; ){
        
        if(op=='+'){
            printf("%d\n",a+b);
        }
        else if(op=='-'){
            printf("%d\n",a-b);
        }
        else if(op=='*'){
            printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }
        else{
            break;
        }
    }

    return 0;
}



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

struct zahyo{
  int x;
  int y;
};

int abs(int x,int y){
  if(x > y){
    return x - y;
  }
  else{
    return y - x;
  }  
}

int min(int a,int b){
  if(a < b){
    return a;
  }
  else{
    return b;
  }
}

int main(){
  /*入力*/
  int n,m;
  cin >> n >> m;
  zahyo P[n],C[m];
  for(int i = 0;i < n;i++){
    cin >> P[i].x >> P[i].y;
  }
  for(int i = 0;i < m;i++){
    cin >> C[i].x >> C[i].y;
  }
  /**/

  for(int i = 0;i < n;i++){ //人
    int minimum,ans = 0;
    for(int j = 0;j < m;j++){ //チェックポイント
      int k;
      k = abs(P[i].x,C[j].x) + abs(P[i].y,C[j].y);
      if(j == 0){
	minimum = k;
	ans = j;
      }
      else{
	if(minimum > k){
	  ans = j;
	}
	minimum = min(k,minimum);	
      }
    }
    cout  << ans + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define repeat(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  string n;
  cin >>n;
  
  repeat(i,3) n[i]=='1' ? n[i]='9' : n[i]='1';
  
  string ans = n;
  
  cout << ans <<endl;
}


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

using namespace std;

int main() 
{
  int a,b,c,x,ans = 0;
  cin >> a >> b >> c >> x;
  
  for(int i = 0; i <= a; i++)
  {
    for(int j = 0; j <= b; j++)
    {
      for(int k = 0; k <= c; k++)
      {
        if(500*i + 100*j + 50*k == x)
        {
          ans++;
         
        }
      }
    }
  }
  cout << ans << endl;
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a;
    double b;
    cin>>a>>b;
    ll int_b = b*100+0.5;
    a *= int_b;
    a/=100;
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
using namespace std;

int main() {
  string S;
  int Q;
  cin >> S >> Q;
  vector<int> N(Q);
  vector<int> F(Q);
  vector<string> C(Q);
  for (int i = 0; i < Q; i++) {
    int n; cin >> n;
    N[i] = n;
    if (n == 2) cin >> F[i] >> C[i];
    if (n == 1) {
      F[i] = 0;
      C[i] = "";
    }
  } 

  deque<string> deq(S.size());
  for (int i = 0; i < S.size(); i++) deq[i] = S[i];
  // 奇数なら反転のフラグ
  int flag = 0;
  for (int i = 0; i < Q; i++) {
    if (N[i] == 1) flag++;
    else {
      if (F[i] == 1 && flag % 2 == 0) deq.push_front(C[i]);
      if (F[i] == 2 && flag % 2 == 0) deq.push_back(C[i]);
      if (F[i] == 1 && flag % 2 == 1) deq.push_back(C[i]);
      if (F[i] == 2 && flag % 2 == 1) deq.push_front(C[i]);
    }
  }
  if (flag % 2 == 1) reverse(deq.begin(), deq.end());

  for (int i = 0; i < deq.size(); i++) cout << deq[i];
  cout << endl;
}


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

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    
    for (int i = 1; i <= d; i++) {
        for (int ii = 0; ii < n; ii++) {
            if (a[ii] == 1) {
                ans++;
            }
            else if ((i % a[ii]) == 1) {
                ans++;
            }
        }
    }
    
    ans += x;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int n, b;
	string a;
	cin >> n;
	vector<pair<string, int>>vec(n);
	rep(i, n) {
		cin >> a >> b;
		vec[i].fir = a + to_string(999-b);
		vec[i].second = i + 1;
	}
	sort(all(vec));
	rep(i, n) {
		cout << vec[i].second << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int H, W, A, B, **ans, flag=0, i, j, ans_0=0, ans_W=0;
	char S[10], T[10], U[10];


	scanf("%s %s", S, T);
	scanf("%d %d", &A, &B);
	scanf("%s", U);

	if (strcmp(S, U)==0){
		printf("%d %d\n", A - 1, B);
	}
	else{
		printf("%d %d\n", A, B - 1);
	}


	/*
	ans = (int **)malloc(sizeof(int *)* H);


	for (i = 0; i<H; i++) {
		ans[i] = (int *)malloc(sizeof(int)* W);
	}

	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++){
			ans[i][j] = 0;
		}
	}
	*/

	return 0;

}
    


Measured memory_bytes: 256