akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)
    val s = readLine()!!.toCharArray()
    println(if (s.distinct().count() == 1) "No" else "Yes")
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

int main()
{
  int n;
  cin >> n;
  
  int a[n];
  int ans = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] % 2 == 0){
      ans++;
    }
  }
  
  for(int i = 0; i < n; i++){
    if( (a[i] % 2 == 0) && ((a[i] % 3 == 0) || (a[i] % 5 == 0)) ){
      ans--;
    }
  }
  
  if(ans == 0){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
}

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

int main() {
  int n, k, w, count;
  cin >> n >> k;
  
  w = k;
  count = 1;
  while (true) {
    if(n <= w-1) {
      cout << count << endl;
      break;
    }
    w *= k;
    count++;
  }
  return 0;
}

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

int main() {
  int n, m; cin >> n >> m;
  vector<vector<int>> arr(n);
  for (auto &v : arr) {
    int k; cin >> k;
    v.resize(k);
    for (auto &a : v) cin >> a;
  }
  for (auto &v : arr) sort(begin(v), end(v));
  vector<vector<int>> ans(n);
  ans[0] = arr[0];
  for (int i=1; i<n; ++i) {
    for (auto &a : ans[i-1]) {
      if (binary_search(begin(arr[i]), end(arr[i]), a)) {
        ans[i].push_back(a);
      }
    }
  }
  cout << ans.back().size() << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define endl '\n'
#define ll long long

using namespace std;

int main() {
    ll v[5], k;
    bool comunica = true;

    for(int i = 0; i < 5; i++) {
        cin >> v[i];
    }

    cin >> k;

    for(int i = 0; i < 5; i++) {

        for(int j = i + 1; j < 5; j++) {
            
            if(abs(v[i] - v[j]) > k) {
                comunica = false;
                break;
            }
        }
    }

    if(comunica) {
        cout << "Yay!" << endl;
    }

    else {
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)((x).size())
#define mp make_pair

using namespace std;

typedef unsigned long long ull;
typedef pair<int,int> ii;

template<class U,class T>ostream& operator<<(ostream& out, pair<U,T> & P){
    return out << "[" << P.first << ", " << P.second << "]";
}
template<class T>ostream& operator<<(ostream& out, vector<T> & V){
    if(!V.empty())out << "[";
    for(int i = 0; i < sz(V); i++)out << V[i] << (i+1==sz(V)?"]":", ");
    return out;
}

int main(){
    ios_base::sync_with_stdio(false);
    char a;
    cin >> a;
    cout << char(a+1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>

#define INT_MAX 1000000000

using namespace std;

int main(){
  int n,m,st,sh,cur;
  pair<int,int> curp;
  while (1){
    cin >> n >> m;
    if (n==0) return 0;
    st=0;sh=0;cur=INT_MAX;curp=make_pair(0,0);
    vector<int> taro(n,0);
    vector<int> hana(m,0);
    for(int i=0;i<n;i++){
      cin >> taro[i];
      st+=taro[i];
    }
    for(int i=0;i<m;i++){
      cin >> hana[i];
      sh+=hana[i];
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        if(st-2*taro[i]==sh-2*hana[j]){
          if (cur>taro[i]+hana[j]){
            cur = taro[i]+hana[j];
            curp.first=i;
            curp.second=j;
          }
        }
      }
    }
    if (cur==INT_MAX){
      cout << "-1" << endl;
    } else {
      cout << taro[curp.first] << ' ' << hana[curp.second] << endl;
    }
  }
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
 
int main() {
  ll a,b;
  ci(a>>b);
  ll c=b-a;
  ll d=0;
  for(i,1,c)
    d+=i;
  co(d-a);
}

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

struct UnionFind
{
  vector<int> rank, p;
  UnionFind(int n)
  {
    rank.resize(n, 0);
    p.resize(n);
    rep(i, n)
    {
      p.at(i) = i;
    }
  }

  int find(int x)
  {
    if (x != p.at(x))
    {
      p.at(x) = find(p.at(x));
    }
    return p.at(x);
  }

  bool same(int x, int y)
  {
    return find(x) == find(y);
  }

  void link(int x, int y)
  {
    if (rank.at(x) < rank.at(y))
    {
      p.at(x) = y;
    }
    else
    {
      p.at(y) = x;
      if (rank.at(x) == rank.at(y))
      {
        rank.at(x)++;
      }
    }
  }

  void unite(int x, int y)
  {
    link(find(x), find(y));
  }
};

int main()
{
  int n;
  cin >> n;
  UnionFind uf(n);
  vector<pair<int, int>> X(n), Y(n);
  rep(i, n)
  {
    int x, y;
    cin >> x >> y;
    X.at(i) = make_pair(x, i);
    Y.at(i) = make_pair(y, i);
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  vector<tuple<int, int, int>> edge;
  rep(i, n - 1)
  {
    edge.push_back(make_tuple(X.at(i + 1).first - X.at(i).first, X.at(i).second, X.at(i + 1).second));
    edge.push_back(make_tuple(Y.at(i + 1).first - Y.at(i).first, Y.at(i).second, Y.at(i + 1).second));
  }
  sort(edge.begin(), edge.end());
  ll cost = 0;
  rep(i, edge.size())
  {
    int w, s, t;
    tie(w, s, t) = edge.at(i);
    if (uf.same(s, t))
    {
      continue;
    }
    cost += w;
    uf.unite(s, t);
  }
  cout << cost << endl;
}

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


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

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

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

  double ans = 0;

  ans += a[0];
  for(int i=1; i<n; ++i){
    ans += pow(2, i-1)*a[i];
  }

  cout << ans / pow(2, n-1) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

struct UnionFind{
	vector<int> par,rank,cnt;
	V<ll> sum;
	UnionFind(int N){
		par.assign(N,0);
		rank.assign(N,0);
		cnt.assign(N,0);
		sum.assign(N,0);
		rep(i,N) par[i]=i;
	}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]) swap(x,y);

		//x becomes root
		par[y]=x;
		sum[x] += sum[y];
		cnt[x] += cnt[y];
		if(rank[x]==rank[y]) rank[x]++;
	}
};
int N,M;
V<int> X,Y,A,B;

int main(){
	cin>>N>>M;
	X.resize(N);
	Y.resize(M);
	A.resize(M);
	B.resize(M);
	rep(i,N) cin>>X[i];
	{
		using P = pair<int,int>;
		using PP = pair<int,P>;
		V<PP> es;
		rep(i,M){
			int a,b,c;
			cin>>a>>b>>c;
			a--,b--;
			es.push_back(PP(c,P(a,b)));
		}
		sort(all(es));
		rep(i,M) A[i] = es[i].sc.fs, B[i] = es[i].sc.sc, Y[i] = es[i].fs;
	}
	UnionFind UF(N);
	rep(i,N) UF.sum[i] = X[i];

	int use = 0;
	rep(t,M){
		UF.unite(A[t],B[t]);
		int r = UF.find(A[t]);
		UF.cnt[r]++;
		if(UF.sum[r] >= Y[t]){
			use += UF.cnt[r];
			UF.cnt[r] = 0;
		}
	}
	cout<<M-use<<endl;
}

Measured memory_bytes: 3808
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long a = 1;
		for(int i = 1 ; i <= n ; i++){
			a = a*i;
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 17160
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
int n,ans=0,cnt[5007],id[5007];
long long h[5007],p[5007],dp[5007];
bool cmp(int x,int y){
	return (h[x]+p[x]<h[y]+p[y]);
}
int main(){
	ios_base::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i]>>p[i];
		id[i]=i;
	}
	sort(id+1,id+1+n,cmp);
	for(int i=1;i<=n;i++) dp[i]=1e16;
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=i-1;j>=0;j--){
			int t=id[i];
			if(dp[j]<=h[t]) dp[j+1]=min(dp[j+1],dp[j]+p[t]);
		}
	}
	for(int i=n;i>=0;i--){
		if(dp[i]!=1e16){
			cout<<i;
			return 0;
		}
	}
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
  long long X;
  cin >> X;

  long long x = 100;
  for (int i = 0; ; ++i) {
    x += x / 100;
    if (x >= X) {
      cout << i + 1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	int n, i, a[111111], sgcd[111111], rsgcd[111111], ans;
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> a[i];
	sgcd[0] = a[0];
	for (i = 1; i < n; i++)
		sgcd[i] = gcd(sgcd[i - 1], a[i]);
	rsgcd[n-1] = a[n-1];
	for (i = n-2; i >=0; i--)
		rsgcd[i] = gcd(rsgcd[i + 1], a[i]);
	ans = max(sgcd[n - 2], rsgcd[1]);
	for (i = 1; i < n - 1; i++)
		ans = max(ans, gcd(sgcd[i - 1], rsgcd[i + 1]));
	cout << ans << endl;
}

Measured memory_bytes: 6144
n=int(input())
A=list(map(int,input().split()))
A.sort()
p=n//2
q=n//2-1
ave=sum(A)//n
ave2=ave+1
ans1=0
ans2=0
ans3=0
ans4=0
for i in range(n):
    ans1+=(A[i]-A[q])**2
    ans2+=(A[i]-A[p])**2
    ans3+=(A[i]-ave)**2
    ans4+=(A[i]-ave2)**2
print(min(ans1,ans2,ans3,ans4))

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

using namespace std;

int n;
int a[200005];
int ma1,ma2;

int main()
{
    scanf("%d",&n);
    ma2 = 0;
    ma1 = 0;
    int flag = -1;
    for(int i = 1;i <= n;i++)
    {
        scanf("%d",&a[i]);
        if(ma1 < a[i])
        {
            ma1 = a[i];
            flag = i;
        }
    }
    for(int i = 1;i <= n;i++)
    {
        if(ma2 < a[i] && i != flag)
            ma2 = a[i];
    }
    for(int i = 1;i <= n;i++)
    {
        if(i != flag)
            printf("%d\n",ma1);
        else
            printf("%d\n",ma2);
    }
    return 0;
}


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

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                int a = int.Parse(Console.ReadLine());
                Console.WriteLine(a*a*a);
            }
        }
    }
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if (a+b > c+d)
    {
	    cout << "Left" << endl;
    }
    else if (a+b == c+d)
    {
	    cout << "Balanced" << endl;
    }
    else
    {
	    cout << "Right" << endl;
    }

	

}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[12][12] = {};

void calc(ll K, ll i, ll j, string res){
    if(i == 1){
        // res += dp[i][j] - '0';
        print(res);
        exit(0);
        return;
    }
    rep(k,0,10){
        if(abs(j - k) <= 1){
            if(K <= dp[i-1][k]){
                res += (char) ('0' + k);
                calc(K, i-1, k, res);
            }else{
                K -= dp[i-1][k];
            }
        }
    }
    


}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    rep(i,0,10) dp[1][i] = 1;
    rep(i,2,11){
        rep(j,0,10){
            rep(k,0,10){
                if(abs(j-k) <= 1){
                    dp[i][j] += dp[i-1][k];
                }
            }
        }
    }
    string res = "";
    ll k = K;
    rep(i,1,11){
        rep(j,1,10){
            // print(i,j,dp[i][j]);
            if(k <= dp[i][j]){
                // print(i,j);
                // print(k);
                char c = '0' + j;
                res += c;
                calc(k, i, j, res);
                return 0;
            }else{
                k -= dp[i][j];
            }
        }
    }
    

}

Measured memory_bytes: 256
// In God We Trust


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

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second
signed main(){
  int n, k;
  cin >> n >> k;
  int h[n];
  for (int i = 0 ; i < n; i ++)
    cin >> h[i];
  long long dp[n];
  dp[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--){
    dp[i] = INT_MAX;
    for (int j = 0; j < k; j++){
      if (i + j + 1 < n)
	dp[i] = min (dp[i], abs(h[i] - h[i + j + 1]) + dp[i + j + 1]);
    }
  }
  cout << dp[0] << endl;
}

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

using i64 = int64_t;

i64 cumsum[200005]={0};

int divide(int left, int right, const vector<i64> &v){
    int ok = left, ng = right;
    while(abs(ok-ng) > 1){
        int mid = (ok + ng) / 2;
        if(cumsum[mid-1]-cumsum[left-1] < cumsum[right-1]-cumsum[mid-1])ok = mid;
        else ng = mid;
    }
    i64 d1 = abs(cumsum[right-1]-cumsum[ok-1] - (cumsum[ok-1]-cumsum[left-1]));
    i64 d2 = abs(cumsum[right-1]-cumsum[ok] - (cumsum[ok]-cumsum[left-1]));
    return (d1 < d2 ? ok : ok + 1);
}

int main(){
    int n;
    cin >> n;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 a;
        cin >> a;
        v.push_back(a);
    }
    for(int i=1;i<=n;++i){
        cumsum[i] = cumsum[i-1] + v[i-1];
    }

    i64 ans = LLONG_MAX;
    for(int i=3;i<=n-1;++i){
        i64 bc = divide(1, i, v), de = divide(i, n+1, v);
        i64 p = cumsum[bc-1] - cumsum[0], q = cumsum[i-1] - cumsum[bc-1], r = cumsum[de-1] - cumsum[i-1], s = cumsum[n] - cumsum[de-1];
        ans = min(ans, abs(max({p,q,r,s})-min({p,q,r,s})));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3440
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cstdlib>
#include<cassert>
#include<random>
using namespace std;
typedef unsigned long long int ull;




int main(){
    int n,ans=0;
    cin>>n;
    bool j=false;
    for(int i=1;i<10;i++){
        if(n==(int)pow(10,i)){j=true; break;}
    }
    if(j){ans=10;}
    else{
        for(int i=100;i>=0;i--){
            ans+=n/(int)pow(10,i);
            n-=n/(int)pow(10,i)*pow(10,i);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    for(;;){
        cin>>H>>W;
        if(H==0,W==0){
            break;
        }
        for(int i=1;i<=H;i++){
            for(int y=1;y<=W;y++){
             cout<<"#";   
            }
            cout<<endl;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3096
import sys
input=sys.stdin.readline

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

N = int(input())
A = [0] + list(map(int, input().split()))

B = {}
x = 0
for i in A:
    x += i
    if x not in B:
        B[x] = 1
    else:
        B[x] += 1

ans = 0
for i in B.values():
    if i >= 2:
        ans += combinations_count(i,2)

print(ans)


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;};
void qmod(ll &a,ll b){a=(a*b)%MOD;};
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll p,q;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll h,w;cin>>h>>w;
  vector<string> s(h);
  for(i=0;i<h;i++)cin>>s[i];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      
      if(s[i][j]=='.'){
        buf=0;
        for(p=-1;p<=1;p++){
          for(q=-1;q<=1;q++){
            try{
              if(s.at(i+p).at(j+q)=='#') buf++;
            }
            catch(out_of_range& ex){}
            //if(s.at(i+p).at(j+q)=='#') buf++;
          }
        }
        s[i][j]=buf+'0';

      }
      
    }
  }
  for(i=0;i<h;i++)cout<<s[i]<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<ll> s(n+1,0);
    rep(i,n) s[i+1]=s[i]+a[i];

    map<ll,ll> m;
    rep(i,n+1){
        m[s[i]]++;
    }

    ll ans=0;
    for(auto e : m){
        ans+=e.second*(e.second-1)/2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 18788
#include<iostream>
using namespace std;
int main(){
 int w,h,n;
 cin>>w>>h>>n;
 int xx=w, xn=0;
 int yx=h, yn=0;
 for(int i=0;i<n;i++){
  int x,y,a;
  cin>>x>>y>>a;
  switch(a){
  case 1: if(x>xn) xn=x; break;
  case 2: if(x<xx) xx=x; break;
  case 3: if(y>yn) yn=y; break;
  case 4: if(y<yx) yx=y; break;
  }
 }
 if(xx<xn)xx=xn;
 if(yx<yn)yx=yn;
 cout<<((xx-xn)*(yx-yn))<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()
#define DEBUG

int main()
{
	ll n;
	cin >> n;

	int ans;
	if(n % 2 == 0)
	{
		ans = (n / 2) - 1;
	}
	else
	{
		ans = (n - 1) / 2;
	}

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  ll k;
  cin >> s >> k;
  rep(i, s.size() - 1) {
    char c = s[i];
    if (c == 'a') {
      cout << 'a';
      continue;
    }
    if (c + k > 'z') {
      k -= (ll)('z' - c + 1);
      cout << 'a';
    } else {
      cout << c;
    }
  }
  char c = s[s.size() - 1];
  if (c + k > 'z') {
    k -= (ll)('z' + 1 - c);
    c = 'a';
  } else {
    c += k;
    k = 0;
  }
  cout << (char)(c + k % 26) << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.*;

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

    int N = sc.nextInt();

    int sum = 0;

    int[] a = new int[ N ] ;
    for(int i = 0 ; i < N ; i ++ ){
      a[i] = sc.nextInt();
      sum = sum + a[i];
    }
    //切上
    int average = (int) Math.round( (double) sum  / N   ) ;

    int cost = 0 ;
    for( int i = 0 ; i < N ; i ++ ){
      cost = cost + ( a[i] - average ) * ( a[i] - average ) ;
    }

    System.out.println( cost );
  }
}


Measured memory_bytes: 21844
// in the name if Allah
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll INF = 1<<30 ;
const ll N= 1e6 ;
#define f first
#define s second
ll n , m , k , dp[110][110] , mod = 1000000007 , level[N] ;
map<ll,ll>  mark ;
deque<ll> g[N] , qu ;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s1 ;
cin >> s1 ;
ll sum = 0 , ans = 0 ;
for(int i = 0 ; i < s1.size() ; i ++){
    if(s1[i] == 'B')sum ++ ;
    else ans += sum ;
}
cout << ans ;
    return 0;
}
 /*
              _     _   __
        /_\  (_    (_)  __)
       /   \  _) . (_) (__
 */


Measured memory_bytes: 674384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int a[200010], ans[200010];

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for (int i=0;i<n;i++) cin >> a[i];

    int xors = 0;
    for (int i=0;i<n;i++) xors ^= a[i];

    ans[0] = xors^a[0];
    for (int i=1;i<n;i++) ans[i] = a[i-1]^a[i]^ans[i-1];

    for (int i=0;i<n;i++) cout << ans[i] << " \n"[i==n-1];
}


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

long long cost[100001][3];
long long ans[100001][3];
using namespace std;


int main() {
    int n;
    cin >> n;
    
    for (int i=0;i<n;i++){
        for (int j=0;j<3;j++){
            cin >> cost[i][j];
        }
    }
    
    ans[0][0]=cost[0][0];
    ans[0][1]=cost[0][1];
    ans[0][2]=cost[0][2];
    
    for (int i=1;i<n;i++){
        ans[i][0]=max(ans[i-1][1],ans[i-1][2])+cost[i][0];
        ans[i][1]=max(ans[i-1][0],ans[i-1][2])+cost[i][1];
        ans[i][2]=max(ans[i-1][0],ans[i-1][1])+cost[i][2];
    }
    
    cout << max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2])) << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define Pll pair<llint,llint>
#define keta(a)  fixed << setprecision(a)
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
const llint INF = 100000000;

int main() {
	ll x, d, k;
	cin >> x >> k >> d;
	x = abs(x);
	ll c = x / d;
	ll ans = 0;
	if (c >= k)ans = x- (d * k);
	else {
		k -= c;
		x -= c * d;
		k %= 2;
		if (k)ans = d - x;
		else ans = x;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
int N = 100;

int main(){
  int n,i,j,l,k,p[N+1],m[N+1][N+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++){
    m[i][i] = 0;
  }

  for(j=2;j<=n;j++){
    for(i=1;i<=n-j+1;i++){
      l = i+j-1;
      m[i][l] = (1<<21);
      for(k=i;k<=l-1;k++){
      if(m[i][l]>m[i][k]+m[k+1][l]+p[i-1]*p[k]*p[l])m[i][l]=m[i][k]+m[k+1][l]+p[i-1]*p[k]*p[l];
      }
    }
  }

  printf("%d\n",m[1][n]);
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin>>N;
    ll dp[2020][2020],ans=0;
    vector<pair<ll,ll>> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i).first;
        A.at(i).second=i;
    }
    sort(A.begin(),A.end(),greater<pair<ll,ll>>());
    for(int j=1;j<=N;j++){
        dp[0][j]=dp[0][j-1]+A.at(j-1).first*(N-j-A.at(j-1).second);
    }
    for(int i=1;i<=N;i++){
        dp[i][0]=dp[i-1][0]+A.at(i-1).first*(A.at(i-1).second-i+1);
        for(int j=1;j<=N-i;j++){
            dp[i][j]=max(dp[i][j-1]+A.at(i+j-1).first*(N-j-A.at(i+j-1).second),dp[i-1][j]+A.at(i+j-1).first*(A.at(i+j-1).second-i+1));
        }
        ans=max(ans,dp[i][N-i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 26276
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;

  cin >> n;
  
  vector<int> v(n);
  REP(i,n){
    cin >> v[i];
  }

  int ans = 0;
  REP(i,n){
    for(int j = i + 1; j < n; ++j){
      ans += v[i] * v[j];
    }
  }

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



Measured memory_bytes: 256
INF = 10**9
N, K = map(int, input().split())
h = list(map(int, input().split()))
cost = [INF] * N
cost[0] = 0
for i in range(1, N):
  for j in range(1, min(i, K)+1):
    cost[i] = min(cost[i], cost[i-j] + abs(h[i] - h[i-j]))
print(cost[N-1])

Measured memory_bytes: 84788
#include<iostream>
#include<algorithm> 
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int N = 105;
const double pi = acos(-1.0);
const ll mod = 998244353;
void init(){
	ios::sync_with_stdio(false);cin.tie(0);
} 
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
ll a[N];
ll quickpow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
set<string>s;
int main()
{
	int n;string a;
	cin>>n;
	while(n--)
	{
		cin>>a;
		s.insert(a);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 19260
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
#=================================================
n=int(input())
A=INPUT()
count=0
for i in range(0,n,2):
    if (i+1)%2==1 and A[i]%2==1:
        count+=1
print(count)


Measured memory_bytes: 61952
n = int(input())
f = []
p = []

for i in range(n):
    f.append(list(map(int,input().split())))

for i in range(n):
    p.append(list(map(int,input().split())))

ans = -10**9
for i in range(1,2**10): #ビット全探索 
    opn = [0 for i in range(10)]
    scr = 0

    for j in range(10):
        memo = (i>>j)
    
    

        if memo&1:
            opn[j] = 1
    
    for k in range(n):
        cnt = 0
        for l in range(10):
            if opn[l] and f[k][l]:
                cnt += 1
        scr += p[k][cnt]

    ans = max(scr,ans)

print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String str = sc.next();
      String p = str.substring(0,1);
      String q = str.substring(1,2);
      String r = str.substring(2,3);
      if(p.equals(q)||q.equals(r)||r.equals(p)) 
        System.out.println("No");
      else System.out.println("Yes");
      sc.close();
    }
}


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

class MainClass
{
    public static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int Y = int.Parse(s[1]);

        List<int> list = new List<int>();

        for (int i = 0; i <= N;i++)
        {
            for (int j = 0; j <= N;j++)
            {
                if (i + j > N) break;
                int k = N - i - j;

                if(i * 10000 + j * 5000 + k * 1000 == Y)
                {
                    Console.WriteLine("{0} {1} {2}",i,j,k);
                    return;
                }
            }
        }


        Console.WriteLine("-1 -1 -1");
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    ll n,m;cin>>n>>m;
    char arr[n+1][m+1];
    for(ll i=1;i<=n;i++)
        for(ll j=1;j<=m;j++)
        cin>>arr[i][j];
    ll dp[n+1][m+1];

    memset(dp,0,sizeof(dp));
    dp[0][1]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            if(arr[i][j]!='#')
            {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
            else
                dp[i][j]=0;
        }
    }
    /*for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    cout<<dp[n][m];
}


Measured memory_bytes: 9088
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int a,b,c,d,ans = 0; 
    cin>>a>>b>>c>>d; 
    co(max(max(a*c,a*d),max(b*c,b*d))); 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3632
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

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

    if(n%10==3){
        cout << "bon"; 
    } else if(n%10==0||n%10==1||n%10==6||n%10==8){
        cout << "pon";
    } else{
        cout << "hon";
    }
}

Measured memory_bytes: 3636
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void YES()
{
	OUT("YES");
}
void NO()
{
	OUT("NO");
}
void YESNO(const bool cond)
{
	OUT(cond ? "YES" : "NO");
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}
void YesNo(const bool cond)
{
	OUT(cond ? "Yes" : "No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

// 階乗を計算 O(N) (N=10^7 で O(10^7))
ll factorial(ll n)
{
	for (ll i = n - 1; i > 1; --i)
		n *= i;
	return n;
}

// nCrを計算 O(N) (N=10^7 で O(10^7))
ll ncr(const ll n, ll r)
{
	if (r * 2 > n) r = n - r;

	ll dividend = 1, divisor = 1;

	for (ll i = 1; i <= r; ++i) {
		dividend *= n - i + 1;
		divisor *= i;
	}

	return dividend / divisor;
}

// 素数判定 O(sqrt(N)) (N=10^7 で O(10^3))
bool isprime(const ll num)
{
    if (num < 2) return false;
    if (num == 2) return true;
    if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (ll i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0) return false;
    }

    return true;
}

// 各桁の和を計算 O(logN) (N=10^7 で O(7))
ll digsum(ll n)
{
	ll sum = 0;
	while(n != 0){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

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

void Main()
{
	inll n;

	ll ans = 0;

	FOR(i, 1, n + 1)
	{
		if (i % 2 == 0) continue;
		ll num = 0;
		FOR(j, 1, i + 1)
		{
			if (i % j == 0) num++;
		}
		if (num == 8) ans++;
	}
	
	return OUT(ans);
}


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

using namespace std;

int main() {
    int n;
    cin >> n ;
    vector <int> a(n);
    
    for (int i = 0; i < n; i++) 
        cin >> a[i];
    int alice = 0, bob = 0;
   
    sort(a.begin(), a.end(),greater<int>());
    for (int i = 0; i < n; i++) {
        if ((i + 1) % 2)
            alice += a[i];
        else
            bob += a[i];
    }
    cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string st;
  cin>>st;
  if(st[0]=='7' || st[1]=='7' || st[2]=='7'){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef string::const_iterator State;

bool flag;
map<string,int> data;
P dat[1005][1005];
int datsize[1005];
int size[1005];

bool isname(char s){
	if(s>='a' && s<='z')return true;
	if(s>='A' && s<='Z')return true;
	return false;
}

string get_name(State &begin){
	string res="";
	while(isname(*begin)){
		res+=*begin;
		begin++;
	}
	return res;
}

int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin-'0';
		begin++;
	}
	return ret;
}

int expression(State &begin){
	if(isdigit(*begin)){
		return number(begin);
	}else{
		string name=get_name(begin);
		begin++;
		int ex=expression(begin);
		begin++;
		if(data.find(name)==data.end()){
			flag=true;
			return -1;
		}
		if(ex==-1)return -1;
		else{
			int num=-1;
			for(int i=0;i<datsize[data[name]];i++){
				if(dat[data[name]][i].first==ex){
					num=dat[data[name]][i].second;
				}
			}
			if(num==-1)flag=true;
			return num;
		}
	}
}

int kaiseki(State &begin){
	string name=get_name(begin);
	while(1){
		if(*begin=='['){
			begin++;
			if(isdigit(*begin)){
				int num=number(begin);
				begin++;
				if(*begin=='='){
					begin++;
					int ex=expression(begin);
					if(data.find(name)==data.end()){
						flag=true;
					}else{
						if(size[data[name]]>num){
							bool update=false;
							for(int i=0;i<datsize[data[name]];i++){
								if(dat[data[name]][i].first==num && !update){
									update=true;
									dat[data[name]][i].second=ex;
								}
							}
							if(!update){
								dat[data[name]][datsize[data[name]]]=P(num,ex);
								datsize[data[name]]++;
							}
						}else flag=true;
					}
				}else{
					if(data.find(name)!=data.end()){
						flag=true;
					}
					data[name]=data.size();
					size[data[name]]=num;
					break;
				}
			}else{
				int ex=expression(begin);
				begin++;
				begin++;
				int ex2=expression(begin);
				if(ex>=0 && ex<size[data[name]]){
					bool update=false;
					for(int i=0;i<datsize[data[name]];i++){
						if(dat[data[name]][i].first==ex && !update){
							update=true;
							dat[data[name]][i].second=ex2;
						}
					}
					if(!update){
						dat[data[name]][datsize[data[name]]]=P(ex,ex2);
						datsize[data[name]]++;
					}
				}else flag=true;
			}
		}else break;
	}
}

int main(void){
	int res=0,cnt=0;
	while(1){
		string str;
		cin >> str;
		if(str=="."){
			if(data.size()==0)break;
			else{
				printf("%d\n",res);
				data.clear();
				cnt=0;
				res=0;
				memset(dat,-1,sizeof(dat));
				memset(datsize,0,sizeof(datsize));
			}
		}else{
			State s=str.begin();
			flag=false;
			kaiseki(s);
			cnt++;
			if(flag){
				if(res==0){
					res=cnt;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 11152
#include <stdio.h>
 
void mergeSort(int *, int, int);
void merge(int *, int, int, int);
 
long long count = 0;
 
int main(){
  int S[200000], n, i, j;
 
  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &S[i]);
 
  mergeSort(S, 0, n);
 
  printf("%lld\n", count);
   
  return 0;
}
 
void mergeSort(int *A, int left, int right){
  int mid;
  if (left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
 
void merge(int *A, int left, int mid, int right){
  int n1, n2, L[100001], R[100001], i, j, k;
 
  n1 = mid - left;
  n2 = right - mid;
 
  for(i=0; i<n1; i++) L[i] = A[left + i];
  for(i=0; i<n2; i++) R[i] = A[mid + i];
  L[n1] = 1000000001;
  R[n2] = 1000000001;
  i = 0;
  j = 0;
 
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
      count += n1 - i;
    }
  }
}

Measured memory_bytes: 2156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <typename T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const vector<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
void ce(void){cerr << '\n';}
template <typename T>
void ce(const T n){cerr << n << '\n';}
template <typename T>
void cesp(const T n){cerr << n << ' ';}
template <typename T>
void ce(initializer_list<T> v){for(T i : v) cesp(i); ce();}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	string s;
	cin >> s;

	ll ans = 0, cnt = 0;
	rep(i, 3) {
		if (s[i] == 'R') cnt++;
		else
			cnt = 0;

		chmax(ans, cnt);
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 3600
from itertools import permutations
from heapq import heappush,heappop

INF=10**12

def dijkstra(G, start = 0, INF=INF):
    
    d = [INF for i in range(len(G))]
    d[start] = 0
    
    que = []
    heappush(que, (0, start))

    while len(que) != 0:
        p = heappop(que)
        v = p[1]
        
        if d[v] < p[0]:
            continue
            
        for u in G[v].keys():
            if d[u] > d[v] + G[v][u]:
                d[u] = d[v] + G[v][u]
                heappush(que, (d[u], u))
    
    return d

H,W=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]
A=[list(map(int,input().split())) for _ in range(H)]

G=[{} for _ in range(10)]
for i in range(10):
  for j in range(10):
    G[i][j] = c[i][j]

dist=[0]*10
for i in range(10):
  d = dijkstra(G,i)
  dist[i] = d[1]

ans=0
for i in range(H):
  for j in range(W):
    if A[i][j] != -1:
      ans += dist[A[i][j]]

print(ans)

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

int main(){
    int ans = 0;
    string s;
    cin>>s;
    int i, k = s.size();
    for(i=0; i<k; i++){
        if(s[i]=='+'){
            ans++;
        }
        else{
            ans--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  set<int> st;
  rep(i,N){
    int x;cin >> x;
    st.insert(x);
  }
  YESNO(st.size()==N);
  return 0;
}


Measured memory_bytes: 9600
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

class Combination {
public:
    vector <ll> fac, inv, fiv;

    Combination(int N) : fac(N + 1), inv(N + 1), fiv(N + 1) {
        fac[0] = inv[0] = fiv[0] = fac[1] = inv[1] = fiv[1] = 1;
        for (ll i = 2; i <= N; i++) {
            fac[i] = fac[i - 1] * i % MOD; // n!
            inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; // n^-1
            fiv[i] = fiv[i - 1] * inv[i] % MOD; // (n!)^-1
        }
    }

    ll C(ll n, ll k) {
        if (k < 0 || n < k) return 0;
        return fac[n] * fiv[k] % MOD * fiv[n - k] % MOD;
    }
};

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

    int n, k;
    cin >> n >> k;

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

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

    Combination com(100005);

    ll ans = 0;
    for (int i = k - 1; i < n; i++) {
        ans = (ans + com.C(i, k - 1) * a[i] % MOD) % MOD;
    }

    sort(a.begin(), a.end(), greater<ll>());
    for (int i = k - 1; i < n; i++) {
        ans = (ans + MOD - com.C(i, k - 1) * a[i] % MOD) % MOD;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3960
#include<stdio.h>

void print(int array[], int n){
  int i;
  for(i=0;i<=n-1;i++){
    if(i>0)printf(" ");
    printf("%d", array[i]);
  }
  printf("\n");
}

int main(){
  int n, i, array[100], flag=1, j, tmp, count=0;

  scanf("%d", &n);
  for(i=0;i<=n-1;i++)scanf("%d", &array[i]);

  while(flag==1){
    flag = 0;
    for(j=n-1;j>=1;j--){
      if(array[j]<array[j-1]){
        tmp = array[j];
        array[j] = array[j-1];
        array[j-1] = tmp;
        count++;
        flag = 1;
      }
    }
  }
  print(array, n);
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 604