akhauriyash/Code-Regression huggingface dataset:
/*input

*/

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define pb                push_back
#define pp                pop_back
#define nl                cout << "\n"
#define MIN(con)          (*min_element(ALL(con)))
#define MAX(con)          (*max_element(ALL(con)))
#define NX(cont)          next_permutation(ALL(cont))
#define PX(cont)          prev_permutation(ALL(cont))
#define prec(n)           cout << fixed << setprecision(n)
#define PI                3.14159265358979323846264338327951
#define all(c)            c.begin(),c.end()
#define rep(i,a,b)        for(ll i=a;i<b;i++)
#define sp                cout << " "
#define mod               1000000007    //9
#define ifalse            ios_base::sync_with_stdio(false),cin.tie(NULL)

using ll = long long;
using ld = long double;
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > string toString(T a)       { return to_string(a); }  // Convert int to string
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}  // Convert string to int

ll add(ll x, ll y) { x += y; if(x >= mod) x -= mod; return x; }
ll sub(ll x, ll y) { x -= y; if(x < 0) x += mod; return x; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }

ll powr(ll a, ll b) {
    ll x = 1LL;
    while(b) {
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}

ll inv(ll a) { return powr(a, mod - 2); }
const int inv2 = (mod + 1) >> 1;
const ll INF =  1e18;
const int inf = 1e9;

bool check(ll n)
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;
    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

/*********************************************START**************************************************************/

int main()
{
    ifalse;
    string s;
    cin >> s;
    int ans = 0;
    int u = 0;

    stack < char > s1, s2;
    for(auto x: s) {
        if(x == '0') {
            if(s2.empty()) {
                s1.push(x);
            }
            else {
                ans += 2;
                s2.pop();
            }
        }
        else {
            if(s1.empty()) {
                s2.push(x);
            }
            else {
                ans += 2;
                s1.pop();
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
m=int(input())
d=[[[0 for i in range(10)]for j in range(3)] for k in range(4)]
for i in range(m):
    b,f,r,v=map(int,input().split())
    d[b-1][f-1][r-1]+=v
for i in range(4):
    for j in range(3):
        for k in range(9):
            print(" ",end="")
            print(d[i][j][k],end="")
        print(" ",end="")
        print(d[i][j][9])
    if(i<=2):
        print("#"*20)


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

ll x[11], y[11];
ll b[11];
int main()
{
    ll n, i, j, k, m;
    scanf("%lld", &n);
    for(i=0; i<n; i++) scanf("%lld %lld", &x[i], &y[i]);
    for(i=0; i<n; i++) b[i]=i;
    double res=0;
    do
    {
        for(i=1; i<n; i++)
        {
            res+=sqrt((x[b[i]]-x[b[i-1]])*(x[b[i]]-x[b[i-1]])+(y[b[i]]-y[b[i-1]])*(y[b[i]]-y[b[i-1]]));
        }
    } while(next_permutation(b, b+n));

    for(i=1; i<=n; i++) res/=(double) i;

    printf("%.10f\n", res);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

#define SIZE 100005

// 1为2017数
int numbers[SIZE];
int _2017[SIZE];

int main() {
	numbers[1] = 0;
	for (int i = 2; i < SIZE; i++) {
		numbers[i] = 1;
	}

	for (int i = 2; i < SIZE; i++) {
		if (numbers[i]) {
			for (int j = 2; j * i < SIZE; j++) {
				numbers[j * i] = 0;
			}
		}
	}

	// 求2017数
	memcpy(_2017, numbers, sizeof numbers);
	_2017[2] = 0;
	for (int i = 3; i < SIZE; i += 2) {
		if (numbers[i] && !numbers[(i + 1) / 2]) {
			_2017[i] = 0;
		}
	}

	for (int i = 2; i < SIZE; i++) {
		_2017[i] += _2017[i - 1];
	}


	int question;
	std::cin >> question;
	while (question--) {
		int left, right;
		std::cin >> left >> right;

		std::cout << _2017[right] - _2017[left - 1] << std::endl;
	}

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
using namespace std;

int main(){
 
    int a,b;
    
    cin >> a >> b ;
    int sum = a*3 + b;
 
    cout << sum/2 <<endl;
 
}


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

using namespace std;

struct RollingHash2D {
    typedef unsigned long long ull;

    struct RollingHash {
        typedef unsigned long long ull;
        string S;
        ull B;
        int len;
        vector<ull> hash, p;

        RollingHash() {}

        RollingHash(string S_, ull B_ = 1000000007LL) :
                S(S_), B(B_), len(S.length()), hash(len + 1), p(len + 1) {
            hash[0] = 0;
            p[0] = 1;
            for (int i = 0; i < len; i++) {
                hash[i + 1] = hash[i] * B + S[i];
                p[i + 1] = p[i] * B;
            }
        }

        //S[l,r)
        ull find(int l, int r) {
            return hash[r] - hash[l] * p[r - l];
        }
    };

    vector<string> S;
    int h, w, r, c;
    ull B;
    vector<ull> p;
    vector<vector<ull> > hash;
    vector<RollingHash> rh;

    RollingHash2D() {}

    RollingHash2D(vector<string> S_, int r_, int c_, ull B_ = 1000000009LL) :
            S(S_), h(S_.size()), w(S_[0].size()), r(r_), c(c_), B(B_),
            p(h + 1), hash(h + 1, vector<ull>(w - c + 1, 0)), rh(h) {
        for (int i = 0; i < h; i++) rh[i] = RollingHash(S[i]);
        p[0] = 1;
        for (int i = 0; i < h; i++) p[i + 1] = p[i] * B;
        for (int j = 0; j < w - c + 1; j++) {
            hash[0][j] = 0;
            for (int i = 0; i < h; i++)
                hash[i + 1][j] = hash[i][j] * B + rh[i].find(j, j + c);
        }
    }

    //[i,i+r) * [j,j+c)
    ull find(int i, int j) {
        return hash[i + r][j] - hash[i][j] * p[r];
    }
};


int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    int r, c;
    cin >> r >> c;
    vector<string> t(r);
    for (int i = 0; i < r; i++) {
        cin >> t[i];
    }

    RollingHash2D srh(s, r, c);
    RollingHash2D trh(t, r, c);

    for (int i = 0; i < h - r + 1; i++) {
        for (int j = 0; j < w - c + 1; j++) {
            if (srh.find(i, j) == trh.find(0, 0)) cout << i << " " << j << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 38612
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INF = 1LL << 60;

int main(){
    long long N; cin >> N;
    int i=0;
    while(true){
        i++;
        if(N <pow(2,i+1)) break;
    }
    long long ans = pow(2,i+1)-1;
    if(N == 1) cout << 1 << endl;
    else cout << ans << endl; ;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000007

using namespace std;
typedef long long ll;

mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

template <typename T> void read(T &x) {
  x = 0;
  char c = getchar();
  T sig = 1;
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      sig = -1;
  for (; isdigit(c); c = getchar())
    x = (x << 3) + (x << 1) + c - '0';
  x *= sig;
}

class Solution {
public:
  void solve() {
    int n;
    read(n);
    vector<int> l(n);
    for (int i = 0; i < n; ++i)
      read(l[i]);
    sort(l.begin(), l.end());
    int ans = 0;
    for (int i = 0; i < n; ++i)
      for (int j = i + 1; j < n; ++j)
        for (int k = j + 1; k < n; ++k)
          if (l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k])
            ans++;
    printf("%d", ans);
  }
};

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

Measured memory_bytes: 3752
#include<iostream>
using namespace std;
#include <vector>
#define re(i,n) for(int i = 0; i < n; i++)

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	re(i, n) cin >> l[i];

	int cnt = 0;
	
	re(i, n - 2) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++) {
				if (abs(l[i] - l[j]) < l[k] && l[k] < l[i] + l[j] && l[i] != l[j] && l[i] != l[k] && l[j] != l[k]) cnt++;
			}
		}
	}

	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {
    val S = readLine()!!
    println(if (isEasy(S)) "Yes" else "No")
}

private fun isEasy(S: String) : Boolean {
    for (i in 0 until S.length) {
        if ((i+1).and(1) == 0) {
            if (S[i] == 'R') {
                return false
            }
        } else {
            if (S[i] == 'L') {
                return false
            }
        }
    }
    return true
}


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

int main(){
  string s;
  cin >> s;
  
  int l = s.size();
  vector<int> dp(l);
  dp.at(0) = 1;
  if(l >= 2){
    if(s.at(0) == s.at(1)) dp.at(1) = 1;
    else dp.at(1) = 2;
    if(l >= 3){
      if(s.at(1) == s.at(2)) dp.at(2) = 2;
      else dp.at(2) = dp.at(1) + 1;
    }
  }
  if(l >= 4){
    for(int i = 3; i < l; i++){
      if(s.at(i) == s.at(i-1)) dp.at(i) = dp.at(i-3) + 2;
      else dp.at(i) = dp.at(i-1) + 1;
    }
  }
  
  cout << dp.at(l-1) << endl;
}

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


int main() {
  int n,m;
  cin >>n>>m;
  if(n<=8&&m<=8){
    cout<<"Yay!"<<endl;
  }else{
    cout<<":("<<endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,p[20],s[1<<20],s1[1<<10];

int main(){
	while(cin>>n){
		if(!n)return 0;
		int n2=n/2;
		fill(s1,s1+(1<<n2),0);
		int sum=0,dif=1e+9;
		for(int i=0;i<n;i++){cin>>p[i];sum+=p[i];}
		if(n<4){
			fill(s,s+(1<<n),0);
			for(int i=0;i<1<<n;i++){
				int sss=0;
				for(int j=0;j<n;j++)if((i/(1<<j))%2)sss+=p[j];
				dif=min(dif,abs(sss*2-sum));
			}
			cout<<dif<<endl;
		}
		else{
		for(int i=0;i<1<<n2;i++){
			for(int j=0;j<n2;j++)if(i>>j&1)s1[i]+=p[j];
		}
		sort(s1,s1+(1<<n2));
		int ans=1e+9;
		for(int i=0;i<1<<(n-n2);i++){
			int ss=0;
			
			for(int j=0;j<n-n2;j++)if(i>>j&1)ss+=p[j+n2];
			ans=min(ans,min(abs((*lower_bound(s1,s1+(1<<n2),(sum)/2-ss)+ss)*2-sum),abs((*(lower_bound(s1,s1+(1<<n2),(sum)/2-ss)-1)+ss)*2-sum)));
		}
		cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int A, B;
    cin >> A >> B;
    cout << max(0, A-2*B) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env perl

use strict;
use warnings;

my $n = <>;
chomp $n;

my @s = split //,<>;
chomp $s[$#s];

my (@left, @right);
for (my $i = 0; $i < $n; $i++) {
  $left[$i] = $s[$i] eq 'W' ? 1 : 0;
  $left[$i] += $left[$i - 1] if $i > 0;
  my $j = $n - $i - 1;
  $right[$j] = $s[$j] eq 'E' ? 1 : 0;
  $right[$j] += $right[$j + 1] if $j < $n - 1;
}

my $ans = 1000000;
for (my $i = 0; $i < $n; $i++) {
  my $cand = $left[$i] + $right[$i] - 1;
  $ans = $cand if $ans > $cand;
}
print $ans, "\n";


Measured memory_bytes: 52996
n, y = (int(x) for x in input().split())
ans = 0
m = y // 10000 + 1
for m_i in reversed(range(m)):
    r = y - 10000 * m_i
    g = r // 5000 + 1
    for g_i in range(g):
        if 5000 * g_i + 1000 * (n - m_i - g_i) == r:
            ans = [m_i, g_i, n - m_i - g_i]
            break
    if ans != 0:
        break
if ans == 0: print(*[-1, -1, -1])
else: print(*ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include<algorithm>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 
using namespace std;

long long mod = 1000000007;



int main()
{
	int N;
	cin >> N;
	string S1, S2;
	cin >> S1;
	cin >> S2;



	int i = 0;
	long long cnt = 0;
	//fl==0:前が縦型,fl==1:前が横型
	int fl;

	while (1) {
		//1回目以降
		if (i != 0) {
			if (i < N) {
				//縦型の場合
				if (S1[i] == S2[i]) {
					if (fl == 0) {
						cnt = (2 * cnt) % mod;
					}
					i++;
					fl = 0;
				}
				//横型の場合
				else {
					if (fl == 0) {
						cnt = (2 * cnt) % mod;
					}
					else {
						cnt = (3 * cnt) % mod;
					}
					i += 2;
					fl = 1;
				}
			}
			else {
				break;
			}
		}//1回目は別処理
		else {
			if (S1[i] == S2[i]) {
				fl = 0;
				cnt = 3;
				i++;
			}
			else {
				fl = 1;
				cnt = 6;
				i += 2;
			}

		}
	}

	cout << cnt << endl;



	


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N/1000==N%1000/100 && N%1000/100==N%100/10)
    cout << "Yes" << endl;
  else if (N%1000/100==N%100/10 && N%100/10==N%10)
    cout << "Yes" << endl;
  else
    cout << "No" <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static final long INF = (1L << 32);
	static long[][]d;;
	static int N;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		int M = sc.nextInt();
		d = new long[N][N];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				if(i == j) {
					d[i][j] = 0;
				}else {
					d[i][j] = INF;
				}
			}
		}
		Data[] data = new Data[M];
		for(int i = 0; i < M; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			int c = sc.nextInt();
			data[i] = new Data(a, b, c);
			d[a][b] = c;
			d[b][a] = c;
		}
		sc.close();
		warshallFloyd();
		int cnt = 0;
		for(int i = 0; i < M; i++) {
			int a = data[i].a;
			int b = data[i].b;
			boolean flag = true;
			loop: for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					long d1 = d[j][a] + data[i].c + d[b][k];
					long d2 = d[j][k];
					if(d1 == d2) {
						flag = false;
						break loop;
					}
				}
			}
			if(flag) cnt++;
		}
		System.out.println(cnt);
//		for(int i = 0; i < N; i++) {
//			for(int j = 0; j < N; j++) {
//				System.out.print(d[i][j] + " ");
//			}
//			System.out.println();
//		}
	}
	static class Data{
		int a, b, c;
		public Data(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}
	}
	static void warshallFloyd() {
        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                if(d[i][k] == INF) continue;
                for(int j = 0; j < N; j++) {
                    if(d[k][j] == INF) continue;
                    d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
    }
}

Measured memory_bytes: 26196
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define MAX 10000100
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
bool sosu[MAX];
int main(){
	memset(sosu,true,MAX);
	for(int i=4;i<MAX;i+=2)sosu[i]=false;
	for(int i=3;i<MAX;i+=2)
	for(int j=3*i;j<MAX;j+=2*i)sosu[j]=false;
	int n;
	while(cin>>n,n){
		for(int i=n;i>=0;i--){
			if(sosu[i]&&sosu[i-2]&&sosu[i-6]&sosu[i-8]){
				cout<<i<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 10932
import java.util.Scanner;
class Main {
public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    int x = Integer.parseInt(sc.next());
    int y = Integer.parseInt(sc.next());
    int sum = 0;
    if(n >k){
    for(int i =0;i<k;i++){
        sum += x;
    }
    for(int i =0;i<n-k;i++){
        sum += y;
    }
    }else{
    for(int i=0;i<n;i++){
    sum += x; 
    }
    }
    System.out.println(sum);          
    }
}

Measured memory_bytes: 9940
N=int(input())
S=[input() for _ in range(N)]
S.sort()
cnt=1
sheet=[[],[]]

for i in range(1,N):
    if S[i]==S[i-1]:
        cnt+=1
        if i==N-1:
            sheet[0].append(S[i-1])
            sheet[1].append(cnt)
    else:
        sheet[0].append(S[i-1])
        sheet[1].append(cnt)
        cnt=1
        if i==N-1:
            sheet[0].append(S[i])
            sheet[1].append(cnt)

cmax=max(sheet[1])
for j in range(len(sheet[1])):
    if sheet[1][j]==cmax:
        print(sheet[0][j])

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

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int N,X;
vector<int> L;

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

    for(int i = 0;i < N;i++) {
        int l;
        cin>>l;
        L.push_back(l);
    }

    int ans = 0;
    int dist = 0;
    for(int i = 0;i < N;i++) {
        if(dist <= X) {
            ans++;
        }
        dist += L[i];
    }
    if(dist <= X)
        ans++;

    cout<<ans<<endl;

    return 0;
}





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

#define ll long long int
#define ull unsigned long long int
#define lld long double
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vull vector<ull>
#define all(v) v.begin(),v.end()
#define mp make_pair
#define bitcount(x) __builtin_popcountll(x)
#define charcount(s,c) count(s.begin(), s.end(), c)
#define each(a,b) memset(a,b,sizeof a) //for b=0/-1, all pos,s for multidim arr too;
#define tofsi(s,c,t) memset(s,c,t) // for char s[n],first t;
#define tofs(s,pos,c,t) fill_n(s.begin()+pos, t, c);
#define fi first
#define se second


ll e_bit=0xAAAAAAAA;
ll o_bit=0x55555555;
lld pi = acos(-1.0);
ll gprime=402653189;
ll pprime=1610612741;
ll dulo=1000000007;

bool is_power2(ll n){
	return (n&&!(n&(n-1)));
}
ll power(ll x, ll y){
    ll temp;
    if( y == 0)
       return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return (temp*temp);
    else
    {
        if(y > 0)
            return (((x*temp))*temp);
        else
            return (temp*temp)/x;
    }
}

long long int mul_inv(long long int n,long long int p,long long int m){
	if(p==1){
		return n%m;
	}
	else if(p%2==0){
		long long int t= mul_inv(n,p/2,m);
		return ((t)*(t))%m;
	}
	else{
		long long int t= mul_inv(n,p/2,m);
		return ((((n%m)*t)%m)*t)%m;
	}
}

bool isprime(ll n){
	if(n==1){
		return false;
	}
	if(n==2){
		return true;
	}
	if(n%2==0){
		return false;
	}
	for(ll i=3;i<=sqrt(n);i+=2){
		if(n%i==0){
			return false;
		}
	}
	return true;
}


// getline(cin,s), cin.ignore() if cin>>p b4;


/*
struct compare {
    bool operator() (pair<int,int> a,pair<int,int> b) const{
        return a.se<b.se;
    }
};
*/


/*
---------------------Priority Queue Compare Operator------------------------

priority_queue<int, std::vector<int>, compare> pq;

*/


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	/*freopen("fbh.in","r",stdin);
    freopen("B-large.out","w",stdout);*/
	/*float ans;
	std::cout << std::fixed;
    std::cout << std::setprecision(9);
    std::cout << ans;
	*/
	int n,m;
	cin>>n>>m;
	char c[n+3][m+3];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>c[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(c[i][j]=='.'){
				int p=0;
				for(int k=-1;k<=1;k++){
					for(int w=-1;w<=1;w++){
						if(i+k<=n&&i+k>=1&&j+w<=m&&j+w>=1&&(!(k==0&&w==0))){
							if(c[i+k][j+w]=='#')p++;
						}
					}
				}
				c[i][j]='0'+p;
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cout<<c[i][j];
		}
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

struct edge {
    int to;
    int cost;
    edge(int a, int b) : to(a), cost(b) {}
};

vector<vector<edge>> e;
int N;

pair<int, int> dfs(int p, int par = -1)
{
    if (e[p].size() == 1 && par > 0) return make_pair(0, p);
    pair<int, int> res = make_pair(0, p);
    for (auto x : e[p]) {
        if (x.to == par) continue;
        auto t = dfs(x.to, p);
        t.first += x.cost;
        res = max(res, t);
    }
    return res;
}

int main()
{
    cin >> N;
    e.resize(N);
    for (int i = 0; i < N-1; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        e[s].emplace_back(t, w);
        e[t].emplace_back(s, w);
    }
    auto res = dfs(0);
    res = dfs(res.second);
    cout << res.first << endl;
}


Measured memory_bytes: 16000
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    vector<vector<pair<int, int>>> l(n + 1);
    rep(i, n + 1) {
      int m;
      cin >> m;
      rep(j, m) {
        int x, y;
        cin >> x >> y;
        l[i].emplace_back(x, y);
      }
    }
    auto f = [&](int t) {
      if (l[0].size() != l[t].size()) return false;
      rep(i, 2) {
        rep(j, 4) {
          int dx = l[0][0].first - l[t][0].first, dy = l[0][0].second - l[t][0].second;
          bool f = true;
          rep(i, l[0].size()) {
            f &= l[0][i].first == l[t][i].first + dx;
            f &= l[0][i].second == l[t][i].second + dy;
          }
          if (f) return true;
          rep(k, l[t].size()) {
            swap(l[t][k].first, l[t][k].second);
            l[t][k].first *= -1;
          }
        }
        reverse(all(l[t]));
      }
      return false;
    };
    loop(i, 1, n + 1) if (f(i)) cout << i << endl;
    cout << "+++++" << endl;
  }
}



Measured memory_bytes: 3000
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	int a, b;
	cin >> a >> b;
	cout << (((a*b) % 2 != 0) ? "Odd" : "Even") << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int ab, bc,ca;
	cin >> ab >> bc >> ca;
	cout << ab * bc / 2 << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n,a;
 	cin >> n>>a;
 	ll ans=0;
 	if(a!=0){
 		cout << -1 << endl;
 		return 0;
 	}
 	for (int i = 0; i < n-1; i++){
 		int b;
 		cin >> b;
 		if(b>a+1){
 			cout << -1 << endl;
 			return 0;
 		}else if(b>=a+1){
 			ans++;
 		}else{
 			ans+=b;
 		}
 		a=b;
 	}
 	cout << ans << endl;
 }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    const int num=3;
    
    int x[num];
    cin >> x[0] >> x[1] >> x[2];
    
    for(int i=num-1; i>0; --i)
        for(int j=0; j<i; ++j)
        {
            if(x[j]>x[j+1]){
                int temp = x[j];
                x[j] = x[j+1];
                x[j+1] = temp;
            }
        }
    
    
    cout << x[0] <<" "<< x[1] <<" "<< x[2] << endl;
    
    
    
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  int H[100000];
  
  for(int i=0; i<N; i++){
    cin >> H[i];
  }
  bool good[100000];//道がつながっていないときもいい展望台なのでtrueで埋める
  for(int i =0; i < N; i++){
    good[i] = true;
  }
  
  for(int i =0; i < M; i++){//道の数ぶん入力するのでM
    int a, b;
    cin >> a >> b;
    a--; b--;
    if(H[a] <= H[b]) good[a] =false; //aはいい展望台ではない。bool配列の対応する要素をfalseに。
    if(H[b] <= H[a]) good[b] =false;
  }
  int ans =0;
  for(int i =0; i < N; i++){//展望台をみていくのでN
    if(good[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4084
import java.io.*;
import java.util.*;
class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String case_number;
    List<String> group_number = new ArrayList<String>();
    while(true){
      case_number = br.readLine();
      if(case_number.equals("0")){
        break;
      }
      group_number.add(case_number);
    }

    int case_count = 0;
    for(String number: group_number){
      case_count++;
      System.out.println("Case " + case_count + ": " + number);
    }
  }
}



Measured memory_bytes: 32296
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
//const ll MOD=1000000007;
//const ll MOD2=998244353;
//const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll H,W,M;
    cin >> H >> W >> M;
    vl h(M),w(M);
    vl cnt0(H),cnt1(W);
    ll mxh=0,mxw=0;
    rep(i,M){
        cin >> h[i] >> w[i];
        h[i]--;w[i]--;
        cnt0[h[i]]++;cnt1[w[i]]++;
        chmax(mxh,cnt0[h[i]]),chmax(mxw,cnt1[w[i]]);
    }
    ll nowh=0,noww=0;
    rep(i,H){
        if(cnt0[i]==mxh){
            nowh++;
        }
    }
    rep(i,W){
        if(cnt1[i]==mxw){
            noww++;
        }
    }
    ll now=0;
    rep(i,M){
        if(cnt0[h[i]]==mxh&&cnt1[w[i]]==mxw){
            now++;
        }
    }
    //cout << now << ' ' << nowh << ' ' << noww << '\n';
    cout << (now==nowh*noww?mxh+mxw-1:mxh+mxw) << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll INF = 4e18;
const int N = 18;

int n;
ll a[N];

map<pii,ll> memo[N][N];
ll go(int l, int r, int ml, int mr) {
    if (l+1 == r) return a[l]*ml + a[r]*mr;

    auto p = mp(ml,mr);
    if (!memo[l][r].count(p)) {
        auto &res = memo[l][r][p];
        res = INF;
        for (int m = l+1; m < r; m++) {
            res = min(res, go(l,m,ml,ml+mr) + go(m,r,ml+mr,mr) - (ml+mr)*a[m]);
        }
    }
    return memo[l][r][p];
}

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

    cin >> n;
    forn(i,n) cin >> a[i];
    cout << go(0,n-1,1,1) << endl;

    return 0;
}


Measured memory_bytes: 16512
//============================================================================
// Name        : HelloWorld.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
    string str;
    cin>>str;
    if(str[0]==str[1] || str[1]==str[2] || str[2]==str[3]){
    	cout<<"Bad"<<endl;
    }else{
    	cout<<"Good"<<endl;
    }
	return 0;
}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int N, M;

int main()
{
	cin >> N >> M;
	while(N) {
		vector<int> h;
		vector<int> w;
		rep(i, N) {
			CIN(int, t);
			h.PB(t);
		}
		rep(i, M) {
			CIN(int, t);
			w.PB(t);
		}
		vector<int> H;
		vector<int> W;
		rep(i, N) {
			int t = 0;
			reps(j, i, N) {
				t += h[j];
				H.PB(t);
			}
		}
		rep(i, M) {
			int t = 0;
			reps(j, i, M) {
				t += w[j];
				W.PB(t);
			}
		}
		sort(all(H));
		sort(all(W));
		ll res = 0;
		int pos = 0;
		rep(i, H.size()) {
			ll hc = 1;
			reps(j, i+1, H.size()) {
				if (H[j] == H[i]) hc++;
				else {
					i = j-1;
					break;
				}
			}
			ll wc = 0;
			for (; pos < (int) W.size(); pos++) {
				if (W[pos] < H[i]) continue;
				if (W[pos] == H[i]) wc++;
				if (W[pos] > H[i]) break;
			}
			res += hc * wc;
			if (pos == (int) W.size()) break;
		}
		cout << res << endl;
		cin >> N >> M;
	}
}



Measured memory_bytes: 19732
def main():
    n = int(input())
    # n, m = map(int, input().split())
    h = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in range(n)]

    count = 0
    h.append(0)
    for j in range(max(h)):
        for i in range(n):
            if h[i] != 0 and h[i+1] == 0:
                count += 1
            if h[i] != 0:
                h[i] -= 1
    
    print(count)



if __name__ == '__main__':
    main()


Measured memory_bytes: 65740
#include <stdio.h>

int main()
{
  int n,i,j,mincost,u,sum=0;
  
  scanf("%d",&n);

  int G[n][n],d[n],p[n],color[n],tmp;

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&tmp);
      if(tmp==-1){
	G[i][j]=2001;
      }
      else G[i][j]=tmp;
    }
  }

  for(i=0;i<n;i++){
    d[i]=2001;
    p[i]=-1;
    color[i]=0;
  }

   d[0]=0;

  while(1){
    
    mincost=2001;
    u=-1;

    for(i=0;i<n;i++){
      if(color[i]!=2 && d[i]<mincost){
	u=i;
	mincost=d[i];
      }
    }

    if(mincost==2001) break;
    
    color[u]=2;
    
    for(i=0;i<n;i++){
      if(color[i]!=2 && G[u][i]<d[i]){
	if(G[u][i]!=2001){
	  p[i]=u;
	  d[i]=G[u][i];
	  color[i]=1;
	}
      }
    }
  }
  
  
  for(i=0;i<n;i++){
    if(p[i]!=-1)sum+=G[i][p[i]];
  }
  
  printf("%d\n",sum);
  
  return 0;
  
}



Measured memory_bytes: 2040
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 04:07:05 2020

@author: liang
"""

C = [[int (x) for x in input().split()] for _ in range(3)]
A = [0]*3
B = [0]*3

ans = False
for a1 in range(C[0][0]+1):
    tmp = True
    b1 = C[0][0] - a1
    b2 = C[0][1] - a1
    b3 = C[0][2] - a1
    a2 = C[1][0] - b1
    a3 = C[2][0] - b1
    if C[1][1] != a2+b2:
        tmp = False
    if C[1][2] != a2+b3:
        tmp = False
    if C[2][1] != a3+b2:
        tmp = False
    if C[2][2] != a3+b3:
        tmp = False
    if tmp == True:
        ans = True
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9184
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)
#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 array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) { if (c)print("Yes"); else print("No"); };

long long gcd(long long x, long long y) {
	long long m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
int g[202][202];
void solve() {
	int N; cin >> N;
	string S; cin >> S;
	int R = 0, G = 0, B = 0;
	REP(i, N) {
		if (S[i] == 'R')R++;
		else if (S[i] == 'G')G++;
		else B++;
	}
	ll ans = R * G*B;
	FOR(k, 1, N - 1) {
		FOR(l,1,min(k+1,N-k)){
			if (S[k - l] != S[k] && S[k] != S[k + l] && S[k - l] != S[k + l])ans--;
		}
	}
	print(ans);
}

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




Measured memory_bytes: 3672
#include <iostream>

using namespace std;

const long MOD = 1000000007;

long dp[100][100000];
long cnt[100000];
long sum[100000];

int main(){
    int N, K;
    cin >> N >> K;
    int sq;
    for(int i = 1; i*i <= N; i++){
        cnt[i-1] = 1;
        sq = i;
    }
    int m;
    if((N/sq) == sq){
        m = 2*sq-1;
        for(int i = sq-1; i >= 1; i--){
            if(i != sq-1) cnt[2*sq-i-1] = (N/i)-(N/(i+1));
            else cnt[2*sq-i-1] = (N/i)-sq;
        }
        for(int i = 0; i < 2*sq-1; i++){
            //cout << cnt[i] << ' ';
            dp[0][i] = cnt[i];
        }
    }else{
        m = 2*sq;
        for(int i = sq; i >= 1; i--){
            if(i != sq) cnt[2*sq-i] = (N/i)-(N/(i+1));
            else cnt[2*sq-i] = (N/i)-sq;
        }
        for(int i = 0; i < 2*sq; i++){
            //cout << cnt[i] << ' ';
            dp[0][i] = cnt[i];
        }
    }
    for(int i = 1; i < K; i++){
        for(int j = 0; j < m+1; j++) sum[j] = 0;
        for(int j = 0; j < m; j++){
            sum[0] += dp[i-1][j];
            sum[0] %= MOD;
            sum[m-j] -= dp[i-1][j];
            sum[m-j] += MOD;
            sum[m-j] %= MOD;
        }
        for(int j = 1; j < m; j++){
            sum[j] += sum[j-1];
            sum[j] %= MOD;
            sum[j] += MOD;
            sum[j] %= MOD;
        }
        for(int j = 0; j < m; j++){
            dp[i][j] = sum[j]*cnt[j];
            dp[i][j] %= MOD;
            //cout << dp[i][j] << ' ';
        }
        //cout << endl;
    }
    long ans = 0;
    for(int i = 0; i < m; i++){
        ans += dp[K-1][i];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 78464
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
print(s.count('1'))


Measured memory_bytes: 74476
import java.util.Scanner;

class A {

    static final int[] money = new int[300];

    static {
        money[1] = 300000;
        money[2] = 200000;
        money[3] = 100000;
    }

    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int X = sc.nextInt();
        final int Y = sc.nextInt();
        System.out.println(money[X] + money[Y] + (X == 1 && Y == 1 ? 400000 : 0));
    }
}
public class Main {
    public static void main(String... args) {
        A.main();
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N,M,Q;
    cin >> N >> M >> Q;
    ll m[N][N];
    for (int yi = 0; yi < N; ++yi) {
        for (int xi = 0; xi < N; ++xi) {
            m[yi][xi] = 0;
        }
    }
    for (int i = 0; i < M; ++i) {
        ll l,r;
        cin >> l >> r;
        l--;r--;
        m[l][r]++;
    }
    for (int li = 0; li < N; ++li) {
        for (int ri = 1; ri < N; ++ri) {
            m[li][ri] += m[li][ri - 1];
        }
    }
    for (int ri = 0; ri < N; ++ri) {
        for (int li = 0; li < N-1; ++li) {
            m[N - li - 2][ri] += m[N - li - 1][ri];
        }
    }
    for (int i = 0; i < Q; ++i) {
        ll p,q;
        cin >> p >> q;
        p--;
        q--;
        cout << m[p][q] << endl;
    }

}


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

using namespace std;

#define MAX 300

int main()
{
    int mx, n;
    while (cin >> mx, mx) {
        cin >> n;
        vector<int> v(n+2, 0);
        for (int i = 1; i <= n; i++) {
            cin >> v[i];
        }
        bool visited[MAX] = {0};
        visited[0] = 1;
        queue<int> Q;
        Q.push(0);

        while (!Q.empty()) {
            int now = Q.front(); Q.pop();
            if (now == n+1) {
                continue;
            }

            for (int i = 1; i <= mx; i++) {
                int next = min(n+1, now+i);
                next += v[next];
                if (next < 0) {
                    next = 0;
                } else if (next > n+1) {
                    next = n+1;
                }
                if (!visited[next]) {
                    visited[next] = 1;
                    Q.push(next);
                }
            }
        }
        bool reachable = 1;
        for (int i = 0; i <= n; i++) {
            if (!visited[i]) {              
                continue;
            }
            bool ng = 1, visited2[MAX] = {0};
            queue<int> Q2; Q2.push(i);
            visited2[i] = 1;
            while (!Q2.empty()) {
                int now = Q2.front(); Q2.pop();
                if (now == n+1) {
                    ng = 0;
                    break;
                }
                for (int i = 1; i <= mx; i++) {
                    int next = min(n+1, now+i);
                    next += v[next];
                    if (next < 0) {
                        next = 0;
                    } else if (next > n+1) {
                        next = n+1;
                    }
                    if (!visited2[next]) {
                        visited2[next] = 1;
                        Q2.push(next);
                    }
                }
            }
            if (ng) {
                reachable = 0;
                break;
            }
        }
        cout << (reachable && visited[n+1] ? "OK" : "NG") << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k;
    cout << (max({a, b, c, d, e}) - min({a, b, c, d, e}) > k ? ":(" : "Yay!") << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(10) //10桁表示


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> c(n - 1), s(n - 1), f(n - 1);
	rep(i, n-1)
	{
		cin >> c[i] >> s[i] >> f[i];
	}


	rep(i, n - 1)
	{
		int time = 0;
		for(int j=i;j<n-1;j++)
		{
			if (time < s[j])
			{
				time = s[j];
			}
			else
			{
				if((time - s[j]) % f[j]!=0)
				time += f[j] - ((time-s[j]) % f[j]);
			}
			time += c[j];
		}
		cout << time << endl;
	}

	cout << 0 << endl;
	debug;
	return 0;
}

Measured memory_bytes: 504
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007


void solve(){
	int n,k;
	cin>>n>>k;
	int h[n];
	for(int i = 0; i<n; i++){
		cin>>h[i];
	}
	int ans =0;
	for(int i = 0; i<n; i++){
		if(h[i]>=k) ans++;
	}
	cout<<ans<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
	int a,b;
	int n;
	int cnt;
	
	while(scanf("%d %d",&a,&b)==2){
		n=a+b;
		cnt=1;
		
		while(n/10!=0){
			n=n/10;
			cnt++;
		}
		
		printf("%d\n",cnt);
	}
	
	return 0;
}

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

typedef long long int ll;
typedef pair<ll,ll> P;

vector<int> G[100001];
int parent[100001];

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        parent[i]=0;
    }
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> q;
    q.push(1);
    parent[1]=1;
    while(!q.empty()){
        int tmp=q.front();q.pop();
        //cout<<tmp<<endl;
        for(auto it:G[tmp]){
            if(parent[it]==0){
                parent[it]=tmp;
                q.push(it);
            }
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++){
        cout<<parent[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 10436
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String[] str = S.split("");
		int count=0;
      
		for(int i=0; i<(S.length()/2); i++){
			if(!(str[i].equals(str[S.length()-1-i]))){
				count++;
            }
        }
		
		System.out.println(count);
    }
}


Measured memory_bytes: 35664