akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String a[][] = new String[h][w];
        for(int i=0; i<h; i++){
            String s = sc.next();
            String b[] = s.split("");
            for(int j=0; j<w; j++){
                a[i][j] = b[j];
            }
        }
        boolean row[] = new boolean[h];
        boolean col[] = new boolean[w];
        for(int i=0; i<h; i++){
            int cnt = 0;
            for(int j=0; j<w; j++){
                if(a[i][j].equals(".")) cnt++;
            }
            if(cnt == w) row[i] = true;
        }
        for(int i=0; i<w; i++){
            int cnt = 0;
            for(int j=0; j<h; j++){
                if(a[j][i].equals(".")) cnt++;
            }
            if(cnt == h) col[i] = true;
        }
        for(int i=0; i<h; i++){
            if(row[i]) continue;
            for(int j=0; j<w; j++){
                if(col[j]) continue;
                System.out.print(a[i][j]);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 26956
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0) {
				break;
			}
			boolean flag = false;
			List<Integer> list = new ArrayList<Integer>();
			long[] num = new long[4001];
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				long b = scanner.nextInt();
				long c = scanner.nextInt();
				num[a] += b * c;
				if (!list.contains(a)) {
					list.add(a);
				}

			}
			for (int t : list) {
				if (num[t] >= 1000000) {
					flag = true;
					System.out.println(t);
				}
			}
			if (!flag) {
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 27348
//  Created by conan1024hao on 2019/11/16.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;
    cin>>n;
    double sum=0;
    vector<pair<int,int>>ab;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        ab.push_back(make_pair(a,b));
    }
    for(int i=0;i<n-1;i++)
        for(int j=i+1;j<n;j++)
            sum+=sqrt((ab[i].fi-ab[j].fi)*(ab[i].fi-ab[j].fi)+(ab[i].se-ab[j].se)*(ab[i].se-ab[j].se));
    double ans=sum*2/n;
    printf("%.8lf\n",ans);
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



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

int main(int argc, const char * argv[]) {
    int N, K;
    
    cin >> N >> K;
    
    vector<int> l(N);
    for (int i = 0; i < N; i++) cin >> l[i];
    
    sort(l.begin(), l.end(), greater<int>());
    
    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum = sum + l[i];
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
import numpy as np

n, k = map(int,input().split())

result = []

for i in range(n):
    num = i+1
    count = 0
    while True:
        if num >= k:
            result.append(count)
            break
        num *= 2
        count += 1


prob = 0

for j in result:
    prob += (1/n) * (0.5)**j

print(prob)

Measured memory_bytes: 21660
def selection_sort(a,n):
  cnt = 0
  for i in range(0,n):
    minj = i
    for j in range(i,n):
      if a[j] < a[minj]:
        minj = j
    if a[i] != a[minj]:
      temp = a[i]
      a[i] = a[minj]
      a[minj] = temp
      cnt += 1
  print(' '.join(map(str,a)))
  print(cnt)
  
num = int(input())
array = list(map(int,input().split()))

selection_sort(array,num)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	long long k;
	cin>>s>>k;
	reverse(s.begin(),s.end());
	while(!s.empty() && s.back()=='1' && --k)s.pop_back();
	putchar(s.back());
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      n: usize,
      mut aa: [usize; n]
    };

    let ans = aa.iter()
        .enumerate()
        .filter(|&(i, v)| (i + 1) % 2 == 1 && v % 2 == 1).count();

    println!("{}", ans);

}


Measured memory_bytes: 2088
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)2e5 + 228;

using namespace std;

int n;
ll a[N], b[N];

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	scanf("%d", &n);
	forn(i, n)
	{
		scanf("%lld", &a[i]);
		b[i] = b[i - 1] + a[i];
	}
	ll ans = b[n];
	for (int i = 1; i < n; i++)
	{
		ans = min(ans, abs(b[i] - (b[n] - b[i])));
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>

using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  cout << (char)(a[0] + ('A' - 'a')) << (char)(b[0] + ('A' - 'a')) << (char)(c[0] + ('A' - 'a')) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long long a[2]={101,103};
long long M[2]={1e9+7,1e9+9};
long long d[2][300010],k[2][300010];
long long R=1,C=1,H[2000010],N[2000010],h[300010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]||N[H[a]]==N[H[b]]&&h[H[a]]<h[H[b]]?1:0;
}
//挿入関数
void hin(long long a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
void init(char *s){//!
  int i,j;
  for(i=0;i<2;i++){
    k[i][0]=1;
    for(j=d[i][0]=0;s[j];j++){
      d[i][j+1]=(d[i][j]*a[i]+(s[j]-'a'+1))%M[i];
      k[i][j+1]=(k[i][j]*a[i])%M[i];
    }
  }
}
int getlr(int l,int r,int i){return (M[i]*M[i]+d[i][r]-d[i][l]*k[i][r-l])%M[i];}
void gets(char *s,int *h){
  int i,j;
  for(i=0;i<2;i++){
    for(j=h[i]=0;s[j];j++)h[i]+=k[i][j]*(s[j]-'0');
  }
}
int match(int l,int r,int *h){
  int i,j=1;
  for(i=0;i<2;i++)j*=getlr(l,r,i)-h[i]?1:0;
  return j;
}
int main(){
  int n=0,m,a,b,i,j,l=0,r=1;
  char s[300010],q[5];
  scanf("%*d %d %s",&m,s);
  init(s);//printf("%s\n",s);
  //for(i=0;s[i];i++)printf("%lld ",k[0][i+1]);printf("\n");
  //printf("%lld %lld %lld\n",d[0][3],d[0][4],k[0][2]);return 0;
  //printf("%lld %lld\n",getlr(0,2,0),getlr(2,4,0));return 0;
  for(i=0;i<m;i++){
    scanf("%s",q);
    if(q[0]=='L')l+=q[1]-'-'?1:-1;
    else         r+=q[1]-'-'?1:-1;//printf("%d %d!",l,r);
    h[R]=getlr(l,r,0);
    hin(getlr(l,r,1));//printf("%lld %lld\n",h[R-1],N[R-1]);
  }
  a=hout();
  for(i=1;i<m;i++){
    b=hout();//printf("%lld %lld %lld %lld\n",N[a],N[b],h[a],h[b]);
    if(N[b]==N[a]&&h[b]==h[a])n++;
    a=b;
  }
  printf("%d\n",m-n);
  return 0;
}



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

int main() {
  int L,R,d;
  cin >> L >> R >>d;
  int l,r,S;
  l=L/d;
  r=R/d;
  if(L%d==0){
    S=r-l+1;
  }
  else{
    S=r-l;
  }
  cout << S << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<set>
#include<vector>
#include<map>

using namespace std;

typedef vector<vector<int> > Mat;

long long W,H,N;

Mat operator*(const Mat &a,const Mat &b){
  Mat m(W,vector<int>(W));
  for(int i=0;i<W;i++){
    for(int j=0;j<W;j++){
      for(int k=0;k<W;k++){
	m[i][j]=(m[i][j]+a[i][k]*1LL*b[k][j])%1000000009;
      }
    }
  }
  return m;
}

Mat bm(const set<int> &s=set<int>()){
  Mat m(W,vector<int>(W));
  for(int i=0;i<W;i++){
    if(s.count(i)==0){
      for(int j=-1;j<=1;j++){
	int x=i+j;
	if(0<=x&&x<W){
	  m[i][x]=1;
	}
      }
    }
  }
  return m;
}

Mat pm(const Mat &m,long long p){
  if(p==0){
    Mat m(W,vector<int>(W));
    for(int i=0;i<W;i++){
      m[i][i]=1;
    }
    return m;
  }else{
    auto r=pm(m*m,p>>1);
    if(p%2){
      r=r*m;
    }
    return r;
  }
}

int main(){
  for(int t=1;cin>>W>>H>>N,W;t++){
    map<long long,set<int> > m;
    while(N--){
      long long x,y;
      cin>>x>>y;
      if(y>1){
	m[y-1].insert(x-1);
      }
    }
    vector<Mat> v;
    long long l=0;
    for(auto e:m){
      v.push_back(pm(bm(),e.first-l-1));
      v.push_back(bm(e.second));
      l=e.first;
    }
    v.push_back(pm(bm(),H-l-1));
    auto am=pm(bm(),0);
    for(int i=v.size()-1;i>=0;i--){
      am=am*v[i];
    }
    cout<<"Case "<<t<<": "<<am[W-1][0]<<endl;
  }
}

Measured memory_bytes: 4136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

bool visited[51][51];
vs s;
ll h, w;

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

using TP = pair<pll, ll>;

ll bfs(ll x, ll y){
    queue<TP> q;
    visited[x][y] = 1;
    ll depth = 0;
    pll now = pll(x, y);
    q.emplace(now, depth);
    while(!q.empty()){
        now = q.front().first;
        depth = q.front().second;
        q.pop();
        if(now.first == h-1 && now.second == w-1){
            return depth;
        }
        rep(i, 4){
            pll next = pll(now.first+dx[i], now.second+dy[i]);
            if(next.first < 0) continue;
            if(next.second < 0) continue;
            if(next.first >= h) continue;
            if(next.second >= w) continue;
            if(!visited[next.first][next.second]){
                visited[next.first][next.second] = 1;
                q.emplace(next, depth+1);
            }
        }
    }
    return -1;
}


int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> h >> w;
    s.resize(h);
    rep(i, h){
        cin >> s[i];
    }
    ll k = 0;
    rep(i, h)rep(j, w){
        if(s[i][j] == '#'){
            visited[i][j] = 1;
            k++;
        }
        else visited[i][j] = 0;
    }
    ll ans = bfs(0, 0);
    if(ans == -1){
        cout << ans << endl;
    }else{
        cout << h*w-k-ans-1 << endl;
    }
    return 0;
}

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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    ll R;
    cin >> R;
    cout << 2 * R * M_PI << endl;
    return 0;
}


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

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

	int d = 100;
	int sum = 0;

	for( int i = 0; i < N; ++i ) {
		if( abs( L+i ) < abs(d) ) {
			d = L+i;
		}

		sum += L + i;
	}

	cout << sum - d << endl;
}


Measured memory_bytes: 256
#include <cstdio>

#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int n, m, d[15][15];

signed main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j)
      scanf("%d", &d[i][j]);
  for (int k = 0; k < 10; ++k)
    for (int i = 0; i < 10; ++i)
      for (int j = 0; j < 10; ++j)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int ans = 0, num;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      scanf("%d", &num);
      if (num != -1)
        ans += d[num][1];
    }
  return printf("%d\n", ans), 0;
}


Measured memory_bytes: 128
l=[51]*26
for s in [input() for _ in range(int(input()))]:
  for i in range(26): c=s.count(chr(97+i)); l[i]=min(l[i],c)
a=''
for i in range(26):
  if l[i]<51: a+=chr(97+i)*l[i]
print(a)

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/04/03  Problem: ABC 050 B / Link: http://abc050.contest.atcoder.jp/tasks/abc050_b  ----- */


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

	LL N; cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	LL sum = accumulate(ALL(a), 0LL);
	LL Q; cin >> Q;
	FOR(_, 0, Q) {
		LL P, X; cin >> P >> X;
		LL ans = sum - a[P - 1] + X;

		cout << (ans) << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);

        var xx = new List<X>();

        spl = input.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
            xx.Add(new X() { i = i, x=int.Parse(spl[i]) });

        xx.Sort((x, y) => x.x - y.x);

        var centers = new List<X>();
        int center = n / 2;

        for(int i=0; i<n; i++) {
            var subidx = xx[i].i;
            var x = (i < center) ? xx[center] : xx[center - 1];

            centers.Add(new X() { i = subidx, x=x.x });
        }

        centers.Sort((x, y) => x.i - y.i);

        var buil = new StringBuilder();
        foreach (var i in centers) {
            buil.AppendLine(i.x.ToString());
        }

        return buil;
    }

    class X
    {
        public int i;
        public int x;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 55188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3576
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

let reader=readInts()
let k=reader[0]
let x=reader[1]

var i=x-k+1
for _ in 1...2*k-1{
  print(i,terminator:"")
  print(" ",terminator:"")
  i+=1
}

Measured memory_bytes: 13256
#include<iostream>
using namespace std;
int main(){
    int x,i=1;
    while(1){
        cin>>x;
        if(x==0){
            break;
        }
        else{
            cout<<"Case"<<" "<<i<<":"<<" "<<x<<endl;
            i++;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
import sys
N = int(input())
S = input()

W = [0] *N
E = [0] *N
L = [0] *N
if S[0] == "W": W[0] = 1
if S[-1] == "E": E[-1] = 1

for i in range(1,N):
  if S[i] == "W":
    W[i] = W[i-1] + 1
  else:
    W[i] = W[i-1]
for i in range(1,N+1):
  if S[-i] == "E":
    E[-i] = E[-i+1] + 1
  else:
    E[-i] = E[-i+1]
L[0] = E[1]
L[-1] = W[-2]
for i in range(1,N-1):
  L[i] = W[i-1] + E[i+1]
print (min(L))

Measured memory_bytes: 29472
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif
template <class C>
inline void vcin(C &a);
template <class C>
inline void vcout(const C a, const string separate = "\n");

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vcin(a);

  set<int> s;
  for (auto e : a)
  {
    auto it = s.find(e);
    if (it == s.end())
    {
      s.insert(e);
    }
    else
    {
      s.erase(e);
    }
  }

  cout << s.size() << endl;

  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C>
inline void vcout(const C c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}


Measured memory_bytes: 5376
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(),x=sc.nextInt();
        int[] l = new int[n+1];
        int[] d = new int[n+2];
        for(int i=1;i<n+1;i++)l[i]=sc.nextInt();

        d[1]=0;
        int i;
        for(i=2;i<n+2;i++){
            d[i]=d[i-1]+l[i-1];
            //System.out.println(d[i]);
            if(d[i]>x){
                System.out.println((i-1));
                return;
            }
        }
        System.out.println((n+1));


    }

}


Measured memory_bytes: 21844
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int count = 0;
		for(int i = 0; i < a; i++){
			int high = sc.nextInt();
			int side = sc.nextInt();
			if(high >= b && side >= c){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n;
multiset<int> s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ans = 0;
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    s.insert(a);
    auto itr = s.find(a);
    if(itr == s.begin()){
      ans++;
    }else{
      s.erase(--itr);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
main :: IO ()
main = do
    s <- fmap read getLine :: IO Int
    print $ solve s

solve :: Int -> Int
solve 1 = 4
solve 2 = 4
solve 4 = 4
solve n = 1 + (solve $ if n `mod` 2 == 0 then n `div` 2 else n * 3 + 1)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A = 0, B = 0;
  cin >> A >> B;
  
  if (A >= 13) {
    cout << B << endl;
  } else if (A >= 6) {
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n&&n!=0){
		int a,b;
		int ma=-1111111,mi=1000000;
		for(int i=0;i<n;i++){
			b=0;
			for(int j=0;j<5;j++) {
				cin>>a;
				b+=a;
			}
			ma=max(b,ma);
			mi=min(b,mi);
		}
		cout<<ma<<" "<<mi<<endl;
	}
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
int n;
long long dp[3002][3002], sum[3002], a[3002];
long long SUM(int l, int r){
  return sum[r] - sum[l - 1];
}

long long solve(int l, int r){
  if (dp[l][r] != -1)
    return dp[l][r];
  if (l == r)
    return dp[l][r] = 0;
  if (l + 1 == r)
    return dp[l][r] = a[l] + a[r];
  dp[l][r] = (long long)1e18;
  for (int i = l; i <= r; i++)
  	dp[l][r] = min(dp[l][r], SUM(l, i) + SUM(i + 1, r) + solve(l, i) + solve(i + 1, r));
  return dp[l][r];
}
main(){
  scanf("%d", &n);
  for (int i = 1; i <= n; i++){
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      dp[i][j] = -1;
  printf("%lld\n", solve(1, n));
  return 0;
}

Measured memory_bytes: 9088
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Point{
	void set(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}
	double x,y;
};

int N;
double a[32],b[32],c[32],d[32];
double S[9];

Point calc_Cross_Point(double x1,double x2,double x3,double x4,double y1,double y2,double y3,double y4){
	Point ret;
	ret.x = ((x2-x1)*(y3*(x4-x3)+x3*(y3-y4))-(x4-x3)*(y1*(x2-x1)+x1*(y1-y2)))/((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1));
	if(x1 != x2){
		ret.y = ((y2-y1)*ret.x+y1*(x2-x1)+x1*(y1-y2))/(x2-x1);
	}else{
		ret.y = ((y4-y3)*ret.x+y3*(x4-x3)+x3*(y3-y4))/(x4-x3);
	}
	return ret;
}

double calc_S(Point a,Point b,Point c,Point d){

	return fabs((b.x*a.y - b.y*a.x)+(c.x*b.y - c.y*b.x)+(d.x*c.y - d.y*c.x)+(a.x*d.y - a.y*d.x))/2;

}

void func(){


	a[0] = 0;
	b[0] = 0;
	c[0] = 0;
	d[0] = 0;
	for(int i = 1; i <= N; i++)scanf("%lf",&a[i]);
	for(int i = 1; i <= N; i++)scanf("%lf",&b[i]);
	for(int i = 1; i <= N; i++)scanf("%lf",&c[i]);
	for(int i = 1; i <= N; i++)scanf("%lf",&d[i]);
	a[N+1] = 1;
	b[N+1] = 1;
	c[N+1] = 1;
	d[N+1] = 1;

	double ans = 0;

	Point A,B,C,D;

	for(int yoko = 0; yoko <= N; yoko++){
		for(int tate = 0; tate <= N; tate++){

			A = calc_Cross_Point(0,1,b[yoko],a[yoko],c[tate+1],d[tate+1],1,0);
			B = calc_Cross_Point(0,1,b[yoko+1],a[yoko+1],c[tate+1],d[tate+1],1,0);
			C = calc_Cross_Point(0,1,b[yoko+1],a[yoko+1],c[tate],d[tate],1,0);
			D = calc_Cross_Point(0,1,b[yoko],a[yoko],c[tate],d[tate],1,0);

			ans = max(ans,calc_S(A,B,C,D));
		}
	}

	printf("%.10lf\n",ans);
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h;
  ll ans = 0;
  cin >> h;
  ll x = 1;
  while(x <= h){
    ans += x;
    x *= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll find_nos(ll a, ll b, ll c)
{
    ll start = a/c, stop = b/c;
    if( a%c !=0 )
        start++;
    ll res = stop - start + 1;
    return res;
}
int main()
{
    she_told_me_dont_worry
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll ans = b - a + 1;
    ans -= find_nos(a, b, c);
    ans -= find_nos(a, b, d);
    ll hcf = (c*d)/__gcd(c, d);
    ans += find_nos(a, b, hcf);
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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;
    cin >> n;
    V<int> b(n);
    rep(i,n) cin >> b[i];
    V<int> ans;
    V<bool> used(n);

    while(sz(ans) != n) {
        bool ok = false;
        for(int i = n-1; i >= 0; i--) {
            int cnt = 0;
            rep(j,i) {
                if(used[j]) cnt++;
            }
            if(b[i]+cnt == i+1 && !used[i]) {
                used[i] = true;
                ans.push_back(b[i]);
                ok = true;
                break;
            }
        }
        if(!ok) {
            cout << -1 << endl;
            return 0;
        }
    }

    reverse(all(ans));
    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N;

  std::cin >> N;

  long long xp = -1;

  for (int i = 0; i <= 40000; i ++) {
    long long x = 1LL * i * i;

    if (x > N)
      break;
    
    xp = x;
  }

  std::cout << xp << std::endl;

  return 0;
}


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

struct UnionFind {
  vector<int> data;
  UnionFind() {}
  UnionFind(int n) : data(n, -1) {}
  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return (data[x] < 0) ? x : data[x] = root(data[x]); }
  int rank(int x) { return -data[root(x)]; }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
};
template<typename T> struct Graph {
  struct Edge { int s, t; T cost; };
  int sz;
  vector<Edge> es;
  Graph(int n = 0) : sz(n) {}

  void addEdge(int u, int v, T w) {
    sz = max(sz, max(u, v) + 1);
    es.push_back({u, v, w});
  }
  T kruskal() {
    UnionFind uf(sz);
    sort(begin(es), end(es), [](Edge e1, Edge e2) {
      return e1.cost < e2.cost;
    });
    T res = 0;
    for (auto&& e : es) {
      if (uf.unite(e.s, e.t)) res += e.cost;
    }
    return res;
  }
};

int main() {
  int n; cin >> n;
  vector<vector<int>> table(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> table[i][j];
    }
  }
  Graph<int> g;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (table[i][j] != -1) g.addEdge(i, j, table[i][j]);
    }
  }
  cout << g.kruskal() << endl;
  return 0;
}



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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

ll gcd(ll a, ll b) { while (b) a %= b, swap(a, b); return abs(a); }


template<typename T>
vector<T> smallest_prime_factors(T n) {

	vector<T> spf(n + 1);
	for (int i = 0; i <= n; i++) spf[i] = i;


	for (T i = 2; i * i <= n; i++) {

		if (spf[i] == i) {

			for (T j = i * i; j <= n; j += i) {

				if (spf[j] == j) {
					spf[j] = i;
				}
			}
		}
	}

	return spf;
}

template<typename T>
unordered_set<T> factolization(T x, vector<T>& spf) {
	unordered_set<T> ret;
	while (x != 1) {
		ret.insert(spf[x]);
		x /= spf[x];
	}
	return ret;
}

int main() {
    ll n;
    cin >> n;
	vector<ll> as(n);
	rep(i, n) {
		cin >> as[i];
	}
	ll setwise = as[n - 1];
	rep(i, n-1) {
		setwise = gcd(setwise, as[i]);
	}

	auto spf = smallest_prime_factors((ll)(1e6 + 1));

	vector<bool> visit(1e6 + 1, false);

	bool pairwise = true;
	rep(i, n) {
		auto result = factolization(as[i], spf);
		for (auto p : result) {
			if (visit[p]) {
				pairwise = false;
				break;
			}
			visit[p] = true;
		}
		if (!pairwise) {
			break;
		}
	}
	if (pairwise) {
		cout << "pairwise coprime" << endl;
	}
	else if (setwise == 1) {
		cout << "setwise coprime" << endl;
	}
	else{
		cout << "not coprime" << endl;
	}
    return 0;
}


Measured memory_bytes: 19004
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;

int lower_bound_sub(vector<int>* a,int k,int min,int max){
  if(min > max){
    return a->size();
  }
  else{
    int mid = min + (max - min) / 2;
    if(a->at(mid) >= k && mid == 0){
      return mid;
    }
    else if(a->at(mid) >= k && a->at(mid-1) < k){
      return mid;
    }
    else if(a->at(mid) >= k){
      return lower_bound_sub(a,k,min,mid-1);
    }
    else {
      return lower_bound_sub(a,k,mid+1,max);
    }

  }

}

int lower_bound(vector<int>* a,int k){
  return lower_bound_sub(a,k,0,a->size()-1);
}

int upper_bound_sub(vector<int>* a,int k,int min,int max){
  if(min > max){
    return a->size();
  }
  else{
    int mid = min + (max - min) / 2;

    if(a->at(mid) > k && mid == 0){
      return mid;
    }
    
    else if(a->at(mid) > k && a->at(mid-1) <= k){
      return mid;
    }
    else if(a->at(mid) > k){
      return upper_bound_sub(a,k,min,mid-1);
    }
    else{
      return upper_bound_sub(a,k,mid+1,max);
    }
  }
}

int upper_bound(vector<int>* a,int k){
  return upper_bound_sub(a,k,0,a->size()-1);
}

int main(){
  long ii,jj,kk,n,q;
  int k;
  vector<int> a;

  cin >> n;

  a.resize(n);

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

  int ret1,ret2;
  cin >> q;
  int ret;
  for(ii=0;ii<q;ii++){
    cin >> k;
    //ret = lower_bound(&a,k);
    ret1 = lower_bound(&a,k);
    ret2 = upper_bound(&a,k);
    cout << ret1 << " " << ret2 << endl;
  }
  
  //for(ii=0;ii<q;ii++){
  //  cin >> k;
  //  if(binSearch(&a,k)){
  //    cout << "1" << endl;
  //  }
  //  else{
  //    cout << "0" << endl;
  //  }
  //}
  
  return 0;
}



Measured memory_bytes: 3128
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011];
char op[11];
LL sums[100011], asums[100011];

void MAIN() {
    scanf("%d", &N);
    scanf("%d", A);
    for (int i=1; i<N; i++) {
	scanf("%s%d", op, A+i);
	if (*op == '-') A[i] = -A[i];
    }

    REP (i, N) {
	sums[i+1] = sums[i] + A[i];
	asums[i+1] = asums[i] + abs(A[i]);
    }
    LL ans = sums[N];
    REP (i, N) if (A[i] < 0) {
	int r = i+1;
	while (r < N && A[r] >= 0) r++;
	if (r < N) {
	    LL tmp = sums[i+1] - (sums[r] - sums[i+1]) + (asums[N] - asums[r]);
	    amax(ans, tmp);
	}
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  
  if( a == 5 && b == 5 && c == 7)
    cout << "YES" << endl;
  else if(a == 5 && b == 7 && c == 5)
    cout << "YES" << endl;
  else if(a == 7 && b == 5 && c == 5)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	long[] sosu = new long[N+1];
	for(int i = 0; i<=N; i++) {
	    int temp = i;
	    int cnt = 2;
	    while(temp > 1 && cnt<N) {
		while(temp%cnt == 0) {
		    sosu[cnt]++;
		    temp = temp/cnt;
		}
		cnt++;
	    }
	}
	//sosuに全ての個数が入ってる
	long ans = 0;
	HashMap<Integer,Long> map = new HashMap<Integer, Long>();

	long n74 = (map.get(74)==null)?0:map.get(74);
	long n24 = (map.get(24)==null)?0:map.get(24);
	long n14 = (map.get(14)==null)?0:map.get(14);
	long n4 = (map.get(4)==null)?0:map.get(4);
	long n2 = (map.get(2)==null)?0:map.get(2);


	for(int i=0; i<=N; i++) {
	    n74 = (map.get(74)==null)?0:map.get(74);
	    n24 = (map.get(24)==null)?0:map.get(24);
	    n14 = (map.get(14)==null)?0:map.get(14);
	    n4 = (map.get(4)==null)?0:map.get(4);
	    n2 = (map.get(2)==null)?0:map.get(2);
	    if(sosu[i] >= 74) map.put(74, n74+1);
	    if(sosu[i] >= 24) map.put(24, n24+1);
	    if(sosu[i] >= 14) map.put(14, n14+1);
	    if(sosu[i] >= 4) map.put(4, n4+1);
	    if(sosu[i] >= 2) map.put(2, n2+1);
	}

	n74 = (map.get(74)==null)?0:map.get(74);
	n24 = (map.get(24)==null)?0:map.get(24);
	n14 = (map.get(14)==null)?0:map.get(14);
	n4 = (map.get(4)==null)?0:map.get(4);
	n2 = (map.get(2)==null)?0:map.get(2);

	ans += n74;
	ans += n24*(n2-1);
	ans += n14*(n4-1);
	ans += (n4*(n4-1))/2 * (n2-2);
	System.out.println(ans);

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef pair<int,int> P;
#pragma GCC optimize("Ofast")

const int MAX_N = 205;

int N;
char G1[MAX_N][MAX_N];
vector<vector<int>> G;

int bfs(int s){
    int ans = -1;
    vector<bool> visited(N, false);
    vector<int> id(N, -10);

    queue<P> Q;
    Q.push({s,1});
    visited[s] = true;
    id[s] = 1;

    while(!Q.empty()){
        auto now = Q.front();
        Q.pop();
        int v = now.first;
        int ID = now.second;
        ans = max(ans, ID);
        //cout << v << endl;
        for(auto nv: G[v]){
            if(id[nv] == ID + 1 || id[nv] == ID - 1 || id[nv] == -10);
            else return -1;
            if(visited[nv]) continue;
            Q.push({nv, ID + 1});
            visited[nv] = true;
            id[nv] = ID + 1;
        }
        //cout << endl;
    }
    return ans;
}
int main(){
    cin >> N;
    G.resize(N);
    rep(i,N){
        rep(j,N){
            cin >> G1[i][j];
            if(G1[i][j] == '1')G[i].push_back(j);
        }
    }
    int ans = -1;
    rep(i,N) ans = max(ans,bfs(i));
    cout << ans << endl;
}

Measured memory_bytes: 512
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
    return dist

n = ni()
graph = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,c = li()
    a -= 1
    b -= 1
    graph[a].append((c,b))
    graph[b].append((c,a))
    
q,k = li()

dist = dijkstra(graph,n,k-1)

xy = [tuple(li_()) for _ in range(q)]

for x,y in xy:
    print(dist[x]+dist[y])

Measured memory_bytes: 56976
#include <bits/stdc++.h>
using namespace std;
int main(){
while(1){
int H, W;
cin>>H>>W;
if(H == 0 && W == 0) break;

for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cout<<"#";
}
cout<<endl;
}
cout<<endl;
}
return 0;
}


Measured memory_bytes: 3040
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int K, X; cin >> K >> X;
  int mini = -1000000, maxi = 1000000;
  int minp = max(X-K+1, mini), maxp = min(X+K-1, maxi);
  for(int x = minp; x <= maxp; x++){
    cout << x << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#define endl '\n'
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define ll long long
#define INF 0x3f3f3f3f
#define sync ios::sync_with_stdio(0);
const int N=10005;
using namespace std;
struct tu{
	int v,next;
}e[N];
int head[N],tot=0;
bool vis[N];
int mch[N];
void init()
{
	tot=0;
	memset(head,-1,sizeof head);
	memset(mch,-1,sizeof mch);
}
void add(int u,int v)
{
	e[tot].v=v;
	e[tot].next=head[u];
	head[u]=tot++;
}
int n;
struct node{
	int x,y;
}a[N],b[N];
bool dfs(int u)
{
	for(int i=head[u];i!=-1;i=e[i].next)
	{
		int v=e[i].v;
		if(vis[v]) continue;
		vis[v]=1;
		if(mch[v]==-1||dfs(mch[v]))
		{
			mch[v]=u;
			return true;
		}
	}
	return false;
}

int main()
{//sync
	cin>>n;
	init();
	for(int i=0;i<n;i++)
	cin>>a[i].x>>a[i].y;
	for(int i=0;i<n;i++)
	cin>>b[i].x>>b[i].y;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(a[i].x<b[j].x&&a[i].y<b[j].y)
			add(i,j);
		}
	}
	for(int i=0;i<2*n;i++)
	{
		memset(vis,0,sizeof vis);
		if(dfs(i))
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
n = gets.to_i

sum = 0

if n % 2 == 0 then
	len = n.to_s().size
	
	(0..1000000).each{ |i|
		base = (5 ** i) * 10
		
#		puts (n / base) * (2 ** i - 1) / (2 ** i)
		
		if n >= base then
			sum += n / base
		else
			break
		end
	}

	puts sum
else
	puts 0
end


Measured memory_bytes: 1788