akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int main() {
    using namespace std;
    unsigned long N;
    scanf("%lu", &N);
    vector<unsigned long> perm(N);
    {
        vector<pair<long, long>> p(N);
        for(auto& i : p)scanf("%lu%lu", &i.first, &i.second);
        sort(p.begin(), p.end());
        for(unsigned long i = 0; i < N; ++i)p[i] = {p[i].second, i + 1};
        sort(p.begin(), p.end());
        transform(p.cbegin(), p.cend(), perm.begin(), [](auto i){return i.second;});
    }

    constexpr unsigned long MOD = 998244353;
    vector<unsigned long> binary(N + 1);
    unsigned long n = binary[0] = 1;
    generate(binary.begin() + 1, binary.end(), [&n](){if(n >= MOD)n -= MOD;return n <<= 1;});


    vector<unsigned long> fenwick_tree(N + 1);
    auto que = [&fenwick_tree, &N](unsigned long i){
        unsigned long s{0}, j{i};
        while(i){
            s += fenwick_tree[i];
            i -= i & -i;
        }
        while(j <= N){
            ++fenwick_tree[j];
            j += j & -j;
        }
        return s;
    };

    vector<unsigned long> coef(N + 1);
    coef[N] = N + MOD - 4;
    for(unsigned long i = 0; i != N; ++i){
        auto p = perm[i], q = que(p);
        ++coef[q];
        ++coef[i - q];
        ++coef[p - q - 1];
        ++coef[N - i - p + q];
    }

    cout << inner_product(binary.begin(), binary.end(), coef.begin(), 4 + MOD - N) % MOD << endl;
    return 0;
}

Measured memory_bytes: 6488
#include<iostream>
#include<utility>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,pair<int,int> > piii;


int main(){
	int n,m,a;
	while(1){
		cin>>n>>m>>a;
		if(!n&&!m&&!a)break;
		piii w[m];
		rep(i,m)cin>>w[i].first>>w[i].second.first>>w[i].second.second;
		sort(w,w+m);
		reverse(w,w+m);
		rep(i,m){
			if(w[i].second.first==a){
				a=w[i].second.second;
			}else if(w[i].second.second==a){
				a=w[i].second.first;
			}
		}
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


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



Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 199999;
const int MAX = 2e5 + 10;

int a[MAX];
int bb[MAX];
void init(){
    for(int i=1;i<=MAX;i++){
        a[i]=i;
    }
}

int find(int u){
    return u==a[u]?u:a[u]=find(a[u]);
}
map<int,int>mp;
void solve() {
    init();
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int one,two;
        cin>>one>>two;
        int aa=find(one);
        int bb=find(two);
        a[aa]=bb;
    }
    for(int i=1;i<=n;i++){
        int one=find(a[i]);
        bb[one]++;
    }
    int ji=0;
    for(int i=1;i<=n;i++){
        ji=max(ji,bb[i]);
    }
    cout<<ji<<'\n';
}

signed main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int _ = 1;
    //cin>>_;
    while (_--) {
        solve();
    }
    return 0;
}


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

string IntToString(int number) {
    stringstream ss;
    ss << number;
    return ss.str();
}

int main(){
    int n;
    cin >> n;
    for(int p=0; p < n; p++){
        string ans;
        string s, t;
        cin >> s >> t;
        if(s.size() > t.size()) swap(s, t);


        int q = t.size()-s.size();
        for(int i=0; i < q; i++) s = "0" + s;

        int up = 0;
        for(int i=s.size()-1; 0 <= i; i--){
            int d = atoi(s.substr(i, 1).c_str());
            int f = atoi(t.substr(i, 1).c_str());
            ans = IntToString((d+f+up)%10) + ans;

            if(0 <= d+f+up-10) up = 1;
            else up = 0;
        }
        if(up == 1) ans = IntToString(1) + ans;

        if(80 < ans.size()) cout << "overflow" << endl;
        else cout << ans << endl;
     }
}

Measured memory_bytes: 1240
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner scan = new java.util.Scanner(System.in);

		double a = scan.nextDouble();
		double b = scan.nextDouble();
		double C = scan.nextDouble();

		double S, L, h;

		C = 2 * Math.PI * C / 360;
		h = b * Math.sin(C);

		S = a * h / 2;

		double c = Math.sqrt(
				Math.pow( a -  b * Math.cos(C), 2 ) + h*h );

		L = a + b + c;
		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}

}

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	bool flag = true;
	for(int i = 0; i < k ; i++){
        if(flag == true){
            if(a % 2 ==  1){
                a--;
            }
            b += a / 2;
            a /= 2;
        }else{
            if(b % 2 == 1){
                b--;
            }
            a += b / 2;
            b /= 2;
        }

        if(flag == 1){
            flag = 0;
        }else{
            flag = 1;
        }
	}
	cout << a << " " << b << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

def detectGroup(parents,x):
    if parents[x]!=x:
        parents[x]=detectGroup(parents,parents[x])
        return parents[x]
    else:
        return x
    
N,M=map(int,input().split())
AB=[[int(x)-1 for x in input().split()] for i in range(M)][::-1]
parents=[i for i in range(N)]
groupsize=[1 for i in range(N)]
inconv=N*(N-1)/2
result = []
for i in range(M):
    result.append(str(int(inconv))+'\n')
    groupA=detectGroup(parents,AB[i][0])
    groupB=detectGroup(parents,AB[i][1])
    if groupA!=groupB:
        inconv-=groupsize[groupA]*groupsize[groupB]
        groupsize[groupA]+=groupsize[groupB]
    parents[groupB] = groupA
print("".join(result[::-1]))

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

bool is_integer(double x) {
    return std::floor(x)==x;
}

int main(){
    string s;
    cin >> s;
    int n(0);
    rep(i,s.size()){
        n += s[i]-'0';
    }

    if(n%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(void){
	int x, sum, ret;
	int i;

	scanf("%d", &x);
	for(i=1; ; i++){
		sum = i*(i+1)/2;
		ret = i;
		if(sum >= x) break;
	}
	printf("%d\n", ret);

	return 0;
}

Measured memory_bytes: 128
import javax.swing.plaf.synth.SynthEditorPaneUI;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        HashMap<Integer,Integer>hm = new HashMap<>();
        long ans=0;
        for (int i =0;i<n;i++){
            int x = sc.nextInt();
            int d = i-x;
            ans+=hm.getOrDefault(d,0);
            hm.put(i+x,hm.getOrDefault(i+x,0)+1);
        }
        pw.println(ans);
        pw.flush();
    }
    static long gcd(long a,long b){
        if (a==0)
            return b;
        return gcd(b%a,a);
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public int[] nextIntarr(int n)throws Exception{
            int[]a = new int[n];
            for (int i =0;i<n;i++)
                a[i]=nextInt();
            return a;
        }
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 65624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp72 {
    class Program {
        static void Main(string[] args) {
            string s = Console.ReadLine();
            int len = s.Length;

            StringBuilder ans = new StringBuilder("");

            for (int i = 0; i < len; i++) {
                switch (s[i]) {
                    case '0':
                        ans.Append('0');
                        break;
                    case '1':
                        ans.Append('1');
                        break;
                    case 'B':
                        if (ans.Length >= 1) {
                            ans.Remove(ans.Length - 1, 1);
                        }
                        break;
                }


            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
 
int main(){
	int N;
  	int ac, wa, tle, re;
	ac = 0;
	wa = 0;
	tle = 0;
	re = 0;

  	string judge;
  
  	cin >> N;
  	
  	for(int i = 0; i < N; i++){	
  		cin >> judge;

      	if(judge == "AC"){
          ac++;
        }else if(judge == "WA"){
          wa++;
        }else if(judge == "TLE"){
          tle++;
        }else if(judge == "RE"){
          re++;
        }
    }
  	cout << "AC x" << " " << ac << endl; 
  	cout << "WA x" << " " << wa << endl; 
 	cout << "TLE x" << " " << tle << endl; 
  	cout << "RE x" << " " << re << endl;
	return 0;

}

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

typedef long long ll;

int main()
{
    int n,i;
    cin >> n;
    vector<string> s(n);
    for(i = 0;i < n;++i){
        cin >> s.at(i);
    }
    sort(s.begin(),s.end());
    string temp = s.at(0);
    int temp_n = 1;
    vector<pair<int,string>> ans;
    for(i = 1;i < n;++i){
        if(s.at(i) == temp){
            ++ temp_n;
        }else{
            ans.emplace_back(temp_n,temp);
            temp = s.at(i);
            temp_n = 1;
        }
    }
    ans.emplace_back(temp_n,temp);
    sort(ans.begin(),ans.end());
    int size = ans.size();
    int number = ans.at(size-1).first;
    vector<string> bob;
    for(i = size-1;i >= 0;--i){
        if(ans.at(i).first == number){
            bob.push_back(ans.at(i).second);
        }else{
            break;
        }
    }
    sort(bob.begin(),bob.end());
    for(i = 0;i < bob.size();++i){
        cout << bob.at(i) << endl;
    }
    return 0;
}

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

using namespace std;


int main () {
	string str;
	cin >> str;

	int counter;
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == 'o') {
			counter++;
		}
	}

	cout << 700 + 100 * counter << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

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

	int a, b;
	cin >> a >> b;
	int ans = (b >= a)? a : a-1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
long long a[1000000];
long long mod=1000000007;
int main()
{
	int n;
	cin>>n;
	long long sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum=sum+a[i];
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		sum=sum-a[i];
		ans=ans%mod+(sum%mod)*(a[i]%mod)%mod;
		ans=ans%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5156
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 32

int main() {
    char line[SIZE];
    while (fgets(line, SIZE, stdin) != NULL) {
        if (*line == '\n')
            continue;

        char *str;
        str = strtok(line, " ");
        long num[6];
        int i = 0;
        num[i] = atol(str);
        while ((str = strtok(NULL, " ")) != NULL) {
            num[++i] = atol(str);
        }
        long denom = num[0] * num[4] - num[1] * num[3];
        float ans_x = (float)(num[4] * num[2] - num[1] * num[5]) / denom;
        float ans_y = (float)(num[0] * num[5] - num[3] * num[2]) / denom;

        //Avoid -0
        if (ans_x == 0)
            ans_x = 0;
        if (ans_y == 0)
            ans_y = 0;
        printf("%.3f %.3f\n", ans_x, ans_y);
    }
}



Measured memory_bytes: 1980
#include <stdio.h>

long fac(int x){
	if(x==0) return 1;
	else return x*fac(x-1);
}

long pp(int a, int b){
	int i;
	long ans=1;
	
	for(i=b; i<=a; i++) ans*=i;
	
	return ans;
}

int main(void){
	while(1){
		long count=0;
		int i, j, k, n;		
		
		scanf(" %d", &n);
		if(n==0) break;
		
		for(i=0; i<=30; i++){
			for(j=0; j<=15; j++){
				for(k=0; k<=10; k++){
					if(i + 2*j + 3*k == n) count += pp(i+j+k, i+1)/fac(j)/fac(k);
					else if(i + 2*j + 3*k > n) break;
				}		
			}
		}
		
		printf("%ld\n", count / 3650 + 1);
	}
	
	return 0;
}

Measured memory_bytes: 600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	ans := "AC"
	c := 0
	for i, r := range s {
		if i == 0 {
			if string(r) != "A" {
				ans = "WA"
			}
		} else if string(r) == "C" && i >= 2 && i <= len(s)-2 {
			c++
		} else {
			if int(r) < 97 {
				ans = "WA"
			}
		}
	}
	if c != 1 {
		ans = "WA"
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1776
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[]){
    int a, b, q, i, j;
    char str[1001], v[1001], p[1001], c[10];
    scanf("%s %d",str,&q);
    for( i = 0 ; i < q ; i++ ){
        scanf("%s %d %d", c, &a, &b);
        if( strcmp(c,"print") == 0 ){
            for( j = a ; j <= b ; j++ ){
                printf("%c",str[j]);
            }
            printf("\n");
        }
        else if( strcmp(c,"reverse") == 0 ){
            strcpy(v,str);
            for( j = a ; j <= b ; j++ ){
                str[j] = v[b-(j-a)];
            }
        }
        else{
            scanf("%s", p);
            for( j = a ; j <= b ; j++ ){
                str[j] = p[j-a];
            }
        }
    }
    return 0;
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 1e5 + 9;
const ll mod = 1e9 + 7;
typedef pair<ll,ll> LL;

string s,t;
ll n,m,i,query,x,y,u,v;
ll b1[N],b2[N];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>s>>t; n = s.size(); m = t.size(); s = " " + s; t = " " + t;
    for (i = 1;i <= n;i++){
        b1[i] = b1[i - 1];
        if (s[i] == 'B') b1[i]++;
        else b1[i] += 2;
    }
    for (i = 1;i <= m;i++){
        b2[i] = b2[i - 1];
        if (t[i] == 'B') b2[i]++;
        else b2[i] += 2;
    }
    cin>>query;
    while(query--){
        cin>>x>>y>>u>>v;
        ll p = b1[y] - b1[x - 1],q = b2[v] - b2[u - 1];
        if (p%3 == q%3) cout<<"YES\n";
        else cout<<"NO\n";
    }
}



Measured memory_bytes: 5348
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

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

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, a, b);

  if (a <= 5)
    puts("0");
  else if (a <= 12)
    cout << b / 2 << endl;
  else
    cout << b << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll a, b;
  cin >> a >> b;
  ll h[999];
  h[0] = 1;
  FOR(i, 1, 999) { h[i] = h[i - 1] + i + 1; }
  cout << h[b - a - 2] - a;
  return 0;
}

Measured memory_bytes: 256
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>


#define DEBUG if(false)

using namespace std;

using ll = long long;
const int MOD = 1000000007;

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int sum = 0;
  if(K <= A){
    sum = K;
  }else if(K <= A+B){
    sum = A;
  }else{
    sum = A-(K-A-B);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3628
//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<assert.h>
#define DEBUG(s,a) cerr<<#s" = "<<(s)<<" \n"[(a)==1]

using namespace std;  typedef long long ll;   char __buf[1<<18],*__c=__buf,*__ed=__buf;
inline int qr(){
	int ret=0,f=0,c=getchar();
	while(!isdigit(c))f|=c==45,c=getchar();
	while(isdigit(c)) ret=ret*10+c-48,c=getchar();
	return f?-ret:ret;
}
const int maxn=8000+5;
const int mod=1e9+7;
int dp[maxn][maxn],N,n,jc[maxn],inv[maxn],A[200000+1],B[200000+1];

inline int MOD(const int&x){return x>=mod?x-mod:x;}
inline int MOD(const int&x,const int&y){return 1ll*x*y%mod;}

inline int ksm(const int&ba,const int&p){
	int ret=1;
	for(int t=p,b=ba;t;t>>=1,b=MOD(b,b))
		if(t&1) ret=MOD(ret,b);
	return ret;
}

void pre(const int&n){
	jc[0]=inv[0]=1;
	for(int t=1;t<=n;++t) jc[t]=MOD(jc[t-1],t);
	inv[n]=ksm(jc[n],mod-2);
	for(int t=n-1;t;--t) inv[t]=MOD(inv[t+1],t+1);
	for(int t=1;t<=n;++t) assert(MOD(inv[t],jc[t])==1);
}

int c(const int&n,const int&m){
	if(n<m) return 0;
	return MOD(jc[n],MOD(inv[m],inv[n-m]));
}

int main(){
	n=qr();
	for(int t=1;t<=n;++t) A[t]=qr(),B[t]=qr(),N=max({N,A[t],B[t]});
	++N;
	pre(8000);
	int ans=0;
	for(int t=1;t<=n;++t) ans=MOD(ans-c(A[t]+A[t]+B[t]+B[t],A[t]+A[t])+mod),dp[N-A[t]][N-B[t]]=MOD(dp[N-A[t]][N-B[t]]+1);
	for(int t=-N+1;t<N;++t)
		for(int i=-N+1;i<N;++i)
			dp[t+N][i+N]=MOD(dp[t+N][i+N]+MOD(dp[-1+t+N][i+N]+dp[t+N][-1+i+N]));
	for(int t=1;t<=n;++t) ans=MOD(ans+dp[A[t]+N][B[t]+N]);
	ans=MOD(ans,(mod+1)/2);
	printf("%d\n",ans);
	return 0;
}

//asdasdasd

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

int main() {
    int N;
    cin >> N;
    
    string result = "Three";
    for(int i = 0; i < N; i++)
    {
        string buf;
        cin >> buf;
        
        if(buf == "Y")
        {
            result = "Four";
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
V = list(map(int,input().split()))
cv1 = Counter(V[::2]).most_common()
cv2 = Counter(V[1::2]).most_common()
cv1.append((-1,0)); cv2.append((-1,0))
if cv1[0][0] != cv2[0][0]:
    print(n-cv1[0][1]-cv2[0][1])
else:
    print(min(n-cv1[1][1]-cv2[0][1], n-cv1[0][1]-cv2[1][1]))

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

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

 //    #ifndef ONLINE_JUDGE
	// 	freopen("../../a.in","r",stdin);
	// 	freopen("../../a.out","w",stdout);
	// #endif

	int x, y;
	cin >> x >> y;
	cout << max(x+y,max(x-1+x,y-1+y)) << "\n";
}	

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

#define ll long long

using namespace std;

int n,k,cot,ans;

int a[105];

int main()

{

    scanf("%d",&n);

    for(int i=1;i<=n;i++)

    {

        scanf("%d",&a[i]);

        cot+=a[i];

    }

    int res=10005;

    for(int i=1;i<=n;i++)

    {

        ans+=a[i];

        int t=abs(cot-2*ans);

        res=min(res,t);

    }

    printf("%d\n",res);

    return 0;

}

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

const int MAX_N = 20;

int main() {
  int N, V[MAX_N], C[MAX_N], D[MAX_N];

  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> V[i];
  }
  for(int i = 0; i < N; ++i) {
    std::cin >> C[i];
    D[i] = V[i] - C[i];
  }
  std::sort(D, D + N, std::greater<int>());

  int ans = 0;
  for(int i = 0; i < N; ++i) {
    if(D[i] > 0) ans += D[i];
    else break;
  }

  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  long long int n,res;
    int i;
    while(scanf("%lld",&n)==1){
            res=1;

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

   printf("%lld\n",res);

    }



   return 0;


    }

Measured memory_bytes: 1024
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int> 
#define N (1<<7)

int a,b;

int main()
{
	cin>>a>>b;
	if(a==1)a+=13;if(b==1)b+=13;
	if(a==b)cout<<"Draw";
	else if(a>b)cout<<"Alice";
	else cout<<"Bob";
	return 0;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut s: Vec<u8> = itr.next().unwrap().bytes().collect();
    s[n..].reverse();

    let mut unko = std::collections::HashMap::new();
    let mut unti = std::collections::HashMap::new();
    for bit in 0..1 << n {
        let mut t = Vec::new();
        let mut u = Vec::new();

        for i in 0..n {
            if bit >> i & 1 == 0 {
                t.push(s[i]);
            } else {
                u.push(s[i]);
            }
        }
        let p = unko.entry((t, u)).or_insert(0);
        *p += 1u64;
    }
    for bit in 0..1 << n {
        let mut t = Vec::new();
        let mut u = Vec::new();

        for i in 0..n {
            if bit >> i & 1 == 0 {
                t.push(s[n + i]);
            } else {
                u.push(s[n + i]);
            }
        }
        let p = unti.entry((t, u)).or_insert(0);
        *p += 1u64;
    }

    let mut ans = 0;
    for (k, v) in unko {
        let p = unti.entry(k).or_insert(0);
        ans += *p * v;
    }
    println!("{}", ans);
}


Measured memory_bytes: 164112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.1415926535
#define MOD 1000000007
 
int main(){
  
  string S,T;
  cin >> S >> T;
  
  string tmp = T.substr(0,S.size());
  if(tmp == S) cout<<"Yes"<<endl;
  else  cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] box = new boolean[n];
        int[] ball = new int[n];
        box[0]=true;
        for (int i=0;i<m;i++){
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            box[y]=box[x]||box[y];
            ball[x]--;
            ball[y]++;
            if (ball[x]==-1)box[x]=false;
        }
        int ans=0;
        for (int i=0;i<n;i++)if (box[i])ans++;
        System.out.println(ans);
    }
}

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

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


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

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt();
            long taka = Input.NextLong();
            long aoki = Input.NextLong();

            for (int i = 1; i < N; i++) {
                long ttmp = Input.NextLong();
                long atmp = Input.NextLong();

                long tmp = Math.Max(((taka - 1) / ttmp), (aoki - 1) / atmp) + 1;
                taka = ttmp * tmp;
                aoki = atmp * tmp;
            }

            Console.WriteLine(taka + aoki);
        }
    }

    class Input {
        static IEnumerator<string> enumerator;

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            if (enumerator == null || !enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
                enumerator.MoveNext();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

int n, a;

int main(){

    cin >> n >> a;

    if(n%500 <= a){
        cout << "Yes";
    } else{
        cout << "No";
    }





}

//g++ -std=c++14 comp.cpp -o b; ./b.exealso

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
t = list(map(int,input().split()))
if n == 1:
  if a[0] == t[0]:
    print(1)
  else:
    print(0)
  quit()
mod = 10**9+7
h = [[1,10**12] for i in range(n)]
h[0] = [a[0],a[0]]
h[-1] = [t[-1],t[-1]]
for i in range(1,n-1):
  h[i][1] = min(h[i][1],a[i])
  if a[i-1] < a[i]:
    h[i][0] = a[i]
for i in range(n-2,0,-1):
  h[i][1] = min(h[i][1],t[i])
  if t[i+1] < t[i]:
    h[i][0] = t[i]
ans = 1
for i in range(n):
  if h[i][0] > h[i][1]:
    print(0)
    quit()
  ans = (ans*(h[i][1]-h[i][0]+1))%mod
print(ans)

Measured memory_bytes: 95204
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;
struct point {
	int x,y;
}arr[maxn];
struct edge {
	int u,v,cost;
};
int pa[maxn];
int Find(int x) {
	return pa[x] == x ? x : pa[x] = Find(pa[x]);
}
void Union(int x,int y) {
	pa[Find(x)] = Find(y);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
		cin >> arr[i].x >> arr[i].y;
	vector<int> idxs(n);
	iota(idxs.begin(),idxs.end(),1);
	vector<edge> E;
	
	sort(idxs.begin(),idxs.end(),[=](int a,int b)->bool
		{return arr[a].x < arr[b].x;});
	for(int i=1;i<n;i++) {
		int u = idxs[i-1] , v = idxs[i];
		E.push_back(edge{u,v,arr[v].x - arr[u].x});
	}
	sort(idxs.begin(),idxs.end(),[=](int a,int b)->bool
		{return arr[a].y < arr[b].y;});
	for(int i=1;i<n;i++) {
		int u = idxs[i-1] , v = idxs[i];
		E.push_back(edge{u,v,arr[v].y - arr[u].y});
	}
	
	sort(E.begin(),E.end(),[=](edge a,edge b)->bool
		{return a.cost < b.cost;});
	iota(pa+1,pa+1+n,1);
	int ans = 0;
	for(edge e : E) {
		int u = e.u , v = e.v , cost = e.cost;
		if(Find(u) != Find(v))
			ans += cost , Union(u,v);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5876
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u32 = read();
    let b:Vec<u32> = (0..n-1).map(|_| read()).collect();

    let mut ans:u32 = 0;
    let mut prev:u32 = b[0];
    for i in 0..n-1 {
        let i = i as usize;
        if prev < b[i] {
            ans += prev;
        } else {
            ans += b[i];
        }
        prev = b[i];
    }
    ans += b[n as usize -2];

    println!("{}" ,ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const ll N=1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;

int main(){
    // in;
    // out;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a) cout<<k<<endl;
    else{
        ll x=k-a;
        if(x<=b) cout<<a<<endl;
        else{
            ll y=x-b;
            cout<<a-y<<endl;
        }
    }
    

}

Measured memory_bytes: 3224
import java.io.BufferedReader; 
import java.io.InputStreamReader; 
import java.io.IOException; 
import java.util.StringTokenizer; 
import java.util.Arrays;
public class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
       public  FastReader()
       {
           br=new BufferedReader(new InputStreamReader(System.in));
       }
       String next()
       {
           while(st==null ||!st.hasMoreElements())
           {
               try
               {
                   st= new StringTokenizer(br.readLine());
               }
               catch(IOException e)
               {
                   e.printStackTrace();
               }
           }
           return st.nextToken();
       }
      
       int nextInt()
       {
           return Integer.parseInt(next());
       }
       long nextLong()
       {
           return Long.parseLong(next());
       }
    }
    public static void main(String args[]) throws IOException
    {
        FastReader fs= new FastReader();
        long A= fs.nextLong();
        String B=fs.next();
        long res= (A* (((B.charAt(0)-'0')*100) +((B.charAt(2)-'0')*10) + (B.charAt(3)-'0')))/100;
        System.out.println(res);
    }

}

Measured memory_bytes: 32592
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void YN(bool ans){
    if(ans)cout<<"OK"<<endl;
    else cout <<"NG"<<endl;
    return;
}
int main(){
    ll A,B,K;
    cin>>K>>A>>B;
    bool ans = false;
    rep(i,A,B+1){
        if(i%K == 0){
            ans = true;
            break;
        }
    }
    YN(ans);
    return 0;
}

Measured memory_bytes: 3624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Closeable;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HBonsai
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AIrreversibleOperation solver = new AIrreversibleOperation();
        solver.solve(1, in, out);
        out.close();
    }

    static class AIrreversibleOperation {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            char[] S = in.next().toCharArray();
            int cnt = 0;
            long ans = 0;
            for (int i = 0; i < S.length; i++) {
                if (S[i] == 'W') {
                    ans += i - cnt;
                    cnt++;
                }
            }
            out.println(ans);
        }

    }

    static class FastScanner implements Closeable {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public void close() {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}



Measured memory_bytes: 24660
N = int(input())
ans = 0
ma = []
mi = []
for i in range(N):
    x1, x2 = map(int, input().split())
    mi.append(x1)
    ma.append(x2)

mi = sorted(mi)
ma = sorted(ma)

L = 0
R = 0

if N % 2 == 0:
    L = (mi[N//2-1]+mi[N//2]) / 2
    R = (ma[N//2-1]+ma[N//2]) / 2
    ans = int((R-L)/0.5)+1
else:
    L = mi[N//2]
    R = ma[N//2]
    ans = R - L + 1


print(ans)


Measured memory_bytes: 27020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main() {
  int n,k; cin >> n >> k;
  mint ans = 0;
  mint com[k+1];
  FORD(i,k,1){
    mint tmp = k / i;
    tmp = tmp.pow(n);
    FOR(j,2,k){
      if(i*j>k) break;
      tmp -= com[i*j];
    }
    com[i] = tmp;
    tmp *= i;
    ans += tmp;
  }
  cout << ans.x << "\n";

  
}

Measured memory_bytes: 4412
#include<stdio.h>
int main(){
  int n,m,i,j;
  scanf("%d %d",&n,&m);
  int a[m][2],b[n+1];
  for(i=0;i<n+1;i++)
    b[i]=0;
  for(i=0;i<m;i++)
   scanf("%d %d",&a[i][0],&a[i][1]);
  for(i=0;i<m;i++)
    if(a[i][1]==n)
      b[a[i][0]]=1;
  for(i=0;i<m;i++)
    if(a[i][0]==1 && b[a[i][1]]==1){
      printf("POSSIBLE\n");
      return 0;
    }
  printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 2560
N, M = map(int, input().split())
X = list(map(int, input().split()))

if M <= N:
  print(0)
  exit(0)
  
X.sort()
intervals = []
for i in range(M-1):
  intervals.append(X[i+1] - X[i])
  
intervals.sort()
R = max(X) - min(X)
for _ in range(N-1):
  R -= intervals.pop()
  
print(R)

Measured memory_bytes: 13968
import sys,math,collections,itertools,copy
input = sys.stdin.readline

H,W=list(map(int,input().split()))
s = []
dot_cnt = 0
for _ in range(H):
    a = input().rstrip()
    dot_cnt += a.count('.')
    s.append(list(a))

num_lis = [[float('inf')]*W for _ in range(H)]

#--#
for ih in range(H):
    for iw in range(W):
        if s[ih][iw]=='#':
            num_lis[ih][iw]=0
        else:
            if iw-1>=0:
                num_lis[ih][iw] = min(num_lis[ih][iw-1]+1,num_lis[ih][iw])
                
    for iw in range(W-1,-1,-1):
        
        if s[ih][iw]=='#':
            num_lis[ih][iw]=0
        else:
            if iw+1<=W-1:
                num_lis[ih][iw] = min(num_lis[ih][iw+1]+1,num_lis[ih][iw])

#--#
for iw in range(W):
    for ih in range(H):
        if s[ih][iw]=='#':
            num_lis[ih][iw]=0
        else:
            if ih-1>=0:
                num_lis[ih][iw] = min(num_lis[ih-1][iw]+1,num_lis[ih][iw])
                
    for ih in range(H-1,-1,-1):
        if s[ih][iw]=='#':
            num_lis[ih][iw]=0
        else:
            if ih+1<=H-1:
                num_lis[ih][iw] = min(num_lis[ih+1][iw]+1,num_lis[ih][iw])

maxOpe = 0
for iw in range(W):
    for ih in range(H):
        maxOpe = max(maxOpe,num_lis[ih][iw])
print(maxOpe)


Measured memory_bytes: 130528
#include <iostream>
#include <queue>
#define INF 1000000001
using namespace std;

int ary[100010];
int main(){
	priority_queue<int> que;
	int N,T;
	cin>>N>>T;
	for(int i=1;i<=N;i++){
		cin>>ary[i];
	}
	int mi=INF;
	for(int i=1;i<=N;i++){
		if(ary[i]<mi){
			mi=ary[i];
		}
		que.push(ary[i]-mi);
	}
	int qma=que.top(),cnt=0;
	while(!que.empty()){
		if(qma!=que.top()){
			break;
		}
		que.pop();
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 1276
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int K; cin >> K;
    rep(i, S.length()) {
        if (S[i] == 'a') continue;
        int distance = 'z' - S[i] + 1;
        if (K >= distance) {
            K -= distance;
            S[i] = 'a';
        }
    }
    K = K % 26;
    while(K--) S[S.length()-1] += 1;
    
    cout << S << endl;

    return 0;
}


Measured memory_bytes: 592
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void push1(int *a,int x);
int pop(int *a);
int isEmpty();
int top1;
struct stack2{
  int index;
  int area;
};
int ppcnt;
void push2(struct stack2 *a, int x1,int x2);
int top2;
int main()
{
  int n,r,i=0,k=0,all=0,st1[20001],c,ind,sub;
  struct stack2 st2[10001];
  char sente[20001];
  top1=0;
  top2=0;
  st2[0].index=-1;
  scanf("%s",sente);
  for(ind=0; ;ind++){
    if(sente[ind]=='\0')break;
    if(sente[ind-1]=='/' && sente[ind]!='/')ppcnt=sub;
    if(sente[ind]=='\\')push1(st1,ind);
    else if(sente[ind]=='/'){
      sub=pop(st1);
      if(sub!=-1)push2(st2,ind,sub);
    }
  }
  for(r=1;r<=top2;r++){
    all+=st2[r].area;
  }
  printf("%d\n",all);
  if(top2==0)printf("%d",top2);
  else {printf("%d ",top2);
    for(r=1;r<=top2;r++){
      printf("%d",st2[r].area);
      if(r!=top2)printf(" ");
    }
  }
  printf("\n");
  return 0;
}
void push1(int *a, int x){
  top1=top1+1;
  a[top1]=x;
  //printf("stack1  %d\n",a[top1]);
}
void push2(struct stack2 *a, int x1,int x2){
  int i,k=0;;
  if((a[top2].index<x2)){
    top2=top2+1;
    a[top2].index=x2;
    a[top2].area=x1-x2;
    //printf("index %d ",a[top2].index);
    //printf("area %d,top(up) %d\n",a[top2].area,top2);
  }else{
    a[top2].area+=(x1-x2);
    k = top2;
    for(i=top2-1;i>=1;i--){
      if(a[i].index > x2){
	a[top2].area += a[i].area;
	k = i;
      }
    }
    a[k].index = a[top2].index;
    a[k].area = a[top2].area;
    top2 = k;
    //printf("index %d ",a[top2].index);
    //printf("area %d, top(stay) %d\n",a[top2].area,top2);
  }
}
int pop(int *a){
  if(isEmpty()==1){
    return -1;
  }else{
    top1=top1-1;
    //printf("pop %d ",a[top1+1]);
    return a[top1+1];
  }
}
int isEmpty(){
  if(top1==0){
    return 1;
  }else{
    return 0;
  }
}



Measured memory_bytes: 2108
#include<iostream>

using namespace std;

int main(){
	int A, B;
	bool flag = false;
	cin >> A >> B;
	if(A % 3 == 0){
		flag = true;
	}else if(B % 3 == 0){
		flag = true;
	}else if((A + B) % 3 == 0){
		flag = true;
	}
	if(flag == true){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int a, b;

int main(){
    cin >> a >> b;
    int x;
    if(b < 10){
        x = a*10+b;
    }
    else if(b < 100){
        x = a*100+b;
    }
    else x = a*1000+b;
    int tmp = sqrt(x);
    if(tmp*tmp == x) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
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; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S;
    in >> S;
    ll l, c=0;
    l = SIZE(S);
    REP(i, l){
        if(S[i]!=S[l-1-i])c++;
    }
    out << c/2 << endl;

    //vector<ll> X(N);

}

Measured memory_bytes: 256