akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	vector<VL> c(3, VL(3, 0));
	FOR(i, 0, 3)
		FOR(j, 0, 3)
		c[i][j] = IN<LL>();

	string ans = "No";
	bool f = false;
	FOR(i, 0, 101) {
		FOR(j, 0, 101) {
			FOR(k, 0, 101) {
				vector<VL> c2 = c;
				FOR(a, 0, 3) {
					c2[0][a] -= i;
					c2[1][a] -= j;
					c2[2][a] -= k;
				}
				//cout << endl;
				//DUMP_VVI(c2);
				// check
				if (c2[0][0] == c2[1][0] && c2[1][0] == c2[2][0] &&
					c2[0][1] == c2[1][1] && c2[1][1] == c2[2][1] &&
					c2[0][2] == c2[1][2] && c2[1][2] == c2[2][2]) {
					ans = "Yes";
					f = true;
					break;
				}
			}
			if (f)break;
		}
		if (f)break;
	}
	O(ans);

	return 0;
}

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

int main(){
	char ch[3][3];
	
	for(int i = 0; i < 3; ++i){
		for(int j= 0; j < 3; ++j){
			cin >> ch[i][j];
		}
	}
	
	for(int i = 0; i < 	3; ++i){
		cout << ch[i][i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n,q;
int a[1000];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int b,m,e;cin>>b>>m>>e;
		rotate(a+b,a+m,a+e);
	}
	for(int i=0;i<n;i++)cout<<(i?" ":"")<<a[i];
	cout<<endl;
}


Measured memory_bytes: 3132
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {


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

		while (true) {

			final int N = sc.nextInt();
			
			if(N == 0){
				break;
			}
			
			int[] x_pos = new int[N];
			int[] y_pos = new int[N];
			
			x_pos[0] = 0;
			y_pos[0] = 0;
			
			for(int i = 1; i < N; i++){
				final int num = sc.nextInt();
				final int t = sc.nextInt();
				
				x_pos[i] = x_pos[num] + (t == 0 ? -1 : t == 2 ? 1 : 0);
				y_pos[i] = y_pos[num] + (t == 1 ? 1 : t == 3 ? -1 : 0);
			}
			
			int x_max = Integer.MIN_VALUE, x_min = Integer.MAX_VALUE;
			int y_max = Integer.MIN_VALUE, y_min = Integer.MAX_VALUE;
			
			for(int i = 0; i < N; i++){
				x_max = Math.max(x_max, x_pos[i]);
				x_min = Math.min(x_min, x_pos[i]);
				y_max = Math.max(y_max, y_pos[i]);
				y_min = Math.min(y_min, y_pos[i]);
			}
			
			System.out.println((Math.abs(x_max - x_min) + 1) + " " + (Math.abs(y_max - y_min) + 1));
		}
	}

}

Measured memory_bytes: 12000
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n, k := io.ScanInt2()
	prices := io.ScanInts(n)
	sort.Ints(prices)
	var sum int
	for i := 0; i < k; i++ {
		sum += prices[i]
	}
	fmt.Println(sum)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInt2() (int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt3() (int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInt4() (int, int, int, int) {
	return int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64()), int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y,z;
    bool operator<(const P &a)const{
        //if(y!=a.y) return y>a.y;
        return max(x,-x)>max(a.x,-a.x);

    }

};
vector<int> v[1];
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
int o[33];
int l[2];
int j[3];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<long long> s;

//priority_queue<P> q;
queue<P> q;
string r;
//char r[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int> p,p1;
//v.resize(unique(v.begin(),v.end())-v.begin());
/*struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> p;//safe_map;
*/
bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();



int main()
{
    scanf("%d",&a);
    cin>>r;
    for(int t=0;t<r.size();t++)
        o[r[t]-'a']++;
    x=1;
    for(int t=0;t<26;t++)
        x*=(o[t]+1),x%=mod;
    printf("%lld",x-1);
}



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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int a, b, t; cin >> a >> b >> t;
  cout << (t/a)*b << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    h,w = map(int, input().split())
    if (h == 0) and (w == 0):
        break
    
    for i in range(h):
        for j in range(w):
            if (i == 0) or (i == (h-1)) or (j == 0) or (j == (w-1)):
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()


Measured memory_bytes: 7004
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String args[])throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        List<String> list_1 = new ArrayList<>();
        List<String> list_2 = new ArrayList<>();
        String str_1 = br.readLine();
        String str_2 = br.readLine();

        list_1 = stringToList(str_1);
        list_2 = stringToList(str_2);
      
        if(list_1.get(0).equals(list_2.get(0))){
          System.out.println("0");
        }else{
          System.out.println("1");
        }
      }
    }

    // stringToList
    public static List<String> stringToList(String str){
      return Arrays.asList(str.split(" "));
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main() {
    ll x,y;
    cin >> x >> y;
    if(abs(x) == abs(y)) cout << 1 << endl;
    else if(abs(x) > abs(y)){
        if(x>0 && y>0) cout << abs(x)-abs(y)+2 << endl;
        else if(x>0 && y==0) cout << abs(x)-abs(y)+1 << endl;
        else if(x<0 && y>0) cout << abs(x)-abs(y)+1 << endl;
        else if(x<0 && y==0) cout << abs(x)-abs(y) << endl;
        else if(x>0 && y<0) cout << abs(x)-abs(y)+1 << endl;
        else cout << abs(x)-abs(y) << endl;
    }
    else{
        if(x>=0 && y>0) cout << abs(y)-abs(x) << endl;
        else if(x<0 && y>0) cout << abs(y)-abs(x)+1 << endl;
        else if(x>=0 && y<0) cout << abs(y)-abs(x)+1 << endl;
        else cout << abs(y)-abs(x)+2 << endl;
    }
}

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

vector<pair<int,pair<bool, int> > > v;
int n;
int something[100005];
int l[100005];
int r[100005];
int sumleft = 0;
int sumright = 0;

main(){
scanf("%lld",&n);
for (int x = 0; x<n; x++){
    int a,b;
    scanf("%lld%lld",&a,&b);
    v.push_back({a,{false,x}});
    v.push_back({b,{true,x}});
    sumleft+=a;
    sumright+=b;
    l[x] = a;
    r[x] = b;

}
sort(v.begin(),v.end());
int ans = 0;
bool possible = false;
for (int x = 0; x<n; x++){
    something[v[x].second.second]++;
    if (something[v[x].second.second]>1){
        possible = true;
    }
    ans += v[x].first;


}


if (possible){
    printf("%lld",ans);
    return 0;
}
int ans2 = min(sumleft,sumright);
if (ans == ans2){
    printf("%lld",ans);
    return 0;
}
for (int x = 0; x<n; x++){
    if (x==v[n-1].second.second){
        ans2 = min(ans2,ans-v[n-2].first+max(l[x],r[x]));
    }
    else{
        ans2 = min(ans2,ans-v[n-1].first + max(l[x],r[x]));
    }
}


printf("%lld",ans2);

}


Measured memory_bytes: 9456
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
	int x,y;
	int a,b;
	long long int ans;
	

	
	cin >> x >> y;
	
	COMinit();

	
	if( (x + y)%3 != 0){
		cout << 0;
		return 0;
	}
	else{
		b = (2*x - y)/3;
		a = (2*y - x)/3;
	}
	
	cout << COM(a+b,a) << endl;
	
	
	
	return 0;
}
				

Measured memory_bytes: 23680
/**
*    author:  yuya1234
*    created: 14.07.2020 11:48:12
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  double n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;

  ll mmax;
  mmax=max((ll)ceil(n/a),(ll)ceil(n/b));
  mmax=max(mmax,(ll)ceil(n/c));
  mmax=max(mmax,(ll)ceil(n/d));
  mmax=max(mmax,(ll)ceil(n/e));

  cout<<mmax+4<<endl;


  return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(x) cout << (x) << endl;
const int INF = 1e+8+7;
ll n,m;
string s,t;
int d[100],dp1[500][500],dp2[500][500];

int main(){
  cin >> n >> m;
  print(n+2*(m-n));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string str;
    cin >> n >> str;
    int l_cnt = 0;
    int r_cnt = 0;
    REP(i, n){
        if(str[i] == '(') l_cnt++;
        else if(str[i] == ')') l_cnt--;
        if(l_cnt < 0){
            r_cnt++;
            l_cnt = 0;
        }
    }

    string l_str, r_str;
    REP(i, r_cnt) l_str += "(";
    REP(i, l_cnt) r_str += ")";
    cout << l_str + str + r_str << "\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] s = new int[m];
        int[] c = new int[m];
        for (int i = 0; i < m; i++) {
            s[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        String[] number = new String[n];
        for (int i = 0; i < m; i++) {
            if (number[s[i] - 1] != null && !Integer.toString(c[i]).equals(number[s[i] - 1])) {
                number[s[i] - 1] = "x";
            } else {
                number[s[i] - 1] = Integer.toString(c[i]);
            }
        }

        for (int i = 0; i < number.length; i++) {
            if (number[i] == null) {
                number[i] = (1 < number.length && i == 0) ? "1" : "0";
            }
        }

        String result = String.join("", number);
        if (0 <= result.indexOf("x") || (1 < result.length() && result.charAt(0) == '0')) {
            result = "-1";
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 23252
S=input()
N=len(S)
counter=0
if N %2 ==0:
    half = int(N/2)
elif N%2==1:
    half = int((N-1)/2)

for i in range(half):
    if S[i]==S[-i-1]:
        pass
    else:
        counter= counter+1
print(counter)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	string s;
	cin >> s;
	map<ll, ll> t;
	rep(i,s.size()){
		t[s[i]]++;
	}
	for(auto x : t){
		if(x.second!=1){
			puts("no");
			return 0;
		}
	}
	puts("yes");
	return 0;
}

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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

char field[2001][2001];
vector<vector<int>> x_right, x_left, y_up, y_down;

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    x_right.resize(h);
    x_left.resize(h);
    y_up.resize(w);
    y_down.resize(w);
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) field[i][j] = s[j];
    }

    int cuml, cumr;
    rep(i, h) {
        cuml = 0;
        cumr = 0;
        rep(j, w) {
            if (field[i][j] == '.') ++cuml;
            else cuml = 0;
            if (field[i][w - j - 1] == '.') ++cumr;
            else cumr = 0;
            x_left[i].push_back(cuml);
            x_right[i].push_back(cumr);
        }
    }

    int cumu, cumd;
    rep(i, w) {
        cumu = 0;
        cumd = 0;
        rep(j, h) {
            if (field[j][i] == '.') ++cumu; 
            else cumu = 0;
            if (field[h - j - 1][i] == '.') ++cumd;
            else cumd = 0;
            y_up[i].push_back(cumu);
            y_down[i].push_back(cumd); 
        }
    }

    int ans = 0, res;
    rep(i, h) {
        rep(j, w) {
            if (field[i][j] == '#') continue;
            res = 0;
            res += x_left[i][j] + x_right[i][w - j - 1] + y_up[j][i] + y_down[j][h - i - 1] - 3;
            // cout << i << " " << j << " " << res << endl;
            ans = max(ans, res);
        } 
    }  

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 68480
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
   while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
   while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
   return f*x;
}
int n;
int64 a, b, c, d;
int main()
{
    n = read()-1, a = read(), b = read(), c = read(), d = read();
    for(int i = 0; i <= n; ++i)
        if(a+c*i-d*(n-i) <= b&&b <= a+d*i-c*(n-i))
            return puts("YES"), 0;            
    puts("NO");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int cntA=0,cntB=0;
	for (int i=0;i<3;i++){
		if (s[i]=='A') cntA++;
		else cntB++;
	}
	if (cntB&&cntA) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<iostream>

using namespace std;

int C,R,m[10][10005];

int dfs(int flg){
  int cookies=0;
  for(int i=0;i<R;i++){
    int tmp=0;
    for(int j=0;j<C;j++){
      if((!(flg & (1<<j)) && m[j][i]==0) || ((flg & (1<<j)) && m[j][i]==1))
        tmp++;
    }
    cookies+=max(tmp,C-tmp);
  }

  return cookies;
}


int solve(int x,int flg){
  if(x==C-1){

    return max(dfs(flg | (1<<x)),dfs(flg & (0xFFFF-(1<<x))));
    
  }else{
    return max(solve(x+1,flg | (1<<x)),solve(x+1,flg & (0xFFFF-(1<<x))));
  }
}


int main(){
  while (true){
    scanf("%d%d",&C,&R);
    if(C==0 && R==0) break;
    for(int i=0;i<C;i++)
      for(int j=0;j<R;j++)
        scanf("%d",&m[i][j]);

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

  return 0;
}

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


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


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

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

  int N, L[2222];

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> L[i];

  std::sort(L, L + N);

  long long C = 0;

  for (int i = 0; i < N; i ++) {
    for (int j = i + 1; j < N; j ++) {
      int x = L[i], y = L[j];

      if (x > y)
        std::swap(x, y);

      int n = std::lower_bound(L + j + 1, L + N, x + y) - (L + j + 1);

      C += n;
    }
  }

  std::cout << C << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int cnt[3]={0};
  rep(i,s.size()){
    cnt[s[i]-'a']++;
  }
  sort(cnt,cnt+3);
  if(cnt[2]-cnt[0] < 2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
	

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans=0;
    for( int i=1; i<n; i++){
        int cnt=0;
        for(char c='a'; c<='z';c++){
            bool left=false, right=false;
            for(int j=0;j<i;j++) if(s[j]==c) left=true;
            for(int j=i;j<n;j++) if(s[j]==c) right=true;
            if(left&&right) cnt++;
        }
        if(ans<cnt) ans = cnt;
    }
    cout << ans << endl;
}




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

using namespace std;

typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;
    map<ll, ll> items;
    for (int i = 0; i < N; ++i) {
        ll a, b;
        cin >> a >> b;
        items[a] += b;
    }

    ll result = 0;

    auto calc = [&](ll mask) {
        ll val = 0;
        for (const auto& item : items) {
            if ((mask | item.first) == mask) {
                val += item.second;
            }
        }
        if (result < val) {
            result = val;
        }
    };

    calc(K);
    for (int i = 0; i < 32; ++i) {
        if ((1ll << i) & K) {
            calc((K | ((1ll << i) - 1)) ^ (1ll << i));
        }
    }

    cout << result << endl;

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

// Problem Specific Parameter:

int main(void){
	int n,m;
	cin >> n >> m;

	
	vector<int> a(n);
	rep(i,n) cin >> a[i],a[i]--;

	vector<int> num(n,0);
	rep(i,n) num[a[i]]++;

	vector<int> sum(n,0);

	rep(i,n) rep(j,num[i]) if(i-j>=0) sum[i-j]++;

	int ans = 0;
	rep(i,n) if(sum[i]==0) ans++;

	
	rep(loop,m){
		int x,y;
		cin >> x >> y;
		x--,y--;

		num[a[x]]--;
		if(a[x]-num[a[x]] >=0){
			sum[a[x]-num[a[x]]]--;
			if(sum[a[x]-num[a[x]]]==0) ans++;
		}

		a[x]=y;

		if(a[x]-num[a[x]] >=0){
			sum[a[x]-num[a[x]]]++;
			if(sum[a[x]-num[a[x]]]==1) ans--;
		}
		num[a[x]]++;

		
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>//万能头 
using namespace std;
int main()//进入主函数 
{
	int n,k,ans=1;//定义变量 
	cin>>n>>k;//输入
	//循环将按ans和k中最小的一个加入ans变量 
	for(int i=0;i<n;i++)
	{
		ans+=min(ans,k);
	}
	cout<<ans;//输出 
	return 0;//拜拜了您嘞 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const ll MOD=1e9+7;
using namespace std;
const int dx[4]={-1, 0, 1, 0};
const int dy[4]={0, -1, 0, 1};

signed main(){
  ll H,W,N;
  ll sr,sc;
  string S,T;
  cin >> H >> W >> N;
  cin >> sr >> sc;
  cin >> S >> T;
  bool flag = true;

  //右に落としたい
  ll x = sc;
  for(ll i=0;i<N;i++){
    if(S[i]=='R') x++;
    if(x==W+1){
      flag = false;
    }
    if(T[i]=='L' && x>=2) x--;
  }
  //左に落としたい
  x = sc;
  for(ll i=0;i<N;i++){
    if(S[i]=='L') x--;
    if(x==0){
      flag = false;
    }
    if(T[i]=='R' && x<=W-1) x++;
  }

  ll y=sr;
  //上に落としたい
  for(ll i=0;i<N;i++){
    if(S[i]=='D') y++;
    if(y==H+1){
      flag = false;
    }
    if(T[i]=='U' && y>=2) y--;
  }
  //下に落としたい
  y=sr;
  for(ll i=0;i<N;i++){
    if(S[i]=='U') y--;
    if(y==0){
      flag = false;
    }
    if(T[i]=='D' && y<=H-1) y++;
  }

  cout << (flag?"YES":"NO") << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    // Failed to predict input format
    ll N, K;
    cin >> N >> K;
    vector<ll> d(K);
    vector<vector<ll>> A(K);
    for (long long i = 0; i < K; i++) {
        cin >> d[i];
        for (long long j = 0; j < d[i]; j++) {
            ll t;
            cin >> t;
            A[i].push_back(t);
        }
    }
    // mout(A);
    vector<int> v(N);
    for (long long i = 0; i < K; i++) {
        for (long long j = 0; j < d[i]; j++) {
            // debg(A[i][j]-1);
            v[A[i][j]-1]=1;
        }
    }
    ll cnt=0;
    for (long long i = 0; i < v.size(); i++) {
        if(v[i]==0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

const string ok="YES";
const string ng="NO";

typedef vector<int> V;
typedef vector<V> VV;

int main(){
    int N;
    cin>>N;
    map<int,int> d;
    REP(i,N){
        int D;
        cin>>D;
        d[D]++;
    }
    int M;
    cin>>M;
    string ret=ok;
    REP(i,M){
        int t;
        cin>>t;
        d[t]--;
        if(d[t]<0)ret=ng;
    }
    cout<<ret<<endl;
    
    return 0;
}


Measured memory_bytes: 9600
//#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;};

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);
    int N,C;
    cin >> N >> C;
    vvl D(C,vl(C)),c(N,vl(N));
    vector<map<ll,ll>> mp(3);
    rep(i,C){
        rep(j,C){
            cin >> D[i][j];
        }
    }
    rep(i,N){
        rep(j,N){
            cin >> c[i][j];
            c[i][j]--;
            mp[(i+j)%3][c[i][j]]++;
        }
    }
    ll ans=INF;
    rep(i,C){//i+j==0
        rep(j,C){//i+j==1
            rep(k,C){//i+j==2
                if(i==j||j==k||k==i)continue;
                ll res=0;
                rep(ii,3){
                    for(auto key:mp[ii]){
                        if(ii==0)
                        res+=key.second*D[key.first][i];
                        if(ii==1)
                        res+=key.second*D[key.first][j];
                        if(ii==2)
                        res+=key.second*D[key.first][k];
                    }
                }
                chmin(ans,res);
            }
        }
    }
    cout << ans << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  rep(i, n+1) {
    rep(j, n+1) {
      if (0<=m-i-j && m-i-j<=n) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define ll long long
using namespace std;

template<typename T>
T gcd(T a,T b){
  if(a<b){
    return gcd(b,a);
  }
  T r;
  while((r=a%b)){
    a=b;
    b=r;
  }
  return b;
}

int main(){
  int n;
  int A,B;
  cin >> n;
  if(n==1){
    cout <<"Hello World"<<endl;
  }
  if(n==2){
    cin >>A;
    cin >>B;
    cout <<A+B<<endl;
  }
	return 0;
}

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

int main() {
  int64_t N, M;
  cin >> N >> M;

  int64_t sum = 0;
  for (int64_t i = 0; i < M; i++) {
    int64_t A;
    cin >> A;
    sum += A;
  }

  cout << (sum <= N ? N - sum : -1) << endl;

  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define N_MAX 5000

int n,m;
int input_map[N_MAX][2];

int za_xnum;
int za_xlist[N_MAX+1];
int za_xlist_raw[N_MAX+1];
int za_ynum;
int za_ylist[N_MAX+1];
int za_ylist_raw[N_MAX+1];
int za_dupe[N_MAX+1];

int treasure_map[N_MAX+5][N_MAX+5];

/* posList[result]<=pos<posList[result+1] */
int za_get(int pos,int isx) {
	int left,right,mid;
	const int* posList;
	left=0;
	if(isx) {
		right=za_xnum-1;
		posList=za_xlist;
	} else {
		right=za_ynum-1;
		posList=za_ylist;
	}
	while(left<=right) {
		mid=(left+right)/2;
		if(posList[mid]==pos)return mid;
		else if(posList[mid]<pos)left=mid+1;
		else right=mid-1;
	}
	return left-1;
}

int qsort_comp(const void* x,const void* y) {
	int a=*((const int*)x);
	int b=*((const int*)y);
	if(a>b)return 1;
	if(a<b)return -1;
	return 0;
}

void za_setup(void) {
	int i;
	za_xlist_raw[n]=INT_MIN;
	za_ylist_raw[n]=INT_MIN;
	qsort(za_xlist_raw,n+1,sizeof(int),qsort_comp);
	qsort(za_ylist_raw,n+1,sizeof(int),qsort_comp);

	za_dupe[0]=0;
	for(i=1;i<=n;i++) {
		if(za_xlist_raw[i]==za_xlist_raw[i-1])za_dupe[i]=1; else za_dupe[i]=0;
		za_dupe[i]+=za_dupe[i-1];
	}
	for(i=0;i<=n;i++)za_xlist[i-za_dupe[i]]=za_xlist_raw[i];
	za_xnum=n+1-za_dupe[n];

	za_dupe[0]=0;
	for(i=1;i<=n;i++) {
		if(za_ylist_raw[i]==za_ylist_raw[i-1])za_dupe[i]=1; else za_dupe[i]=0;
		za_dupe[i]+=za_dupe[i-1];
	}
	for(i=0;i<=n;i++)za_ylist[i-za_dupe[i]]=za_ylist_raw[i];
	za_ynum=n+1-za_dupe[n];
}

int main(void) {
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++) {
		scanf("%d%d",&input_map[i][0],&input_map[i][1]);
		za_xlist_raw[i]=input_map[i][0];
		za_ylist_raw[i]=input_map[i][1];
	}
	za_setup();
	for(i=0;i<n;i++) {
		treasure_map[za_get(input_map[i][0],1)][za_get(input_map[i][1],0)]++;
	}
	for(i=0;i<za_xnum;i++) {
		for(j=1;j<za_ynum;j++) {
			treasure_map[i][j]+=treasure_map[i][j-1];
		}
	}
	for(j=0;j<za_ynum;j++) {
		for(i=1;i<za_xnum;i++) {
			treasure_map[i][j]+=treasure_map[i-1][j];
		}
	}

	for(i=0;i<m;i++) {
		int x1,y1,x2,y2;
		int xx1,yy1,xx2,yy2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		xx1=za_get(x1,1);
		yy1=za_get(y1,0);
		xx2=za_get(x2,1);
		yy2=za_get(y2,0);
		if(za_xlist[xx1]==x1)xx1--;
		if(za_ylist[yy1]==y1)yy1--;
		printf("%d\n",
			treasure_map[xx2][yy2]-treasure_map[xx1][yy2]-
			treasure_map[xx2][yy1]+treasure_map[xx1][yy1]);
	}

	return 0;
}

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

int n;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; 7*i<=n; ++i){
		if((n-7*i)%4 == 0){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> arr;
typedef vector<arr> matrix;
typedef vector<ll> longarr;
typedef vector<longarr> longmat;
typedef map<int, arr> graph;
arr dp(100001, -1);
graph G;
int solve(int src) {

	if (dp[src] != -1) return dp[src];
	if (G[src].size() == 0) {dp[src] = 0; return 0;}
	int ans = 0;
	for ( auto it : G[src]) {
		ans = max(ans, 1 + solve(it));
	}
	return dp[src] = ans;
}


int main() {
//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	int n, e;
	cin >> n >> e;
	int x, y;
	for (int i = 0; i < e; ++i) {
		cin >> x >> y;
		G[x].push_back(y);
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans = max(ans, solve(i));
	}

	cout << ans;

}

Measured memory_bytes: 14976
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  
  var tmpList = [];
  for(var i = 0; i < N; i++){
    tmpList.push(list[i] - (i + 1));
  }
  
  tmpList.sort(function(a,b){
  	return a-b;
  });
  
  var b = tmpList[myconv(tmpList.length / 2,1)];
  var output = 0;
  for(var i = 0; i < N; i++){
    output += Math.abs(list[i] - (b + (i + 1)));
  }
  myout(output);
}

Main(myin());


Measured memory_bytes: 38120
#include "bits/stdc++.h"

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999



int main(){
    int n,s;
    static int dp[11][350][1<<10]={};
    dp[0][0][(1<<10)-1]=1;
    
    
    for(int i=1;i<=10;i++){
        for(int j=0;j<=340;j++){
            rep(k,10){
                for(int l=(1<<10)-1;l>=0;l--){
                    if(j-(k*i)>=0 && (l&(1<<k))!=0){
                        dp[i][j][(l^(1<<k))] += dp[i-1][j-(k*i)][l];
                    }
                }
            }
        }
    }
    
    while(cin>>n>>s){
        int ans=0;
        if(s<=340){
            rep(i,1<<10){
                ans += dp[n][s][i];
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 15132
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var H = cin.ReadIntArray(N);

            var max = 0;
            for (int i = 0; i < N; i++)
            {
                if (H[i] > max)
                {
                    max = H[i];
                }
                else
                {
                    var diff = max - H[i];
                    if (diff > 1)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
            Console.WriteLine("Yes");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 29020
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a)
{ int sz = a.size(); for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

ll dp[200020][5];

int main(void){
  ioboost();

  int l;cin >> l;
  vl a(l+1,0);
  rep(i,l)cin >> a[i+1];

  rep(i,200020)rep(j,5)dp[i][j] = (1LL << 55);
  dp[0][0] = 0;
  
  for(int x = 0;x < l;x++){
    for(int p = 0;p <= 4;p++){
      for(int np = p;np <= 4;np++){
        ll add;

        if(np == 0 || np == 4)add = a[x+1];
        else if(np == 1 || np == 3)add = (a[x+1] == 0 ? 2 : a[x+1] % 2);
        else add = (a[x+1] + 1) % 2;

        chmin(dp[x+1][np],dp[x][p] + add);
      }
    }
  }

  ll ans = 1LL << 55;
  rep(i,5)chmin(ans,dp[l][i]);
  cout << ans << '\n';

}

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

const ll INF = 1LL << 60;


int main() {
    std::string S;
    std::cin >> S;
    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}


Measured memory_bytes: 3624
import java.util.*;
import java.lang.reflect.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n  = sc.nextInt();
        int a  = sc.nextInt();
        int b  = sc.nextInt();
        System.out.println(Math.min(a * n, b));
    }
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]!=t[i]) cnt++;
    }
    cout << cnt << endl;
}

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

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	int k1=0, k2=0, k3=0;
	for (int i=0; i<n; i++) {
		int p;
		cin>>p;
		if (p <= a)
			k1++;
		else if (p <= b)
			k2++;
		else
			k3++;
	}
	cout<<min(k1, min(k2, k3))<<endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        h: [i32;n],
        // com: [[u32;2];m]
        ab: [(usize, usize); m],
    }

    // println!("{:?}", ab);

    let mut v_peaks = vec![true; n as usize];

    for (a, b) in ab {
        if h[a - 1] >= h[b - 1] {
            v_peaks[b - 1] = false;
        }
        if h[b - 1] >= h[a - 1] {
            v_peaks[a - 1] = false;
        }
    }

    // // println!("{:?}", bad_peaks);

    println!("{}", v_peaks.iter().filter(|x| x == &&true).count());
}


Measured memory_bytes: 6088
n = gets.to_i
h = Hash.new(0)
n.times do |i|
  h[gets.chomp] += 1
end
puts 'AC x ' << h['AC'].to_s
puts 'WA x ' << h['WA'].to_s
puts 'TLE x ' << h['TLE'].to_s
puts 'RE x ' << h['RE'].to_s

Measured memory_bytes: 14296