akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	cin >> N;
	long long A[300][300];

	for (auto i = 0; i < N; ++i)
	{
		for (auto j = 0; j < N; ++j)
		{
			cin >> A[i][j];
		}
	}

	auto isValid = true;
	for (auto k = 0; k < N; ++k)
	{
		for (auto i = 0; i < N; ++i)
		{
			for (auto j = 0; j < N; ++j)
			{
				if (A[i][j] > A[i][k] + A[k][j])
				{
					isValid = false;
				}
			}
		}
	}

	if (isValid)
	{
		auto result = 0ll;
		for (auto i = 0; i < N; ++i)
		{
			for (auto j = i + 1; j < N; ++j)
			{
				auto isAdd = true;
				for (auto k = 0; k < N; ++k)
				{
					if (i == k || j == k)
					{
						continue;
					}

					if (A[i][j] == A[i][k] + A[k][j])
					{
						isAdd = false;
						break;
					}
				}

				if (isAdd)
				{
					result += A[i][j];
				}
			}
		}

		cout << result << endl;
	}
	else
	{
		cout << "-1" << endl;
	}

	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(n==1)
        printf("1\n");
    if(n==2||n==3)
        printf("2\n");
    if(n>=4&&n<=7)
        printf("4\n");
    if(n>=8&&n<=15)
        printf("8\n");
    if(n>=16&&n<=31)
        printf("16\n");
    if(n>=32&&n<=63)
        printf("32\n");
    if(n>=64)
        printf("64\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
/*AtCoder Beginner Contest 104(๑•﹏•๑｀)*/

int main(){
	integer D,G; SCLLD2(D,G);
	integer P[12] = {};
	integer C[12] = {};

	FORq(i,1,D){
		cin >> P[i];
		cin >> C[i];
	}



	vector<int> v(D);
	iota(v.begin(), v.end(), 1);

	integer ans = 100000000;

	do {
		integer restG = G;
		integer nans = 0;

		for(auto x:v){
			if (((P[x] * 100 * x) + C[x]) < restG){
				restG = restG - (P[x] * 100 * x) - C[x];
				nans += P[x];
				continue;
			} else{
				integer dem = 0;
				if ((restG % (x * 100)) == 0){
					dem = restG / (x * 100);
				}else{
					dem = (restG / (x * 100)) + 1;
				}

				dem = min(dem,P[x]);

				nans = nans + dem;
				break;
			}
		}


		ans = min(ans,nans);

    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成

	PRINTLLD(ans);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
		
		if(a*b%2 == 0){
          System.out.println("Even");
        }else{
          System.out.println("Odd");
        }  
	}
}

Measured memory_bytes: 21588
import java.io.IOException;
import java.util.ArrayList;
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 final int N_MAX = 500;
	public static final int M_MAX = 50;
	
	public static double inner_product(double[] in1, double[] in2){
		double sum = 0;
		
		for(int i = 0; i < in1.length; i++){
			sum += in1[i] * in2[i];
		}
		
		return sum;
	}
	
	public static double dist(double[] in){
		double ret = 0;
		for(double elem : in){
			ret += elem * elem;
		}
		
		return Math.sqrt(ret);
	}
	
	public static boolean check(double[] tele, double t_dist, double[] star, double rad){
		double[] small = new double[3];
		
		for(int i = 0; i < 3; i++){
			small[i] = tele[i] / t_dist;
		}
		
		double s_dist = 0;
		for(int i = 0; i < 3; i++){
			s_dist += (star[i] - small[i]) * (star[i] - small[i]);
		}
		s_dist = Math.sqrt(s_dist);
		
		double l_dist = Math.tan(t_dist);
		
		return l_dist >= s_dist;
	}
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		
		double[][] stars = new double[N_MAX][3];
		double[][] teles = new double[M_MAX][3];
		double[] rads = new double[M_MAX];
		boolean[] counted = new boolean[N_MAX];
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			Arrays.fill(counted, false);
			
			for(int i = 0; i < n; i++){
				for(int j = 0; j < 3; j++){
					stars[i][j] = sc.nextDouble();
				}
			}
			
			final int m = sc.nextInt();
			
			for(int i = 0; i < m; i++){
				for(int j = 0; j < 3; j++){
					teles[i][j] = sc.nextDouble();
				}
				
				rads[i] = sc.nextDouble();
			}
			
			int count = 0;
			for(int tele = 0; tele < m; tele++){
				final double t_len = dist(teles[tele]);
				
				for(int star = 0; star < n; star++){
					if(counted[star]){
						continue;
					}
					
					final double s_len = dist(stars[star]);
					
					final double inner = inner_product(teles[tele], stars[star]);
					
					final double rad = Math.abs(Math.acos(inner / (s_len * t_len)));
					
					//System.out.println(rad + " " + rads[tele]);
					
					if(rads[tele] > rad){
						counted[star] = true;
						count++;
					}
					
					//double l_dist = inner / s_len;
					
					//System.out.println(t_len + " " + l_dist);
					
					//if(0 > l_dist){
					//	continue;
					//}
					
					//if(check(teles[tele], l_dist, stars[star], rads[tele])){
					//	counted[star] = true;
					//	count++;
					//}
				}
			}
			
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 67908
#include<bits/stdc++.h>
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 FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 n, k;
double p[200010];
double e[200010], s[200010];

int main() {
    cin >> n >> k;
    rep(i, n) cin >> p[i];

    rep(i, n) e[i] = (p[i] + 1.0) / 2.0;
    rep(i, n) s[i+1] = s[i] + e[i];

    double ans = -1.0;
    for (int i = 0; i + k <= n; i++) {
        double tmp = s[i+k] - s[i];
        chmax(ans, tmp);
    }
    cout << fixed << setprecision(16) << ans << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
	bool color[8];
	int free = 0;

	for(int i=0;i<8;i++) color[i] = false;

	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		if(a/400 >= 8){
			free++;
		}else{
			color[a/400] = true;
		}
	}

	int kind = 0;
	for(int i=0;i<8;i++){
		if(color[i]) kind++;
	}


	cout << max(kind, 1) << " " <<  kind + free <<endl;


 	return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = list(range(0,n))
        self.sz = [1]*(n)

    def find(self, x):
        if(self.root[x]==x): return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y): return
        if(self.sz[x] > self.sz[y]): x,y = y,x
        self.sz[y] += self.sz[x]
        self.root[x] = y

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self,x):
        return self.sz[self.find(x)]

n,m = map(int,input().split())
ans = []
edge = []
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    edge.append([a,b])
edge.reverse()
ans.append(n*(n-1)//2)
uf = UnionFind(n)
for i in range(m - 1):
    ans.append(ans[i])
    a,b = edge[i][0],edge[i][1]
    if(uf.same(a,b)): continue
    c,d = uf.size(a),uf.size(b)
    ans[i + 1] -= c*d     
    uf.unite(a,b)
ans.reverse()
for i in range(m):
    print(ans[i])

Measured memory_bytes: 26404
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100010];
bool used[100010];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		a[i]=1;
	}
	used[1]=true;
	for (int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		a[x]--;
		a[y]++;
		if (used[x])
		{
			used[y]=true;
			if (!a[x])
			{
				used[x]=false;
			}
		}
	}
	int ans=0;
	for (int i=1;i<=n;i++)
	{
		if (used[i])
		{
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;


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

    int n;
    string s;
    cin >> n >> s;

    map<char, int> x;
    map<char, int> y;

    int res = 0;
    for (int i = 1; i < n - 1; ++i) {
        x.clear();
        y.clear();
        for (int j = 0; j < i; ++j) {
            x[s[j]]++;
        }
        for (int j = i; j < n; ++j) {
            y[s[j]]++;
        }

        int cnt = 0;
        for (auto e: x) {
            cnt += (y[e.first] > 0);
        }
        res = max(res, cnt);
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t 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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t 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) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<vector<mint> > dp(n+1, vector<mint>(13));
    dp[0][0] = 1;
    rep(i, n) {
        if('0' <= s[i] && s[i] <= '9') {
            int ss = s[i]-'0';
            rep(j, 13) {
                dp[i+1][(10*j + ss) % 13] = dp[i][j];
            }
        } else {
            rep(j, 13) {
                rep(k, 10) {
                    dp[i+1][(10*j + k) % 13] += dp[i][j];
                }
            }
        }
    }

    cout << dp[n][5] << endl;
}

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

#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 ALL(v) v.begin(), v.end()

int main() {
  std::cout << std::fixed << std::setprecision(20);

  static const long double pi = 3.141592653589793;
  long double A, B, H ,M;
  cin >> A >> B >> H >> M;

  long double AT = H/12.0 + M/60.0/12.0;
  long double BT = M/60.0;
  long double rad = abs(AT-BT);
  //if(rad > 0.5) rad -= 0.5;
  //rad = rad * 2.0*pi;

  long double d = A*A + B*B - (2.0*A*B)*cos(rad * 2.0*pi);


  cout << sqrt(d) << endl;

}

Measured memory_bytes: 4108
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define cost first
#define node second
using namespace std;
typedef pair <int,int> P;
int n,m;
vector <P> V[101];

int prim(int mn){
  int D[101]={},visited[101]={};
  for(int i=0;i<=n;i++) D[i] = 100000;
  priority_queue <P, vector<P>, greater<P> > Q;
  Q.push((P){0,1});

  int cnt=0,mxc=0,mnc=10000;
  while(!Q.empty()){
    P t=Q.top();Q.pop();
    if(visited[t.node] == 1) continue;
    visited[t.node] = 1, cnt++;

    if(cnt!=1)mxc = max(mxc,t.cost),mnc=min(mnc,t.cost);
    if(cnt == n && mnc == mn) return mxc;
    if(cnt ==n) return -1;
    for(int i=0;i<V[t.node].size();i++){
      int nn = V[t.node][i].node, ncost = V[t.node][i].cost;
      if(ncost < mn || visited[nn]==1|| D[nn]<=ncost)continue;
      D[nn] = ncost;
      Q.push((P){ncost,nn});
    }
  }
  return -1;
}

int main() {
  while(1) {
    cin >>n>>m;
    int cost[5001];
    if(n==0&&m==0) break;
    for(int i=0;i<=n;i++) V[i].clear();
    for(int i=0;i<m;i++){
      int a,b,c;
      cin >> a  >> b >> c;
      V[a].push_back((P){c,b});
      V[b].push_back((P){c,a});
      cost[i] = c;
    }
    sort(cost,cost+m);
    int ans = 100000;
    for(int i=0;i<m;i++) {
      int res = prim(cost[i]);
      if(res!=-1)ans = min(ans,res-cost[i]);      
    }
    if(ans == 100000) ans = -1;
    cout << ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1384
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss >> v[i];
    return ss;
}

template <class T> 
ostream& operator<<(ostream& ss, const vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
    return ss;
}

ll binpow(ll a, ll n, ll m) {
    ll res = 1;
    while (n) {
        if (n & 1) {
            res *= a;
            res %= m;
        }
        a *= (a % m);
        a %= m;
        n >>= 1;
    }
    return res % m;
}

ll gcd(ll a, ll b) {
    return b ? gcd (b, a % b) : a;
}

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

const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 2e5 + 5;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << a * b;
}

int main() {
    speed;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}

Measured memory_bytes: 3584
use strict;
use warnings;
package SuffixArray;
sub sa_is(\@$);
sub sa_is(\@$){
	my@s=@{$_[0]};
	my$upper=$_[1];
	my$n=@s;
	if($n==0){
		return();
	}
	elsif($n==1){
		return(0);
	}
	elsif($n==2){
		if($s[0]<$s[1]){
			return(0,1);
		}
		else{
			return(1,0);
		}
	}
	my@sa;
	my@ls;
	for(my$i=$n-2;$i>=0;$i--){
		$ls[$i]=$s[$i]==$s[$i+1]?$ls[$i+1]:$s[$i]<$s[$i+1];
	}
	my@sum_l=(0)x($upper+1);
	my@sum_s=(0)x($upper+1);
	$ls[$_]?$sum_l[$s[$_]+1]++:$sum_s[$s[$_]]++for 0..$n-1;
	for(0..$upper){
		$sum_s[$_]+=$sum_l[$_];
		$sum_l[$_+1]+=$sum_s[$_]if$_<$upper;
	}
	my$induce;
	$induce=sub{
		my@sa=(-1)x$n;
		my@buf=@sum_s;
		for(@_){
			next if$_==$n;
			$sa[$buf[$s[$_]]++]=$_;
		}
		@buf=@sum_l;
		$sa[$buf[$s[$n-1]]++]=$n-1;
		for(@sa){
			$sa[$buf[$s[$_-1]]++]=$_-1if$_>=1&&!$ls[$_-1];
		}
		@buf=@sum_l;
		for(my$i=$n-1;$i>=0;$i--){
			my$v=$sa[$i];
			$sa[--$buf[$s[$v-1]+1]]=$v-1if$v>=1&&$ls[$v-1];
		}
		return@sa;
	};
	my@lms_map=(-1)x($n+1);
	my$m=0;
	my@lms;
	for(1..$n-1){
		if(!$ls[$_-1]&&$ls[$_]){
			$lms_map[$_]=$m++;
			push@lms,$_;
		}
	}
	@sa=$induce->(@lms);
	if($m>0){
		my@sorted_lms=grep$lms_map[$_]!=-1,@sa;
		my@rec_s;
		my$rec_upper=0;
		$rec_s[$lms_map[$sorted_lms[0]]]=0;
		for(1..$m-1){
			my$l=$sorted_lms[$_-1];
			my$r=$sorted_lms[$_];
			my$end_l=$lms_map[$l]+1<$m?$lms[$lms_map[$l]+1]:$n;
			my$end_r=$lms_map[$r]+1<$m?$lms[$lms_map[$r]+1]:$n;
			my$same=1;
			if($end_l-$l!=$end_r-$r){
				$same=0;
			}
			else{
				$l++,$r++while$l<$end_l&&$s[$l]==$s[$r];
				$same=0if$l==$n||$s[$l]!=$s[$r];
			}
			$rec_upper++if!$same;
			$rec_s[$lms_map[$sorted_lms[$_]]]=$rec_upper;
		}
		my@rec_sa=sa_is(@rec_s,$rec_upper);
		$sorted_lms[$_]=$lms[$rec_sa[$_]]for 0..$m-1;
		@sa=$induce->(@sorted_lms);
	}
	return@sa;
}
sub suffix_array(\$){
	my@s=map ord,split"",${$_[0]};
	return sa_is(@s,255);
}
package LcpArray;
sub lcp(\@\@){
	my@s=@{$_[0]};
	my$n=@s;
	my@sa=@{$_[1]};
	my@rnk;
	$rnk[$sa[$_]]=$_ for 0..$n-1;
	my@lcp;
	my$h=0;
	for(0..$n-1){
		$h--if$h>0;
		next if$rnk[$_]==0;
		my$j=$sa[$rnk[$_]-1];
		$h++while$j+$h<$n&&$_+$h<$n&&$s[$j+$h]==$s[$_+$h];
		$lcp[$rnk[$_]-1]=$h;
	}
	return@lcp;
}
sub lcp_array(\$\@){
	my@s=map ord,split"",${$_[0]};
	return lcp(@s,@{$_[1]});
}
package main;
my$s=<>;
chomp$s;
my@sa=SuffixArray::suffix_array($s);
my@lcp=LcpArray::lcp_array($s,@sa);
my$ans=@sa*(@sa+1)/2;
$ans-=$_ for@lcp;
print$ans,$/;


Measured memory_bytes: 252056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  if(N %2 != 0){
    cout << 0 << endl;
  }
  else{
    N /= 10;
    int64_t ans = N;
    int64_t cnt = 5;
    while(cnt <= N){
      ans += N / cnt;
      cnt *= 5;
    }
    cout << ans << endl;
  }
}
  

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc113/tasks/abc113_d
//ポイント：上からDP
//参考：https://drken1215.hatenablog.com/entry/2019/04/23/183916

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  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;
  }
};

LL H,W,K;
 
mint ans = 0;

void solve(){
    if(W==1){
        ans.x = 1;
        return;
    }
    //縦棒を上からi刻み分についての入れ方のうち、
    //1からスタートしてj本目に到達するような
    //横線の入れ方の場合の数を
    //dp[i][j]とおく
    vector<vector<mint>> dp(H+1,vector<mint>(W,mint(0)));
    dp[0][0] = mint(1);
    //回収するイメージのDP
    for(int i=0;i<H;i++){
        int pattern = (1<<(W-1));
        //bitが例えば1010なら縦棒1,2間、3,4間に横線を引くと表現する
        for(int bit=0;bit<pattern;bit++){
            //横棒が隣り合うようなbitならfalseを返すラムダ式
            auto ok = [&](){
                for(int b=0;b<(W-1)-1;b++){
                    if(((bit>>b)&1)&&((bit>>(b+1))&1)) return false;
                }
                return true;
            };

            //どの横棒も隣り合わないなら
            if(ok()){
                for(int j=0;j<W;j++){
                    int nj = j;
                    if (bit & (1<<j)) nj++;
                    else if (j > 0 && (bit & (1<<(j-1)))) nj--;
                    dp[i+1][nj] += dp[i][j];
                }
            }
        }
    }
    ans = dp[H][K-1];
}
 
int main(){
    cin >> H >> W >> K;
 
    solve();
 
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

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

    int a[3] = {};
    rep(i, s.size()) {
        a[s[i]-'a']++;
    }


    if(abs(a[0]-a[1]) < 2 and abs(a[0]-a[2]) < 2 and abs(a[1]-a[2]) < 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  for(int i=0;i<19;i++){
    if(i!=5 && i!=13){
      cout<<s[i];
    }
    else{
      cout<<" ";
    }
  }
  cout<<"\n";
  return 0;
}

Measured memory_bytes: 3656
// In The Name Of God
#include <iostream>
#include <string.h>
#include <algorithm>
#include <set>
#include <vector>
#include <climits>
#include <map>
#include <queue>
#include <math.h>
#include <iomanip>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define MP make_pair
#define BSZ  __builtin_popcount
#define ALL(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

int n;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; ; i++)
		if (i * (i + 1) / 2 >= n)
			return cout << i << endl, 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 1e6+50;
int n, a[N], b[N];
int f[2*N], *cnt = f+N;

//求出中位数>=x的子区间个数
ll calc(int x) {
	REP(i,-n,n) cnt[i] = 0;
	ll ans = 0;
	int ret = 0, sum = 0, pos = 0;
	//ret维护0<=j<=i-1, s[j]<=s[i]的j的个数
	REP(i,1,n) {
		++cnt[sum], ++ret;
		if (a[i]>=x) ret += cnt[++sum];
		else ret -= cnt[sum--];
		ans += ret;
	}
	return ans;
}

int main() {
	scanf("%d", &n);
	REP(i,1,n) scanf("%d",a+i),b[i]=a[i];
	sort(b+1,b+1+n);
	int l=1,r=n,ans;
	ll m = (n+1ll)*n/2, pos = (m+1)/2;
	while (l<=r) {
		if (calc(b[mid])>=pos) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n", b[ans]);
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
inline int re(){
	char c;
	int w=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')w=-1;
	int res = c-'0';
	while((c=getchar())>='0'&&c<='9')res = res*10+c-'0';
	return res*w;
}
const int maxn = 1e5+5;
int n,m,b,c,fa[maxn];
inline int getfa(int x){
	return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}
int main(){
	scanf("%d %d",&n,&m);
	int ans = n-1;
	for(int i=1;i<=n;++i)fa[i] = i;
	for(int i=1,x,y;i<=m;++i){
		scanf("%d %d",&x,&y);
		int fx = getfa(x),fy = getfa(y);
		if(fx != fy)fa[fx] = fy,--ans;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 4200
N, M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

total = sum(A)

p = 0
threshold = total / (4 * M)

for i in A:
  if i >= threshold:
    p += 1

if M <= p:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
def C():
    H, W, K = map(int, input().split())
    C = []
    for _ in range(H):
        C.append(input())
    count = 0
    for mask_i in range(2**H-1):
        for mask_j in range(2**W-1):
            black = 0
            for i in range(H):
                for j in range(W):
                    if mask_i >> i & 1 == 0 and mask_j >> j & 1 == 0 and C[i][j] == '#':
                        black += 1
            if black == K:
                count += 1
    print(count)

C()

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

#define ll long long int
#define VI vector<int>
#define lf(i,a,b) for(int i=a;i<=b;i++)
ll k,n;
ll fun(ll b)
    {   ll cnt=(n/b)*(b-k);
        if(n%b>=k)
        {   cnt+=(min(n%b+1,b)-k);
        }
        //cout<<b<<" "<<cnt<<endl;
        if(k==0)
            cnt--;
        return cnt;
    }
int main()
{   cin>>n>>k;
    ll cnt=0;
    lf(ind,k+1,n)
    {   cnt+=fun(ind);
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3552
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  int a[11]={0};
  int i,j,maxa,maxb,maxc;
  

  for(i=0; i<10; i++){
    scanf("%d",&a[i]);
    //    maxa=max(maxa,a[i]);
  }

  for(i=0; i<10; i++){
    for(j=0; j<10; j++){
      if(a[i]>a[j]){
	swap(a[i],a[j]);
      }
    }
  }

  maxa=a[0];
  maxb=a[1];
  maxc=a[2];

  printf("%d\n%d\n%d\n",maxa,maxb,maxc);
  
  return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,S[100000],q,T[50000],c=0,i,i2,toread,cnt;
	cin>>n;
	for(i=0;i<n;i++)cin>>S[i];
	cin>>q;
	for(i=0;i<q;i++)cin>>T[i];
	/*for(i=0;i<n;i++){
		for(i2=0;i2<n;i2++){
			if(S[i]<S[i2]){
				toread=S[i];
				S[i]=S[i2];
				S[i2]=toread;
			}
		}
	}*/
	sort(S,S+n);
	for(i=0;i<q;i++){
		cnt=0;
		toread=n;
		while(toread>1){
			if(toread%2==0)toread/=2;
			else toread=(toread+1)/2;
			if(S[(toread-1)+cnt]<T[i])cnt+=toread;
			else if(S[(toread-1)+cnt]==T[i]){
				c++;
				break;
			}
		}
	}
	cout<<c<<endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, r;
	cin >> n >> r;
	if(n <= 10) {
		r += (10 - n) * 100; 
	}
	cout << r << '\n';
	return 0;
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 998244353;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    for (int i = 0;i < N; i++) cin >> A[i];

    vector<vector<int>> dp(N+1, vector<int>(S+1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int s = 0; s <= S; s++) {
            if (s + A[i] <= S) (dp[i+1][s+A[i]] += dp[i][s]) %= MOD;
            (dp[i+1][s] += dp[i][s] * 2) %= MOD;
        }
    }

    cout << dp[N][S] << endl;
    return 0;
}

Measured memory_bytes: 73684
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	matrix := make([][]int, N)
	for i := 0; i < N; i++ {
		matrix[i] = make([]int, N)
		fill(matrix[i], -1)
		A := sc.NextInt()
		for j := 0; j < A; j++ {
			x, y := sc.NextInt(), sc.NextInt()
			matrix[i][x-1] = y
		}
	}

	mx := 0
	for bit := 0; bit < 1<<uint(N); bit++ {
		ans := func() int {
			cnt := 0
			for k := 0; k < N; k++ {
				if bit&(1<<uint(k)) > 0 {
					cnt++
					//fmt.Println(bit, k)
					for l := 0; l < N; l++ {

						if matrix[k][l] == -1 || bit&(1<<uint(l)) > 0 == (matrix[k][l] == 1) {

						} else {
							//fmt.Println("Yes", bit, k, l, bit&(1<<l), matrix[k][l])
							return 0
						}
					}
				}
			}
			return cnt
		}()
		if mx < ans {
			mx = ans
		}
	}
	fmt.Println(mx)

}

func fill(arr []int, v int) {
	for i := 0; i < len(arr); i++ {
		arr[i] = v
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=233;
struct edge{
	int to,next;
}e[N*2];
int head[N],tot;
int mxd[N];
#define ll long long
ll ans1,ans2;
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
void dfs(int x,int fa,int d){
	int sum=0;
	for (int i=head[x];i;i=e[i].next)
		if (e[i].to!=fa){
			sum++;
			dfs(e[i].to,x,d+1);
		}
	mxd[d]=max(mxd[d],sum);
}
void solvert(int rt){
	memset(mxd,0,sizeof(mxd));
	dfs(rt,0,1);
	ll tot1=1,tot2=1;
	for (;mxd[tot1];tot1++)
		tot2=1ll*tot2*mxd[tot1];
	if (tot1<ans1||(tot1==ans1&&tot2<ans2))
		ans1=tot1,ans2=tot2;
}
void solveedge(int rt1,int rt2){
	memset(mxd,0,sizeof(mxd));
	dfs(rt1,rt2,1); dfs(rt2,rt1,1);
	ll tot1=1,tot2=2;
	for (;mxd[tot1];tot1++)
		tot2=1ll*tot2*mxd[tot1];
	if (tot1<ans1||(tot1==ans1&&tot2<ans2))
		ans1=tot1,ans2=tot2;
}
int n;
int main(){
	ans1=1e18,ans2=1e18;
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	for (int i=1;i<=n;i++){
		solvert(i);
		for (int j=head[i];j;j=e[j].next)
			solveedge(i,e[j].to);
	}
	printf("%lld %lld",ans1,ans2);
}

Measured memory_bytes: 256
#include<iostream>

#define MAX 100000 + 1

int parent(int i) { return i / 2; }

int left(int i) { return 2 * i; }

int right(int i) { return 2 * i + 1; }

int main() {
    int H;
    int A[MAX];

    std::cin >> H;
    for (int i = 1; i <= H; i++) {
        std::cin >> A[i];
    }

    for (int i = 1; i <= H; i++) {
        std::cout << "node " << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1) std::cout << "parent key = " << A[parent(i)] << ", ";
        if (left(i) <= H) std::cout << "left key = " << A[left(i)] << ", ";
        if (right(i) <= H) std::cout << "right key = " << A[right(i)] << ", ";
        std::cout << std::endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int sum = 0;
  for (int i = 0; i < N; i++){
    int x_i;
    cin >> x_i;
    sum += min ( 2 * x_i, 2 * ( K - x_i ) );
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 200020
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],pre[N],nxt[N],st[N],top,vis[N];
ll k;
int main(){
	n=read(),k=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	for(int i=1;i<=n;++i){
		if(pre[a[i]])nxt[pre[a[i]]]=i;
		pre[a[i]]=i;
	}
	for(int i=1;i<=n;++i){
		if(!nxt[pre[a[i]]])nxt[pre[a[i]]]=i;
	}
	int t=1;
	for(int u=1;u<=n;u=nxt[u]+1){
		if(nxt[u]<=u)++t;
	}
	k%=t;
	if(!k)return 0;
	for(int u=1,nt=1;u<=n;u=nxt[u]+1){
		if(nxt[u]<=u)++nt;
		if(nt>k){
			for(int i=u;i<=n;++i){
				if(vis[a[i]]){
					while(vis[a[i]])vis[st[top--]]=0;
				}
				else{
					vis[st[++top]=a[i]]=1;
				}
			}
			break;
		}
	}
	for(int i=1;i<=top;++i){
		printf("%d ",st[i]);
	}
	printf("\n");
	return 0;
}




Measured memory_bytes: 7472
object Main {
  def f(c : Char) : Int = c match {
  	case 'I' => 1
    case 'D' => -1
  }
  
  def main(args : Array[String]) {
    io.StdIn.readLine()
    println(io.StdIn.readLine.map(f).scanLeft(0)(_ + _).max)
  }
}

Measured memory_bytes: 25288
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
  
    def sum(self, i):
        s = 0
        while i > 0:
            s = max(s, self.tree[i])
            i -= i & -i
        return s
  
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = max(x, self.tree[i])
            i += i & -i

N, = map(int, input().split())
Hs = map(int, input().split())
As = map(int, input().split())
 
bit = Bit(N)
for h, a in zip(Hs, As):
    a0 = bit.sum(h)
    bit.add(h, a0+a)
print(bit.sum(N))


Measured memory_bytes: 119760
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
template <class T>
class Cumulative2DSum {
public:
    vector<vector<T>>sum;
    T e;
    Cumulative2DSum(vector<vector<T>>&v,T e) {
        int W = v.size();
        int H = v.front().size();
        ++H , ++W;
        sum = vector<vector<T>>(H,vector<T>(W,e));
        
        for(int i = 0; i < v.size(); ++i){
            for(int j = 0; j < v[i].size(); ++j){
                sum[i + 1][j + 1] +=  v[i][j];
            }
        }
        for(int i = 1; i < sum.size(); ++i){
            for(int j = 1; j < sum[i].size();++j){
                sum[i][j] += sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
            }
        }
    }
    auto query(int sx,int sy,int gx,int gy){
        return sum[gx][gy] - sum[sx][gy] - sum[gx][sy] + sum[sx][sy];
    }
};

signed main(){
    int n,m,Q;
    cin >> n >> m >> Q;
    vector<vector<int>>grid(n,vector<int>(n,0LL));
    rep(_,m){
        int l,r; cin >> l >> r;
        --l,--r;
        grid[l][r]++;
    }
    auto dcm = Cumulative2DSum<int>(grid,0LL);
    rep(_,Q){
        int l,r; cin >> l >> r;
        --l,--r;
        cout << dcm.query(l,l,r+1,r+1) <<endl;
    }
}


Measured memory_bytes: 4864
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

int main()
{
	int a;
	cin >> a;
	cout << 3*a*a << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
$p = int();
for($i = 0; $i <= 50000; $i++){
    if($p == floor($i * 1.08)){
        echo $i;
        exit;
    }
}
echo ":(";

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 4856
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef ll Type;
  int segn2;
  vector<Type> data, s_data;
  function<Type(Type, Type)> merge;

  StarrySkyTree(function<Type(Type, Type)> merge, int n): merge(merge)
  {
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 0);
    s_data.assign(segn2*2, 0);
  }

  StarrySkyTree(int n): //Original Ver.
    StarrySkyTree([](Type a, Type b){ return min(a, b); }, n) {}

  //get value of [a,b)
  Type query(int a, int b, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(r <= a || b <= l) return LLINF; //大きさに注意
    if(a <= l && r <= b) return data[k] + s_data[k];
    return min(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2 , r, k*2+2)) + s_data[k];
  }

  //add x to [a,b)
  Type add(int a, int b, Type x, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(a <= l && r <= b)
      s_data[k] += x;
    else if(a < r && l < b)
      data[k] = min(add(a, b, x, l, (l+r)/2, k*2+1), add(a, b, x, (l+r)/2, r, k*2+2));

    return data[k] + s_data[k];
  }

  Type val(int x){
    Type res = 0;
    x += segn2 - 1;

    while(x){
      res += s_data[x];
      x = (x-1)/2;
    }

    return res;
  }

  void add(int a, Type x){
    a += segn2 - 1;
    s_data[a] += x;

    while(a){
      a = (a-1)/2;
      data[a] = min(data[a*2+1] + s_data[a*2+1], data[a*2+2] + s_data[a*2+2]);
    }
  }
};

int main(){
  int N, A, B, p;

  scanf("%d%d%d", &N, &A, &B);

  StarrySkyTree seg(N+1);

  for(int i=0;i<N;i++){
    scanf("%d", &p);
    ll minVal = seg.query(0, p);

    seg.add(0, p, A);
    seg.add(p+1, N+1, B);

    ll q = seg.val(p);
    seg.add(p, minVal - q);
  }

  ll ans = seg.query(0, N+1);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
def inpl(): return list(map(int, input().split()))

#### START
a, b, c = map(int,input().split())
k = int(input())
m = max([a, b, c])

mk = m*(2**k)
print(mk+sum([a, b, c])-m)

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

#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...)        GET_MACRO(__VA_ARGS__, repn, rep0)(__VA_ARGS__)
#define rep0(i, b)      for(int i = 0; i < (b); ++i)
#define repn(i, a, b)   for(int i = a; i < (b); ++i)
#define trav(a, b)      for(auto& a : (b))
#define all(a)          (a).begin(),(a).end()
#define endl            '\n'
#define M               1000000007
#define tests           int ___;cin>>___;while(___--)

using namespace std;
using ll = int64_t;
using u64 = uint64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<int, int>;
using vpi = vector<pi>;

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

    vi grid(9);
    trav(g,grid) cin >> g;
    int n; cin >> n;
    rep(i, n) {
        int b; cin >> b;
        auto it = find(all(grid), b);
        if (it != grid.end())
            grid[it-grid.begin()] = 0;
    }
    rep(i, 3) {
        bool v = 1, v2 = 1;
        rep(j, 3) {
            if (grid[3*i+j] != 0) v = 0;
            if (grid[3*j+i] != 0) v2 = 0;
        }
        if (v || v2) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (grid[0] == 0 && grid[4] == 0 && grid[8] == 0) {
        cout << "Yes" << endl; return 0;
    }
    if (grid[2] == 0 && grid[4] == 0 && grid[6] == 0) {
        cout << "Yes" << endl; return 0;
    }
    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int n; std::cin >> n;
  bool ok = true;
  while (n--) {
    int a; std::cin >> a;
    if (a%2 == 0 && a%3 != 0 && a%5 != 0) ok = false;
  }
  if (ok) std::cout << "APPROVED" << std::endl;
  else std::cout << "DENIED" << std::endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    string n;
    cin >> n;
    int sum = 0;
    int x = 0;
    rep(i, n.length()) {
        sum += n[i] - '0';
        int tmp_num = n.length() - 1 - i;
        int tmp_x = n[i] - '0';
        while(1) {
            if ( tmp_num == 0 ) break;
            tmp_x *= 10;
            --tmp_num;
        }
        x += tmp_x;
    }
    if ( x % sum== 0 ) cout << "Yes" << endl;
    else               cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String s1 = inp.next();
        String s2 = inp.next();
        s1 = new StringBuffer(s1).reverse().toString();
        System.out.println(s1.equals(s2) ? "YES" : "NO");
    }
}

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

int main() {
    ll int h, w;
    cin >> h >> w;
    ll int ans;
    if(h==1 || w==1) ans = 1;
    else if(h%2==1 && w%2==1) ans = (h*w)/2 + 1;
    else ans = h*w/2;
    cout << ans << endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;

    int ans = 0;
    rep(i, s.size()) {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3916