akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n,greater<int>());
    ll x=1,b[n],c[n],j=0,k=0;
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1])
            x++;
        else{
            b[j++]=a[i];
            c[k++]=x;
            x=1;
        }
    }
    b[j]=a[n-1];
    c[k]=x;
    for(int i=0;i<k;i++){
        if(c[i]>=4){
            cout<<b[i]*b[i]<<endl;
            return 0;
        }
        else if(c[i]>=2){
            for(int p=i+1;p<=k;p++){
                if(c[p]>=2){
                    cout<<b[i]*b[p]<<endl;
                    return 0;
                }
            }
            break;
        }
    }
    cout<<"0"<<endl;
}


Measured memory_bytes: 5952
#include<bits/stdc++.h>
using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main() {
    IOS;
    int n,i,j,temp1,temp2;
    cin>>n;
    int a[n+1];
    ll pre[n+1];
    pre[0]=0;
    REP(i,1,n) cin>>a[i],pre[i]=a[i]+pre[i-1];
    vector<ll> mi(n+1,1e18),ma(n+1,0);
    i=1;
    j=2;
    while(j<=n){
    	while(i<j-1&&max(pre[j]-pre[i],pre[i])-min(pre[j]-pre[i],pre[i])>max(pre[j]-pre[i+1],pre[i+1])-min(pre[j]-pre[i+1],pre[i+1])) i++;
    	mi[j]=min(pre[j]-pre[i],pre[i]);
    	ma[j]=max(pre[j]-pre[i],pre[i]);
    	j++;
    }
    i=n;
    j=n-1;
    while(j>0){
    	while(i>j+1&&max(pre[n]-pre[i],pre[i]-pre[j])-min(pre[n]-pre[i],pre[i]-pre[j])>max(pre[n]-pre[i-1],pre[i-1]-pre[j])-min(pre[n]-pre[i-1],pre[i-1]-pre[j])) i--;
    	mi[j]=min({mi[j],pre[i]-pre[j],pre[n]-pre[i]});
    	ma[j]=max({ma[j],pre[n]-pre[i],pre[i]-pre[j]});
    	j--;
    }
    ll ans=1e18;
    REP(i,2,n-1){
    	ans=min(ans,ma[i]-mi[i]);
    }
    cout<<ans;
   	return 0;   
} 

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

l = set()
o = ''
for _ in range(n):
    c = input().split()
    if c[0] == 'insert':
        l.add(c[1])
    elif c[0] == 'find':
        o += ('yes' if c[1] in l else 'no') + "\n"

print(o, end='')



Measured memory_bytes: 33988
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	if((B-A)%2==0) {
		cout<<(B-A)/2<<endl;
	}
	else {
		ll a=(N-B)+1+(B-A)/2;
		ll b=(A-1)+1+(B-A)/2;
		
		cout<<min(a,b)<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
require 'pp'

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N = gets_i
a_list = gets_i_list

colors = Array.new(8){false}
free_count = 0

a_list.each do |a|
  if       1 <= a && a <=  399
    colors[0] = true
  elsif  400 <= a && a <=  799
    colors[1] = true
  elsif  800 <= a && a <= 1199
    colors[2] = true
  elsif 1200 <= a && a <= 1599
    colors[3] = true
  elsif 1600 <= a && a <= 1999
    colors[4] = true
  elsif 2000 <= a && a <= 2399
    colors[5] = true
  elsif 2400 <= a && a <= 2799
    colors[6] = true
  elsif 2800 <= a && a <= 3199
    colors[7] = true
  else
    free_count += 1
  end
end

color_count = colors.count(true)

min = color_count > 0 ? color_count : 1
max = color_count + free_count

puts [min, max].join(" ")


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;


int main()
{
    ll n,c;
    cin >> n >> c;
    vector<pll> sushi(n);
    rep(i,n){
        ll x, v;
        cin >> x >> v;
        sushi[i] = mp(x, v);
    }
    vll migione(n + 1, 0), migitwo(n + 1, 0), hidarione(n + 1, 0), hidaritwo(n + 1, 0);
    ll now = 0;
    rep(i,n){
        now += sushi[i].S;
        migione[i + 1] = max(now - sushi[i].F, migione[i]);
        migitwo[i + 1] = max(now - 2 * sushi[i].F, migitwo[i]);
    }
    now = 0;
    repr(i,n-1,-1){
        now += sushi[i].S;
        hidarione[i] = max(now - c + sushi[i].F, hidarione[i + 1]);
        hidaritwo[i] = max(now -2*( c - sushi[i].F), hidaritwo[i + 1]);
    }

    ll ans = max(migione[n], hidarione[n]);
    
    rep(i,n+1){
        ans = max(ans, max(migitwo[i] + hidarione[i], migione[i] + hidaritwo[i]));
    }
    /*
    rep(i,n+1){
        cout << migione[i] << " ";
    }
    cout << endl;
    rep(i, n + 1)
    {
        cout << migitwo[i] << " ";
    }
    cout << endl;
    rep(i, n + 1)
    {
        cout << hidarione[i] << " ";
    }
    cout << endl;
    rep(i, n + 1)
    {
        cout << hidaritwo[i] << " ";
    }
 
    cout << endl;    */

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,t=0,h=0;
  cin >> n;
  string a,b;
  for(int i=0; i<n; i++) {
      cin >> a >> b;
      if(a<b) {
          h+=3;
      }
      else if(a>b) {
          t+=3;
      }
      else {
          t+=1,h+=1;
      }
  }
  cout << t << " " << h << endl;
}


Measured memory_bytes: 3180
import sys
from math import sqrt

inf = 1<<30

def solve():
    while 1:
        h, w = map(int, sys.stdin.readline().split())

        if h == w == 0:
            return

        L = h**2 + w**2
        maxL = inf
        ansx = inf
        ansy = inf

        for x in range(1, L):
            if L - x**2 < 0:
                break

            y = nibutan(L - x**2)

            if y <= x:
                break

            if x**2 + y**2 == L:
                if h < x:
                    ansx = x
                    ansy = y
                    break
                else:
                    y += 1

            if x**2 + y**2 < maxL:
                maxL = x**2 + y**2
                ansx = x
                ansy = y

        print(ansx, ansy)

def nibutan(a):
    top = inf
    btm = 0

    while top - btm > 1:
        mid = (top + btm) // 2

        if mid**2 >= a:
            top = mid
        else:
            btm = mid

    return top

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7808
import java.util.*;

class Main{
    static long Mod = 1000000000+7;
    static int maxn = 200000;
    static long[] fac = new long[maxn+1];
    static long[] inv = new long[maxn+1];
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        if(isPrime(M)){
            System.out.println(M);
            System.exit(0);
        }
        ini();
        HashMap<Integer,Integer> dic = new HashMap<>();
        for(int i=2;M>=i;i++){
            int cnt = 0;
            if(M%i==0){
                while(M%i==0){
                    cnt++;
                    M = M/i;
                }
                dic.put(i,cnt);
                if(isPrime(M)){
                    dic.put(M,1);
                    break;
                }
            }
        }
        long ans = 1;
        for(Integer w:dic.keySet()){
            int cnt = dic.get(w);
            ans = ans*com(N-1+cnt,N-1)%Mod;
        }
        System.out.println(ans);
    }

    static void ini(){
        fac[0]=1;
        for(int i=1;i<=maxn;i++) fac[i]=fac[i-1]*i%Mod;
        inv[0]=1;
        inv[maxn] = pow(fac[maxn],Mod-2);
        for(int i=maxn-1;i>=1;i--) inv[i]=inv[i+1]*(i+1)%Mod;
    }
    static long com(int m, int n){
        return fac[m]*inv[n]%Mod*inv[m-n]%Mod;
    }
    static long pow(long base, long p){
        long ans = 1;
        while(p>0){
            if(p%2==1) ans = ans*base%Mod;
            base = base*base%Mod;
            p /= 2;
        }
        return ans;
    }
    static boolean isPrime(int n){
        if(n==1) return false;
        int up = (int) Math.sqrt(n)+1;
        for(int i=2;i<=up;i++){
            if(n%i==0) return false;
        }
        return true;
    }
}


Measured memory_bytes: 27348
#include<bits/stdc++.h>
using namespace std;
int a,c;
int main(){
  cin>>a;
  vector<int> b(a);
  for(int i=0;i<a-1;i++){
    cin>>c;
    b[c-1]++;
  }
  for(int i=0;i<a;i++)cout<<b[i]<<endl;
}

Measured memory_bytes: 4048
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	Vl A;
	A.push_back(a * c);
	A.push_back(a * d);
	A.push_back(b * c);
	A.push_back(b * d);
	ll ans = -1 * (1e18);
	rep(i, 4) {
		ans = max(ans, A[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3628
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Playing Tag on Tree
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int BN = 17;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;

/* global variables */

vi nbrs[MAX_N];
int ps[MAX_N][BN], ds[MAX_N], cns[MAX_N];
int maxds[MAX_N], maxcs[MAX_N];

/* subroutines */

inline int ancestor(int u, int d) {
  for (int i = 0, bi = 1; u >= 0 && bi <= d; i++, bi <<= 1)
    if (d & bi) u = ps[u][i];
  return u;
}

/* main */

int main() {
  int n, s, t;
  scanf("%d%d%d", &n, &s, &t);
  s--, t--;

  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
  }

  ps[t][0] = -1, ds[t] = 0;
  qi q;
  q.push(t);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int up = ps[u][0], vd = ds[u] + 1;

    for (int i = 0; i < BN - 1; i++)
      ps[u][i + 1] = (ps[u][i] >= 0) ? ps[ps[u][i]][i] : -1;

    vi &nbru = nbrs[u];
    for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int v = *vit;
      if (v != up) {
	ps[v][0] = u, ds[v] = vd;
	cns[u]++;
	q.push(v);
      }
    }
  }

  memset(maxds, -1, sizeof(maxds));
  memset(maxcs, -1, sizeof(maxcs));

  for (int u = 0; u < n; u++)
    if (cns[u] == 0) maxds[u] = ds[u], q.push(u);

  while (! q.empty()) {
    int u = q.front(); q.pop();
    int up = ps[u][0];
    if (up >= 0) {
      if (maxds[up] < maxds[u])
	maxds[up] = maxds[u], maxcs[up] = u;
      if (--cns[up] == 0) q.push(up);
    }
  }
  //for (int u = 0; u < n; u++)
  //printf("[%d]=%d,%d,%d\n", u, ds[u], maxds[u], maxcs[u]);

  int cnt = 0;
  while (s != t) {
    // takahashi moves
    if (maxcs[s] < 0 || ds[s] - ds[t] > 2)
      s = ps[s][0];
    else
      s = maxcs[s];
    if (s == t) break;

    // aoki moves
    if (ds[s] - ds[t] == 1)
      t = s;
    else
      t = ancestor(s, ds[s] - ds[t] - 1);
    cnt++;
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 14208
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
    int N, W; cin >> N >> W;
    int w[N + 1], v[N + 1];
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];

    ll dp[N + 1][W + 1] = {};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j < w[i]) {
                dp[i + 1][j] = dp[i][j];
            } else {
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79104
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N] , b[N] , n , cnt , res;
int main(){
	cin >> n;
	for(int i = 1; i <= n; i ++) scanf("%d" , &a[i]);
	for(int i = 1; i < n; i ++){
		if(a[i] >= a[i + 1]) cnt ++;
		else cnt = 0;
		res = max(res , cnt);
	}
	cout << res << "\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    ll a, b, x;
    cin >> a >> b >> x;
    b -= (b % x);
    if (a % x) a += x-(a % x);
    cout << (b-a)/x+1 << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3688
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

class ModInt {
public:
    long long x;
    constexpr ModInt(const long long x=0) : x((x+MOD)%MOD) {}
    constexpr ModInt& operator+=(const ModInt rhs) {
        x += rhs.x;
        if (x >= MOD) x -= MOD;
        return *this;
    }
    constexpr ModInt operator+(const ModInt rhs) const {
        return ModInt(*this) += rhs; 
    }

    constexpr ModInt& operator-=(const ModInt& rhs) {
        x -= rhs.x;
        if (x < 0) x += MOD;
        return *this;
    }
    constexpr ModInt operator-(const ModInt rhs) const {
        return ModInt(*this) -= rhs; 
    }

    constexpr ModInt& operator*=(const ModInt& rhs) {
        x = x * rhs.x % MOD;
        return *this;
    }
    constexpr ModInt operator*(const ModInt rhs) const {
        return ModInt(*this) *= rhs; 
    }

    constexpr ModInt& operator/=(const ModInt& rhs) {
        ModInt div = powmod(rhs, MOD - 2);
        (x *= div.x) %= MOD;
        return *this;
    }
    constexpr ModInt operator/(const ModInt rhs) const {
        return ModInt(*this) /= rhs; 
    }

    constexpr ModInt powmod(ModInt m, long long p) {
        if (p == 0) ModInt(1);
        ModInt tmp = powmod(m, p / 2);
        if (p & 1) return tmp * tmp * m;
        else return tmp * tmp;
    }

    friend ostream& operator<<(ostream& os, const ModInt &rhs) {
        os << rhs.x;
        return os;
    }
};

using modi = ModInt;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    modi ans;
    for (ll i = k; i <= n + 1; i++) {
        ll low = i * (i - 1) / 2;
        ll high = n * i - low;
        ans += modi(high - low + 1);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stdlib.h>
using namespace std;

vector<int> W;

int sum(int begin, int end)
{
	int sum = 0;
	for (int i = begin; i <= end; i++)
	{
		sum += W[i];
	}

	return sum;
}

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

	W.resize(N);
	for (int i = 0; i < N; i++)
	{
		cin >> W[i];
	}

	vector<int> ans(N);
	for (int i = 0; i < N; i++)
	{
		int front = sum(0, i);
		int back = sum(i + 1, N - 1);
		
		ans[i] = abs(front - back);
	}

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

	cout << ans[0];

	return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=998244353;

int main(){
  ll N,T;
  cin>>N>>T;
  vector<ll> A(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
  }
  vector<ll> maxi(N),mini(N);
  mini[0] = A[0];
  for(int i(1);i<N;i++){
    mini[i] = min(mini[i-1],A[i]);
  }
  maxi[N-1] = A[N-1];
  for(int i(N-2);i>=0;i--){
    maxi[i] = max(maxi[i+1],A[i]);
  }
  ll ans(0);
  for(int i(0);i<N-1;i++){
    ll tmp = maxi[i+1] - mini[i];
    ans = max(ans,tmp);
  }
  map<ll,int> m;
  int cnt(0);
  for(int i(0);i<N;i++){
    if(m[A[i]-ans] != 0){
      cnt++;
      m[A[i]-ans]--;
    }else{
      m[A[i]]++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 15104
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
totalA=0
totalB=0
C=[0]*100
D=[0]*100
max=0
for i in range(N):
    totalA+=A[i]
    C[i]=totalA
    totalB += B[i]
    D[i] = totalB

for i in range(N):
    if i==0:
        if max<D[N-1]+C[0]:
            max=D[N-1]+C[0]
    elif i==N-1:
        if max<C[i]+D[i]-D[i-1]:
            max=C[i]+D[i]-D[i-1]
    else:
        if max<C[i]+D[N-1]-D[i-1]:
            max=C[i]+D[N-1]-D[i-1]

print(max)

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

int main(void) {
	int x;
	scanf("%d",&x);
	if(x<=599){
		printf("8");
	}
	else if(x<=799){
		printf("7");
	}
	else if(x<=999){
		printf("6");
	}
	else if(x<=1199){
		printf("5");
	}
	else if(x<=1399){
		printf("4");
	}
	else if(x<=1599){
		printf("3");
	}
	else if(x<=1799){
		printf("2");
	}
	else if(x<=1999){
		printf("1");
	}
}


Measured memory_bytes: 1664
S = input()

d = {}
for s in S:
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

flag = 1
for v in d.values():
    if v != 2:
        flag = 0

if flag:
    print('Yes')
else:
    print('No')

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

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    for (int i = 0; i < k; i++){
        cout << s;
        if (i != n - 1) cout << " ";
        else cout << endl;
    }
    for (int i = k; i < n; i++){
        if (s == 1e9) cout << (s - 1);
        else cout << (s + 1);
        if (i != n - 1) cout << " ";
        else cout << endl;
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

int a, b;
char op;

int main()
{
    cin >> a >> op >> b;
    if(op == '+')  printf("%d", a + b);
    else  printf("%d", a - b);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (2147483647)
#define mod (1000000007)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)

void solve()
{
    int N,Q;cin>>N>>Q;
    ll a[N];REP(i,N)cin>>a[i];
    ll x;
    REP(i,Q){
        cin>>x;
        ll sum=0,ans=0;
        int r=0;
        REP(l,N){
            while(r<N&&sum+a[r]<=x){
                sum+=a[r];
                r++;
            } 
            ans+=r-l;
            if(r==l)r++;
            else sum-=a[l];
        }
        cout<<ans<<endl;
    }    
}

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


Measured memory_bytes: 3988
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
	int n, a, num[100000] = { 0 },max = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		num[a]++;
	}
	for (int j = 1; j < 99999; j++) {
		if (num[j - 1] + num[j] + num[j + 1]  > max)max = num[j - 1] + num[j] + num[j + 1];
	}
	printf("%d\n", max);
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
    if(a%b) {
        return gcd(b, a % b);
    } else {
        return b;
    }
}

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

int main()
{
    ll a, b;
    int c, d;
    cin >> a >> b >> c >> d;

    ll ans = b - a + 1;

    ll rd = b / d;
    ll ld = b / c;
    ll dd = rd + ld - b / lcm(c, d);

    ll rc = (a - 1) / d;
    ll lc = (a - 1) / c;
    ll cc = rc + lc - (a - 1) / lcm(c, d);

    ans -= dd - cc;

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



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


Measured memory_bytes: 3080
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;




int main(){	
	ll n,k;cin>>n>>k;
	n%=k;
	cout<<min(n,k-n)<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
template< typename flow_t >
struct FordFulkerson {
  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
    int idx;
  };
 
  vector< vector< edge > > graph;
  vector< int > used;
  const flow_t INF;
  int timestamp;
 
  FordFulkerson(int n) : INF(numeric_limits< flow_t >::max()), timestamp(0) {
    graph.resize(n);
    used.assign(n, -1);
  }
 
  void add_edge(int from, int to, flow_t cap, int idx = -1) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false, idx});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true, idx});
  }
 
  flow_t dfs(int idx, const int t, flow_t flow) {
    if(idx == t) return flow;
    used[idx] = timestamp;
    for(auto &e : graph[idx]) {
      if(e.cap > 0 && used[e.to] != timestamp) {
        flow_t d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
 
  flow_t max_flow(int s, int t) {
    flow_t flow = 0;
    for(flow_t f; (f = dfs(s, t, INF)) > 0; timestamp++) {
      flow += f;
    }
    return flow;
  }
 
  void output() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e : graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};
 
 
int main() {
    ll N;
    cin >> N;
    int s= N*2;int t=s+1;
 
    FordFulkerson< int > g(t+1);
    vector<pair<int,int>> A;
    vector<pair<int,int>> C;
    for(int i=0;i<N;i++){
        int a,b;
        cin >> a >>b;
        A.emplace_back(a,b);
        g.add_edge(s,i,1);
    }
    for(int i=0;i<N;i++){
        int c,d;
        cin >> c >> d;
        C.emplace_back(c,d);
        g.add_edge(N+i,t,1);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(A[i].first < C[j].first && A[i].second < C[j].second){
                g.add_edge(i,N+j,1);
            }
        }
    }
    cout << g.max_flow(s,t) << endl;
    return 0;
}

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

int main() {
  string str1, str2;
  cin >> str1 >> str2;
  int a,b;
  cin >> a >> b;
  string str3;
  cin >> str3;
  
  if(str3 == str1){
    a = a-1;
  }
  else if(str3 == str2){
    b = b-1;
  }
  
  cout << a <<" " << b <<  endl;
}
  




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

int main()
{
    int n, x, cnt;
    while (cin >> n >> x && n + x != 0)
    {
        cnt = 0;
        for (int i = 1; i <= n; ++i)
        {
            for (int j = i + 1; j <= n; ++j)
            {
                for (int k = j + 1; k <= n; ++k)
                {
                    if (i + j + k == x)
                    {
                        ++cnt;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
int main(){
	int S,h,m,s;
	
	scanf("%d",&S);
	
	h=S/3600;
	m=(S%3600)/60;
	s=S%60;
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}


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

int main(void){
    int n;
    cin >> n;
    
    bool d[101] = {false};
    int input;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        d[input] = true; 
    }
    
    int cnt = 0;
    for(i = 1; i <= 100; i++){
        if(d[i]){
            cnt++;
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define MAX_N_BIT 222222
long long bit[MAX_N_BIT + 1];
long long n = MAX_N_BIT;
long long sum(long long i)
{
    i++;
    long long s = 0;
    while (i > 0)
    {

        s += bit[i];
        i -= i & -i;
    }
    return s;
}
void add(long long i, long long x)
{
    i++;
    while (i <= n)
    {

        bit[i] += x;
        i += i & -i;
    }
}
int main()
{
    ll n, d, a;
    cin >> n >> d >> a;
    vl x(n), h(n);
    rp(i, 0, n) cin >> x[i] >> h[i];
    pair<ll, ll> pi[n];
    rp(i, 0, n) pi[i] = make_pair(x[i], (h[i] + a - 1) / a);
    sort(pi, pi + n);
    vl xx(n);
    rp(i, 0, n) xx[i] = pi[i].first;
    ll ans = 0;
    ll now[n + 1];
    za(n + 1, now);
    rp(i, 0, n)
    {
        if (sum(i) < pi[i].second)
        {
            ans += (pi[i].second - sum(i));
            ll tt = pi[i].second - sum(i);
            add(i, tt);
            ll k = upper_bound(be(xx), 2 * d + xx[i]) - xx.begin();
            add(k, -tt);
        }
        //ca(n, now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
def main():
    N = int(input())
    X = [int(x) for x in input().split()]
    avgX = round(sum(X) / len(X))
    diff = 0
    for i in range(N):
        diff += (X[i] - avgX)**2
    print(diff)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61992
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    print(N * (N - 1) // 2)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
from sys import stdin, stdout
import math
import bisect
import re

n, k, c = map(int, stdin.readline().strip().split())
s = stdin.readline().strip()

arr1 = [-1] * 200005
arr2 = [-1] * 200005

cnt = 1
day = 0
while day<len(s):
    if s[day] == 'o':
        arr1[day] = cnt
        cnt += 1
        day+=c
    if cnt > k:
        break
    day+=1

cnt = k
day = len(s) - 1
while day>=0:
    if s[day] == 'o':
        arr2[day]=cnt
        cnt-=1
        day-=c
    if cnt <= 0:
        break
    day-=1

for i in range(len(s)):
    if arr1[i]==arr2[i] and arr1[i]!=-1:
        stdout.writelines('%d\n' % (i+1))

Measured memory_bytes: 90828
import java.util.*;
import java.lang.*;

public class Main {
    static final int INF = 1000000000;             
    static final int MAXN = 111111; 
    
    public static void main(String[] args) throws Exception {                
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[][] a = new int[n][2];
        int[] parentOf = new int[n];
        for (int i = 0; i < parentOf.length; ++i) parentOf[i] = -1;
        for (int i = 0; i < n; ++i) {
            int id = input.nextInt();
            a[id][0] = input.nextInt();
            a[id][1] = input.nextInt();
            if (a[id][0] >= 0) parentOf[a[id][0]] = id;
            if (a[id][1] >= 0) parentOf[a[id][1]] = id;
        }
        int root = 0;
        for (int i = 0; i < n; ++i) {
            if (parentOf[i] == -1) root = i;
        }
        System.out.println("Preorder");
        preorder(root, a);
        System.out.println("");
        System.out.println("Inorder");
        inorder(root, a);
        System.out.println("");
        System.out.println("Postorder");
        postorder(root, a);
        System.out.println("");                
    }              
    
    static void preorder(int u, int[][] a) {
        System.out.print(" " + u);
        if (a[u][0] >= 0) preorder(a[u][0], a);
        if (a[u][1] >= 0) preorder(a[u][1], a);
    }
    
    static void inorder(int u, int[][] a) {
        if (a[u][0] >= 0) inorder(a[u][0], a);
        System.out.print(" " + u);
        if (a[u][1] >= 0) inorder(a[u][1], a);
    }
    
    static void postorder(int u, int[][] a) {
        if (a[u][0] >= 0) postorder(a[u][0], a);
        if (a[u][1] >= 0) postorder(a[u][1], a);
        System.out.print(" " + u);
    }
}

Measured memory_bytes: 18072
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

int main(){
    long A, B, K;
    
    cin >> A >> B >> K;

    long remained = K - A;
    if (remained < 0){
        remained = 0;
    }
    A = A - K;
    if (A < 0){
        A = 0;
    }
    B = B - remained;
    if (B < 0){
        B = 0;
    }
    cout << A << " " << B << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int n = S.length();

    int[] dp = new int[n + 1];
    Map<Integer, HashSet<String>> suffixes = new HashMap<>();
    HashSet<String> set = new HashSet<>();
    set.add("");
    suffixes.put(0, set);
    // Checking i
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j < 4 && i - j >= 0; j++) {
        // Cut at h = i - j.
        int h = i - j;
        String cut = S.substring(h, i);
        if (suffixes.get(h).stream().anyMatch(s -> !s.equals(cut))) {
          int score = dp[h] + 1;

          if (dp[i] > score) {
            continue;
          }

          HashSet<String> suffix = (score > dp[i]) ? new HashSet<>() : suffixes.get(i);
          suffix.add(cut);
          suffixes.put(i, suffix);
          dp[i] = score;
        }
      }
    }
    System.out.println(dp[n]);
  }
}


Measured memory_bytes: 152976
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef pair<long long, long long>pll;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 200050;
const double pi = acos(-1); constexpr double EPS = 1e-12;
constexpr ll INF = 1e16;
void yes(bool c) { if (c)print("Yes"); else print("No"); };



string S[1000010];
bool comp(const pii &a, const pii &b) {
	return a.first + a.second > b.first + b.second;
}
void solve() {
	int N; cin >> N;
	REP(i, N)cin >> S[i];
	vector<pii>plus, minu;
	REP(i, N) {
		int mn = 0, res = 0;
		REP(j, S[i].size()) {
			if (S[i][j] == '(') {
				res++;
			}
			else {
				res--;
				mn = min(mn, res);
			}
		}
		if (res <= 0)minu.push_back({ -mn,res });
		else plus.push_back({ -mn,res });
	}
	VSORT(plus);
	sort(all(minu),comp);
	int now = 0;
	bool ok = true;
	for (auto p : plus) {
		int need = p.first, ad = p.second;
		if (now < need)ok = false;
		now += ad;
	}  
	for (auto p : minu) {
		int need = p.first, ad = p.second;
		if (now < need)ok = false;
		now += ad;
		if (now < 0)ok = false;
	}

	if (!ok)print("No");
	else yes(now == 0);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 50284
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
int main(){
int N, ans=0; cin >> N; int L[N];
REP(i, N){ cin >> L[i]; }
REP(i, N){ for(int j=i+1; j<N-1; j++){ for(int k=j+1; k<N; k++){
if(L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]&&L[i]+L[j]>L[k]&&L[j]+L[k]>L[i]&&L[k]+L[i]>L[j]){ ans++; }
}}}
cout << ans << "\n";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    string n;
    cin>>n;
    ll sum = 0;
    for(ll i=0; i<n.size(); i++)
    {
        sum += (int)n[i] - int('0');
    }
    // cout<<sum<<'\n';
    if(sum%9)
    {
        cout<<"No"<<'\n';
    }
    else
    {
        cout<<"Yes"<<'\n';
    }
    
}

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

int main() {
  int N,Y;
  int a=-1,b=-1,c=-1;
  cin >> N >> Y;
  Y = Y/1000;
  int z;
  for (int x=0; x<=N; x++) {
    for (int y=0; y<=N-x; y++) {
      z = N-x-y;
      if (10*x+5*y+z==Y) {
        a=x;b=y;c=z;
        goto label;
      }
    }
  }
  label:;
  cout << a << " " << b << " " << c << endl; 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,a[]={0,1,2,1,3,1,3,1,1,3,1,3,1};
  cin>>x>>y;
  if(a[x]==a[y])cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
cnt = 0
flag = False

for i in range(n):
  da, db = map(int, input().split())
  if da == db:
    cnt += 1
  else:
    cnt = 0
  
  if cnt == 3:
    flag = True
    
if flag:
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  vector<string>s(51);
  vector<int>x={1,1,1,0,0,-1,-1,-1};
  vector<int>y={1,0,-1,1,-1,1,0,-1};
  cin >> h >> w;
  for(int i=0;i<h;i++)cin >> s.at(i);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int ans=0;
      if(s[i][j]=='#')continue;
      for(int k=0;k<8;k++){
        int ni,nj;
        ni=i+x[k];nj=j+y[k];
        if(ni<0||h<=ni)continue;
        if(nj<0||w<=nj)continue;
        if(s[ni][nj]=='#')ans++;
      }
      s[i][j]=char(ans+'0');
    }
    cout << s[i] << endl;
  }
}

Measured memory_bytes: 256
#n = int(input()) #入力
#a, b = (int(x) for x in input().split())
#a, b = map(int, input().split())

#a = [int(x) for x in input().split()]
#a = list(map(int, input().split()))
#a = [list(map(int,input().split(" "))) for i in range(N)]   #2次元


#a.sort() # C++ の sort(a.begin(), a.end());
#a.append(3) # C++ の a.push_back(3);


#exit(0) # return 0 的な。終了できる。
## 整数の切り捨て除算は // (ダブルスラッシュ)


#a[始まりの位置: 終わりの位置: スライスの増分] # (a は配列)


#import numpy as np  #importに100 ms 程度かかる。
import math
import copy
import string
#math.gcd(a, b) で、gcd 計算できる。
#math.pi は円周率。

INF = int(10**18) #べき乗 C++ の pow(10, 18) or 1e18;
pi = math.pi

MOD = 1000000007
#MOD = 1000000009
#MOD = 998244353




#繰り返し2乗法
#N^aの、Mで割った余りを求める。
def my_pow(N, a, M):
    if(a == 0):
        return 1
    else:
        if(a % 2 == 0):
            tempo = my_pow(N, a/2, M)
            return (tempo * tempo) % M
        else:
            tempo = my_pow(N, a - 1, M)
            return (tempo * N) % M




#N_C_a を M で割った余り
def my_combination(N, a, M):
    res = 1

    for i in range(0, a):
        res *= N - i
        res %= M

    for i in range(0, a):
        res *= my_pow(i + 1, M - 2, M)
        res %= M

    return res




#N_C_i を M で割った余りを、v[i] に代入する。
def my_combination_table(N, M, v):
    if(len(v) < N + 1):
        l = N + 1 - len(v)
        tempo = [1] * l
        v.extend(tempo)

    for i in range(1, N + 1):
        v[i] = v[i - 1] * (N - (i - 1))
        v[i] %= M

        v[i] *= my_pow(i, M - 2, M)
        v[i] %= M

    return




#math.factorial で階乗は計算できる。
#math.gcd で gcd は計算できる。
#np.gcd.reduce(A) #(Aは配列) で、Aの全ての要素の gcd が計算できる。



N = int(input())
res = 10 ** N - 2 * (9 ** N) + 8 ** N
res %= MOD

print(res)









Measured memory_bytes: 11836
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 1000 + 47;
struct Item
{
	int i, pos, left;
	Item(int i1, int pos1, int left1)
	{
		i = i1;
		pos = pos1;
		left = left1;
	}

	Item() {}
};

int A[MAX];
Item X[MAX];

bool cmp(Item a, Item b)
{
	return a.pos < b.pos;
}

void no()
{
	cout << "No" << endl;
	exit(0);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
	{
		int x;
		cin >> x;
		x--;
		X[i] = Item(i, x, i);
	}

	sort(X, X + n, cmp);
	FILL(A, -1);
	int p = 0;
	FOR(i, 0, n)
	{
		//cout << X[i].i << " " << X[i].left << endl;
		while (X[i].left != 0)
		{
			if (A[p] == -1)
			{
				X[i].left--;
				A[p] = X[i].i;
			}

			p++;
		}

		if (A[X[i].pos] != -1) no();
		A[X[i].pos] = X[i].i;
	}

	p = 0;
	FOR(i, 0, n * n)
	{
		while (p < n && X[p].left == n - X[p].i - 1) p++;
		if (p == n) break;

		if (A[i] == -1)
		{
			if (X[p].pos > i) no();
			A[i] = X[p].i;
			X[p].left++;
		}
	}

	//FOR(i, 0, n)
	//{
	//	FOR(k, 0, n - i - 1)
	//	{
	//		while (A[p] != -1) p++;
	//		A[p] = X[k].i;
	//	}
	//}

	cout << "Yes" << endl;
	FOR(i, 0, n * n)
	{
		cout << A[i] + 1 << " ";
	}

	cout << endl;
}


Measured memory_bytes: 5376
def main(N,A):
    A_ans = [[0]*N for _ in range(N)]

    for i in range(N):
        for j in range(A[i][1]):
            tmp = A[i][j+2]
            #print(tmp)
            A_ans[i][tmp-1] = 1

    return A_ans

N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
A_ans = main(N,A)
for i in range(N):
    A_ans[i] = map(str,A_ans[i])
    print(' '.join(A_ans[i]))



Measured memory_bytes: 5688
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
#define MAX 100001
#define LN 100000000

struct Card {
    char moji;
    int val;
};

Card L[MAX/2], R[MAX/2]; // temporary arrays
int n;

// r??????n-1
int partition ( Card K[], int p, int r ) {
    int judge_n = K[r].val;
    int i = p-1;
    for ( int j = p; j <= r; j++ ) {
        if ( K[j].val <= judge_n ) {
            i++;
            std::swap(K[i], K[j]);
        }
    }
    return i; // this is the index of the judge_n
}

void quickSort ( Card K[], int start, int end ) {
    if (start < end) {
        int p = partition( K, start, end );
        quickSort( K, start , p-1 );
        quickSort( K, p+1, end );
    }
}


void merge(Card K[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) {
        L[i] = K[left+i];
    }
    for (int i = 0; i < n2; i++) {
        R[i] = K[mid+i];
    }
    L[n1].val = LN; R[n2].val = LN;
    int i = 0; int j = 0;
    for (int k = left; k < right; k++) {
        if (L[i].val <= R[j].val) {
            K[k] = L[i];
            i++;
        }
        else if (L[i].val > R[j].val) {
            K[k] = R[j];
            j++;
        }
    }
}

void mergeSort(Card K[], int left, int right) {
    if (left+1 < right) {
        int mid = (left + right) / 2;
        mergeSort(K, left, mid);
        mergeSort(K, mid, right);
        merge(K, left, mid, right);
    }
}

int main() {
    Card A[MAX], B[MAX];
    char S[10];
    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
        scanf("%s %d", S, &A[i].val);
        A[i].moji = S[0];
        B[i] = A[i];
    }

    quickSort(A, 0, n-1);
    mergeSort(B, 0, n);
    
    int i = 0;
    while (i < n) {
        if (A[i].moji == B[i].moji) i++;
        else break;
    }
    if (i == n) printf("Stable\n");
    else printf("Not stable\n");

    for ( int i = 0; i < n; i++ ) {
        printf("%c %d\n", A[i].moji, A[i].val);
    }

    return 0;
}

Measured memory_bytes: 5456
import math

n = input()

a = map(int, raw_input().split())

minNum = 100000000000
maxNum = -100000000000
sumNum = 0

for x in a :
    minNum = min(minNum, x)
    maxNum = max(maxNum, x)
    sumNum += x

minNum, maxNum, sumNum = map(str, [minNum, maxNum, sumNum])

print minNum + ' ' + maxNum + ' ' + sumNum

Measured memory_bytes: 7132
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  vector<double>x(n);
  vector<string>u(n);
  for(int i=0;i<n;i++)cin>>x[i]>>u[i];
  double sum=0;
  for(int i=0;i<n;i++){
    if(u[i]=="BTC")sum+=x[i]*380000;
    else sum+=x[i];
  }
  cout<<std::fixed<<std::setprecision(10)<<sum<<endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod =1e9+7;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
ll inv(ll x){
    return power(x,mod-2);
}
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int main(){
    int n;
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10)cout<<a*b;
    else cout<<-1;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	string S;int N;
	cin >> S >> N;
	string s1;
	int ans=0;
	for(int i=0;i<N;i++){
		cin >> s1;
		bool f=false;
		for(int i=0;i<s1.length();i++){
			for(int j=0;j<S.length();j++){
				if(S[j]!=s1[(i+j)%s1.length()])goto a;
			}
			f=true;
			a:;
		}
		if(f)ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    string s;
    int sum;
    while(cin>>s&&s!="0"){
        sum=0;
        for(int i=0;s[i]!='\0';i++)sum+=s[i]-'0';
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3164