akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string s[1000];
int dp[1000][1000];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    for( int i = 0; i < n; i++ ) {
        cin >> s[i];
    }
    for( int i = 0; i < n; i++ ) 
        for( int j = 0; j < m; j++ ) 
            dp[i][j] = 10000;
    dp[0][0] = s[0][0] == '#';
    for( int i = 0; i < n; i++ ) {
        for( int j = 0; j < m; j++ ) {
            if( 0 < i ) {
                if( s[i][j] == '#' && s[i-1][j] == '.' ) 
                    dp[i][j] = min( dp[i-1][j]+1, dp[i][j] );
                else
                    dp[i][j] = min( dp[i-1][j], dp[i][j] );
            }
            if( 0 < j ) {
                if( s[i][j] == '#' && s[i][j-1] == '.' ) 
                    dp[i][j] = min( dp[i][j-1]+1, dp[i][j] );
                else
                    dp[i][j] = min( dp[i][j-1], dp[i][j] );
            }
        }
    }
    cout << dp[n-1][m-1] << '\n';
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<array>
using uint = unsigned int;

void scan(uint&d) {
	d = 0;
	int c;
	while (c = fgetc(stdin), c == ' ' || c == '\n');
	do
		d = d * 10 + c - '0';
	while (c = fgetc(stdin), c != ' '&&c != '\n');
}
uint read() {
	uint d;
	scan(d);
	return d;
}

constexpr uint N = 502;

::std::array<::std::array<uint, N>, N> sum;

int main() {
	uint n, m, q;
	scan(n);
	scan(m);
	scan(q);
	uint l, r;
	while (m--) {
		scan(l);
		scan(r);
		++sum[1][r];
		--sum[l + 1][r];
	}

	for (uint i = 1;i < N;++i) {
		for (uint j = 1;j < N;++j) {
			sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
		}
	}

	while (q--) {
		scan(l);
		scan(r);
		printf("%u\n", sum[l][r]);
	}
	return 0;
}


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

int main() {
  
  int N, point, sum1, sum2;
  sum1 = 0;
  sum2 = 0;
  cin >> N;
  vector<int> card(N);
 
  for(int i=0; i < N; i++){
    cin >> point;
    card.at(i) = point;
    //cout << card.at(i) << ' ';
  }
  
   
  
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  
  //Aliceの所得するカードは、0スタートより偶数番のカード
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      sum1 = sum1 + card.at(i);
      //cout << sum1 << endl;
    }
  //Bobの所得するカードは、奇数番のカード
    if(i % 2 != 0){
      sum2 = sum2 + card.at(i);
      //cout << sum2 << endl;
    }
  }  
  //cout << sum1 << ' ' << sum2 << endl; 
  cout << sum1 - sum2 << endl;
  return 0;
}


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

using namespace std;

int main()
{
	char b;
	cin >> b;
	
	const map<char, char> m = {
		{'A', 'T'}, {'C', 'G'}, {'G', 'C'}, {'T', 'A'}
	};

	cout << m.at(b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-(x)))
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const int maxn = 5e5 + 10;
int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a;
    return 0;
}


Measured memory_bytes: 3620
N = int(input())
Ts = [int(input()) for i in range(N)]

def saishokoubaisuu(n,m):
    a = max(n,m)
    b = min(n,m)
    while b:
        a, b = b, a % b
    return n*m//a

ans = 1
for t in Ts:
    ans = saishokoubaisuu(ans,t)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define MAX_INF 0x1010101010101010
#define ARR_MAX 400
#define BUF_SIZE (ARR_MAX*11+50)

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(uint64_t *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtoll(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

int main(void) {
    uint64_t arr[ARR_MAX];
    // dp[size][start]
    static uint64_t dp[ARR_MAX+1][ARR_MAX];
    int num = get_int();
    fget_array(arr, num);
    int size, start;
    int i;
    static uint64_t cum[ARR_MAX+1];
    for(i = 1; i <= num; i++) {
        cum[i] = cum[i-1] + arr[i-1];
    }
    int start2;
    for(size = 2; size <= num; size++) {
        for(start = 0; start <= num-size; start++) {
            int end = start+size-1;
            uint64_t res = MAX_INF;
            uint64_t this = cum[end+1] - cum[start];
            // consider [start, start2-1], [start2, end]
            for(start2 = start+1; start2 <= end; start2++) {
                uint64_t size1 = start2-start;
                uint64_t size2 = end-start2+1;
                res = min(
                    res,
                    dp[size1][start] + dp[size2][start2] + this
                );
            }
#ifdef DEBUG
            printf("dp[%d][%d] = %llu\n", size, start, res);
#endif
            dp[size][start] = res;
        }
    }
    printf("%llu\n", dp[num][0]);
    return 0;
}

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

string s;
char c;
int q, t, f, r = 0;
deque<char> d;
int main() {
    cin >> s;
    for(int i = 0; i < s.length(); i++) d.push_back(s[i]);
    cin >> q;
    while(q--) {
        cin >> t;
        if(t == 1) {
            r = 1 - r;
        }
        else {
            cin >> f >> c;
            if((r && f == 1) || (!r && f == 2)) d.push_back(c);
            else d.push_front(c);
        }
    }
    if(r) {
        for(int i = d.size() - 1; i > -1; i--) cout << d[i];
    }
    else {
        for(int i = 0; i < d.size(); i++) cout << d[i];
    }
}

Measured memory_bytes: 896
fun main(args: Array<String>) = abc157d()

fun abc157d() {
    val (n, m, k) = readLine()!!.split(' ').map { it.toInt() }
    val abList = (1..m).map { readLine()!!.split(' ').map { it.toInt() - 1 }.let { Pair(it[0], it[1]) } }
    val cdList = (1..k).map { readLine()!!.split(' ').map { it.toInt() - 1 }.let { Pair(it[0], it[1]) } }

    val uf = UnionFind(n)
    for (ab in abList) {
        val (a, b) = ab
        uf.unite(a, b)
    }

    val friendOrBlocked = IntArray(n)

    for (ab in abList) {
        val (a, b) = ab
        friendOrBlocked[a]++
        friendOrBlocked[b]++
    }

    for (cd in cdList) {
        val (c, d) = cd
        if (uf.isSame(c, d)) {
            friendOrBlocked[c]++
            friendOrBlocked[d]++
        }
    }

    val answer = friendOrBlocked.mapIndexed { index, l -> uf.size(index) - l - 1 }.joinToString(" ")

    println(answer)
}

private class UnionFind(initSize: Int) {
    private val parent = IntArray(initSize) { it }
    private val size = LongArray(initSize) { 1L }

    fun root(x: Int): Int {
        if (x == parent[x]) return x

        val xr = root(parent[x])
        parent[x] = xr
        return xr
    }

    fun unite(x: Int, y: Int) {
        val xr = root(x)
        val yr = root(y)
        if (xr == yr) return

        if (size[xr] >= size[yr]) {
            size[xr] += size[yr]
            parent[yr] = xr
        } else {
            size[yr] += size[xr]
            parent[xr] = yr
        }
    }

    fun isSame(x: Int, y: Int): Boolean = root(x) == root(y)

    fun size(x: Int): Long = size[root(x)]
}


Measured memory_bytes: 90896
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  ll x[N], y[N], h[N];
  for(ll i=0;i<N;++i) {
    cin>>x[i]>>y[i]>>h[i];
  }
  ll tmpx, tmpy, tmph;
  if(h[0]==0) {
    for(int i=1;i<N;++i) {
      if(h[i]>0) {
        tmpx = x[i];
        tmpy = y[i];
        tmph = h[i];
        x[i] = x[0];
        y[i] = y[0];
        h[i] = h[0];
        x[0] = tmpx;
        y[0] = tmpy;
        h[0] = tmph;
        break;
      }
    }
  } 
  bool can = false;
  ll ans, ansx, ansy;
  ll zero = 0;
  for(ll cx=0;cx<=100;++cx) {
    for(ll cy=0;cy<=100;++cy) {
      can = true;
      for(ll i=0;i<N;++i) {
        if(i==0) ans = h[0] + abs(cx-x[0]) + abs(cy-y[0]);
        else {
          if(max(ans-abs(cx-x[i])-abs(cy-y[i]), zero)!=h[i]) {
            can = false;
            break;
          }
        }
      }
      if(can) {
        ansx = cx;
        ansy = cy;
        break;
      }
    }
    if(can) break;
  }
  cout<<ansx<<" "<<ansy<<" "<<ans<<endl;
}



Measured memory_bytes: 3640
$n = gets.to_i

def dfs(x,lr)
  return true if x+lr == $n
  return false if x+lr > $n

  if dfs(x+lr, 4)
    return "Yes"
  end
  if dfs(x+lr, 7)
    return "Yes"
  end

  return false
end

if dfs(0,4)
  puts "Yes"
elsif dfs(0,7)
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
<?php
 
$input = trim(fgets(STDIN));

$strs = str_split($input);
$result = array_count_values($strs);
$out = 'No';
if(count($result) == 2){

  $c = array_pop($result);

  if($c == 2){
    $out = 'Yes';
  }

}

print $out;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define Reverse(v) reverse(all(v))
#define Rsort(v) sort(all(v),greater)
#define pub(v) push_back(v)
#define pob(v) pop_back(v)
typedef long long ll;
typedef vector<ll> vel;
typedef vector<vector<ll>> vel2d;
typedef string str;
typedef pair<ll,ll> pal;
typedef vector<str> ves;


int main() {
    ll N,A,B,ans=0;
    cin>>N>>A>>B;
    ans+=(N/(A+B))*A;
    if(N%(A+B)<=A){ans+=N%(A+B);}
    else{ans+=A;}
    cout<<ans<<endl;
}


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

using namespace std;

int main()
{
    char a;
    cin >> a;
    if((a>='a')&&(a<='z')){
        cout << 'a';
    }
    else{
        cout << 'A';
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
    }
    int count =0;
    int m=vec.at(0);
    for(int i=0; i<N; i++){
        if( m >= vec.at(i)){
            m = vec.at(i);
            count++;
        }

    }
    cout << count << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

D getExpectation(D x) {
   return perform(x)/x;
}

int main()
{
    cin>>N>>M>>K;
    Int ans=(N*M)/2;
    cout<<ans<<"\n";
   
    
}

Measured memory_bytes: 26964
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long k){
    i64 ans = 0;
    for(int i = 0; i < k; ++i)
        for(int j = 0; j < k; ++j)
            for(int c = 0; c < k; ++c){
                ans += gcd(gcd(i + 1, j + 1), c + 1);
            }
    cout << ans << endl;
}


signed main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3764
import itertools, bisect
N = int(input())
d = len(str(N))
L =  []
for k in range(3,d+1):
    for a in itertools.product(["3","5","7"],repeat=k):
        if "3" in a and "5" in a and "7" in a:
            L.append(int("".join(a)))
L = sorted(L)
print(bisect.bisect_right(L,N))

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    cout << (N*N*N) <<endl;
    return (0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
    // 利子
    final static String INTEREST = "0.05";
    // 元金
    final static String INIT_LOAN = "100000";

    public static void main(String[] args) {
        // 入力値を一行分取得する。
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Integer inputNumber = null;
        try {
            inputNumber = Integer.valueOf(br.readLine());
        } catch (IOException e) {
            System.out.println("inputError" + e.getMessage());
        }

        BigDecimal interest = new BigDecimal(INTEREST);
        BigDecimal loan = new BigDecimal(INIT_LOAN);

        // n(入力値された値)年後の借金額を計算する。
        for (int i = 0; i < inputNumber; i++) {
            loan = loan.add(loan.multiply(interest));
            // 千円以下を切り上げ
            loan = loan.setScale(-3, BigDecimal.ROUND_UP);
        }
        System.out.println(loan.toBigInteger());
    }
}

Measured memory_bytes: 16940
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

template<class T>
inline ostream& operator <<( ostream& s, vector<T>& v ) {
	for( size_t i = 0; i < v.size(); ++i ) {
		if( i ) { s << ' '; }
		s << v[i];
	}
	return s;
}

int main() {
	ios_base::sync_with_stdio( false );

	int n;
	cin >> n;
	vector<int> a( n ), b, c;
	cin >> a;
	b = a;
	c = a;
	if( prev_permutation( a.begin(), a.end() ) ) { cout << a << endl; }
	cout << b << endl;
	if( next_permutation( c.begin(), c.end() ) ) { cout << c << endl; }

	return 0;
}



Measured memory_bytes: 3216
N, K = map(int, input().split())
A = list(map(int, input().split()))


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


g = A[0]
for i in range(1, N):
    g = gcd(g, A[i])

ma = max(A)
if K <= ma and K % g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 14224
#include <iostream>
using namespace std;
int main( )
{
    int x,y,i,j;
    char arr[10000][10000];
     cin>>x>>y;
     for(i=0;i<x+2;i++)
     {
         for(j=0;j<y+2;j++)
         {  
             if(i==0 || i==x+1 || j==0 || j==y+1)
             {
                 arr[i][j]='#';
             }
             else
             {
             cin>>arr[i][j];
             }
         }
     }
     for(i=0;i<x+2;i++)
     {
         for(j=0;j<y+2;j++)
         {     
            cout<<arr[i][j];
     }
     cout<<endl;
}
}

Measured memory_bytes: 2688
#include <stdio.h>
#include <math.h>
int main(void){
    double r, PI, S, L;
    scanf("%lf", &r);
    
    PI = acos(-1);
    S = 2*r*PI;
    L = r*r*PI;
    
    printf("%.6f %.6f\n", L, S);
    
    return 0;
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,x; cin>>n>>x;
	int ans; cin>>ans; ans=abs(ans-x);
	for(int i=1;i<n;++i){
		int a; cin>>a;
		ans=gcd(ans,abs(a-x));
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
int ceil(int a,int b){// a以上でbの倍数の最小値を出力//
    return (a+b-1)/b*b;
}
int stoii(string s){//stoi関数の代用 文字列を数値として読み取りint型に変換//
    return atoi(s.c_str());
}
int main (void){
    vector<int> a(3,0);
    int k;
    cin>>a[0]>>a[1]>>a[2]>>k;
    sort(a.begin(),a.end());
    cout<<a[2]*(1<<k)+a[1]+a[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;


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

int N; cin  >> N;
VP BA(N); rep(i, 0, N) cin >> BA[i].second >> BA[i].first;
sort(ALL(BA));

int now = 0;
for (PII ba: BA){
    if (now + ba.second <= ba.first) 
        now += ba.second;
    else {
        cout << "No\n";
        return 0;
    }
}
cout << "Yes\n";

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 3328
def main():
  N=int(input())
  l=[2,1]
  if N<2:
    print(1)
    exit()
  else:
    for i in range(N-2):
      l[0],l[1]=l[1],l[0]+l[1]
    print(l[0]+l[1])
      

if __name__ == "__main__":
  main()
    

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define all(x)     (x).begin() , (x).end()
typedef long long int ll;
using namespace std;

const ll     mod = 1e9+7;
const double eps = 1e-9;


int n,k;
const int N=2e5+10;
int a[N];

void solve(){
    cin >> n >> k;
    for(int i=0;i<n;++i)
        cin >> a[i];
    int l=1,h=1e9,ans=0;
    auto ok = [&](int m) {
        int cnt=0;
        for(int i=0;i<n;++i)
            cnt+=(a[i]-1)/m;
        return cnt<=k;
    };
    while(l<=h) {
        int md=(l+h)/2;
        if(ok(md))ans=md,h=md-1;
        else l=md+1;
    }
    cout << ans;
}


int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 4444
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    h = [int(i) for i in input().split()]

    mae = h[n-1]
    for i in range(n-2, -1, -1):
        if h[i] <= mae:
            mae = h[i]
        elif h[i]-1 == mae:
            pass
        else:
            print("No")
            sys.exit()
    print("Yes")


if __name__ == "__main__":
    main()


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

int main(){
int N;
cin >> N;
  
vector<int> A(N);
for (int i = 0; i < N; i++){cin >> A.at(i);}

    sort(A.begin(), A.end()); // {1, 2, 2, 5}
    reverse(A.begin(), A.end()); // {5, 2, 2, 1}
 
double ans = 0;
double v = 1;  
for (int i = 0; i < N-1; i++){
  v *= 2;
  ans += A.at(i) / v;
}

ans += A.at(N-1) / v ;
  
cout << ans << endl;  
 
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
	typedef long long ll;
	ll r,d,a;
	int main(){
		IOS
		cin>>r>>d>>a;
		for(int i=0;i<10;i++){
			a=a*r-d;
			cout<<a<<"\n";
		}
		
	} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int times;
    int n;
    
    while (scanf("%d", &n), n!=0){
        times=0;
        while (n!=1){
            n = n%2 ? 3*n+1 : n/2;
            times++;
        }
        printf("%d\n", times);
    }
    
    return 0;
}

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

const int maxn = 1e5 + 100;

int m, n, e_n, nxt[maxn << 1], head[maxn], to[maxn << 1], cyc[maxn], par[maxn], dep[maxn];
long long s, ans, val[maxn];
bool isr[maxn];

long long abs(long long x) {
	return x < 0 ? -x : x;
}

long long dfs(int u, int f, int p) {
	long long x = p ? 1 : -1;
	for (int i = head[u]; i; i = nxt[i]) {
		if(to[i] != f && !isr[to[i]]) {
			x += dfs(to[i], u, p ^ 1);
		}
	}
	if(f) {
		ans += abs(x);
	}
	return x;
}

void dfs2(int u, int f) {
	dep[u] = dep[f] + 1;
	par[u] = f;
	for (int i = head[u]; i; i = nxt[i]) {
		if(to[i] != f) {
			if(dep[to[i]]) {
				if(dep[to[i]] < dep[u]) {
					for(int v = u; v != to[i]; v = par[v]) {
						isr[cyc[m++] = v] = 1;
					}
					isr[cyc[m++] = to[i]] = 1;
				}
			}
			else {
				dfs2(to[i], u);
			}
		}
	}
	return;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int u, v, i = 0; i < m; ++i) {
		scanf("%d%d", &u, &v);
		nxt[++e_n] = head[u];
		to[e_n] = v;
		head[u] = e_n;
		nxt[++e_n] = head[v];
		to[e_n] = u;
		head[v] = e_n;
	}
	if(m == n - 1) {
		return !printf("%lld\n", dfs(1, 0, 0) ? -1 : ans);
	}
	m = 0;
	dfs2(1, 0);
	for (int i = 0; i < m; ++i) {
		s += (val[i] = dfs(cyc[i], 0, 0));
	}
	if(s & 1) {
		return !puts("-1");
	}
	if(m & 1) {
		s /= 2;
		for (int i = 1; i < m; i += 2) {
			s -= val[i];
		}
		for (int i = 0; i < m; ++i) {
			ans += abs(s);
			s = val[i] - s;
		}
		return !printf("%lld\n", ans);
	}
	s = 0;
	for (int i = 0; i < m; ++i) {
		s += (val[i] *= ((i & 1) ? -1 : 1));
	}
	if(s) {
		return !puts("-1");
	}
	for (int i = 1; i < m; ++i) {
		val[i] += val[i - 1];
	}
	std::sort(val, val + m);
	m >>= 1;
	for (int i = 0; i < m; ++i) {
		ans += val[i + m] - val[i];
	}
	return !printf("%lld\n", ans);
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int c = 0;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++)
        if(s[i] != t[i])
            c++;
    cout << c;

    return 0;
}


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

int main(void){
  int N,K,S[100000],B[1000][1000];
  int sum;
  int cnt;

  while(1){

    cnt = 0;

    cin >> N >> K;

    if( N == 0 && K == 0 ) break;

    for( int i = 0 ; i < K ; i++ ){

      cin >> S[i];

    }

    for( int j = 0 ; j < N ; j++ ){
      for( int i = 0 ; i < K ; i++ ){

	cin >> B[j][i];

      }
    }

    for( int i = 0 ; i < K ; i++ ){

      sum = 0;

      for( int j = 0 ; j < N ; j++ ){

	sum += B[j][i]; 

      }

      if( sum <= S[i] ) cnt++;
    
    }

    if( cnt == K ) cout << "Yes" << endl;
    else cout << "No" << endl;

  }

  return 0;

}

Measured memory_bytes: 1552
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P; 

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, init, n) for(ll i = init; i <(ll)(n); i++)

int main() {

    ll H, W, D;
    cin >> H >> W >> D;
    ll tmp;
    vector<P> A(H*W+1); 
    REP(i, H) REP(j, W){
        cin >> tmp;
        A[tmp] = P(i+1, j+1);
    }
    vector<ll> S(H*W+1, 0);
    rep(i, D+1, H*W+1){
        S[i] = S[i-D] + abs(A[i-D].first - A[i].first) + abs(A[i-D].second - A[i].second);
    }
    ll Q;
    cin >> Q;
    vector<ll> L(Q), R(Q);
    REP(i, Q) cin >> L[i] >> R[i];

    REP(i, Q) cout << (S[R[i]] - S[L[i]]) << endl; 


    return 0;
}

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


int main(){
	string s;
	cin>>s;
	
	vector<int> l(s.length()+1),r(s.length()+1);
	int count = 0;
	for(int i=0;i<=s.length();i++){
		l[i] = count;
		if(i<s.length() && s[i]=='<')count++;
		else count=0;
	}
	count = 0;
	for(int i=s.length() ;i>=0;i--){
		r[i] = count;
		if( i> 0 && s[i-1]=='>') count++;
		else count = 0;
	}
	long ans =0;
	//for(int i=0;i<=s.length();i++){
		//cout<<l[i];
	//}
	//cout<<endl;
	//for(int i=0;i<=s.length();i++){
		//cout<<r[i];
	//}
	//cout<<endl;
	
	for(int i=0;i<=s.length();i++){
		ans += max(l[i],r[i]);
	}
	cout<<ans;
	
	return 0;
}


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

using lli = int64_t;
using vi = vector<lli>;

int main()
{
    lli n; cin >> n;

    int u = 87;
    vi v(u);

    v[0] = 2;
    v[1] = 1;

    for(int i = 2; i < u; i++)
        v[i] = v[i - 1] + v[i - 2];

    cout << v[n] << endl;

    return 0;
}

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

const int N = 1e3 + 10;
const int M = 1e5 + 10; 

int n, w;
ll dp[N][M];
ll weight[N], value[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	cin >> n >> w;
	for (int i = 1; i <= n; ++i) cin >> weight[i] >> value[i];
	
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= w; ++j) {
			if (weight[i] <= j)
				dp[i][j] = max(value[i] + dp[i-1][j-weight[i]], 
								          dp[i-1][j]);
			else
				dp[i][j] = dp[i-1][j];
		}
	}

	cout << dp[n][w] << "\n";

	return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
ll nCr(ll n, ll r){
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
  ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
  return ret;
}

ll powa(ll a, ll b){
  ll ret = 1;
  rep(i,b){
    ret *= a;
  }
  return ret;
}

int main(void){
  ll k;cin>>k;
  ll base=0,seki=0,memo=0;
  while(true){
    seki = 0;
    rep(i,8){
      seki += powa(base,i);
    }
    if(seki > k || memo > seki){
      base--;
      break;
    }
    base++;
    memo = seki;
  }
  seki = 0;
  rep(i,8){
    seki += powa(base,i);
    cerr<<"i:"<<i<<"seki:"<<seki<<"powa:"<<powa(base,i)<<endl;
  }
  ll remain = k - seki;
  cerr<<"remain:"<<remain<<endl;
  vector<ll> ans;
  rep(i,8){
    ans.push_back(0);
  }
  if(base <= 1){
    ans[0] += remain;
  }else{
    rep(i,7){
      ans[i] += remain % base;
      remain /= base;
    }
    ans[7] += remain;
  }
  cerr<<"base:"<<base<<endl;
  cerr<<ans[0]<<endl;
  /*cerr<<base<<endl;
  rep(i,8){
    cerr<<ans[i]<<" ";
  }
  cerr<<endl;*/
  ll debug = 0;
  rep(i,8){
    debug += powa(base, i) * (ans[i] + 1);
  }
  cerr<<k<<" "<<debug<<endl;
  while(debug != k){

  }
  string fest = "FESTIVAL";
  rep(i,7){
    rep(j,base){
      cout<<fest[i];
    }
  }
  REP(i,8){
    rep(j,ans[i]){
      cout<<fest[i];
    }
  }
  rep(i,8){
    cout<<fest[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while( sc.hasNext() ) {
			String[] vals = sc.next().split(",");
			double w = Double.parseDouble( vals[1] ), h = Double.parseDouble(vals[2]);
			if( w / h / h >= 25 ) System.out.println(vals[0]);
		}
	}
}

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

int main(){
  int k;
  string s;
  cin >> k >> s;
  int s_size = s.size();
  if(s_size <= k)
    cout << s << endl;
  else{
    rep(i,k)  cout << s[i];
    cout << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    string s;
    cin >> s;
    int sum = 0;
    rep(i,s.size()){
        int m = s.at(i) - '0';
        sum += m;
    }
    string ans = "No";
    if(sum % 9 == 0) ans = "Yes";
    cout << ans << endl;
return 0;
}

Measured memory_bytes: 3720
import math
A,B,H,M=input().split();
A=int(A);
B=int(B);
H=int(H);
M=int(M);
PI=math.pi
radA=2*PI*H/12+2*PI*M/(12*60);
radB=2*PI*M/60;
Ax,Ay=A*math.sin(radA),A*math.cos(radA);
Bx,By=B*math.sin(radB),B*math.cos(radB);
L=(Ax-Bx)*(Ax-Bx)+(Ay-By)*(Ay-By);
L=math.sqrt(abs(L));
print(L);

Measured memory_bytes: 9536
n, k = map(int, input().split())
lr = []
for _ in range(k):
    l, r = map(int, input().split())
    lr.append((l, r))
mod = 998244353
dp = [0]*(2*n+1)
dp[0] = 1
dp[1] = -1
now = 1
for i in range(n):
    for l, r in lr:
        dp[i+l] += now
        dp[i+r+1] -= now
    now += dp[i+1]
    now %= mod
ans = 0
for i in range(n):
    ans += dp[i]
    ans %= mod
print(ans)

Measured memory_bytes: 71112
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }
int main() {
    int N;
    cin >> N;
    int ans = N%2==0 ? N/2 : N/2+1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
ll mod = pow(10, 9) + 7;
int main(){
    ll h, w, ans;
    cin >> h >> w;
  	if(h!=1 && w!=1){
      if(h%2==0){
          ans = h * w /2;
      }else{
          ans = (h-1) * w /2;
          ans += w/2;
          if(w%2==1){
              ans += 1;
          }
      }
    }else{
     ans = 1; 
    }
    cout << ans << endl;
}


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

using ll = long long;
using P = pair<int, int>;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  ll mini = min(a, min(b, min(c, min(d, e))));

  cout << (n + mini - 1) / mini + 4 << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    ２の累乗
    https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0406?year=2019
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;

    int den = 2;
    while (den <= n) {
        den *= 2;
    }
    cout << (den / 2) << endl;

    return 0;
}


Measured memory_bytes: 3192
use std::io::{stdin, Read};
use std::str::FromStr;

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

#[allow(dead_code)]
fn main() {
    let x = read::<usize>();
    let y = read::<usize>();
    let z = read::<usize>();
    let k = read::<usize>();
    let mut a = (0..x).map(|_| read::<i64>()).collect::<Vec<_>>();
    let mut b = (0..y).map(|_| read::<i64>()).collect::<Vec<_>>();
    let mut c = (0..z).map(|_| read::<i64>()).collect::<Vec<_>>();
    a.sort();
    b.sort();
    c.sort();
    a.reverse();
    b.reverse();
    c.reverse();

    struct Input {
        x: usize,
        y: usize,
        z: usize,
        k: usize,
        a: Vec<i64>,
        b: Vec<i64>,
        c: Vec<i64>,
    }

    let mut up = a[0] + b[0] + c[0];
    let mut mid = up;
    let mut down = a[x - 1] + b[y - 1] + c[z - 1];

    let input = Input {
        x: x,
        y: y,
        z: z,
        k: k,
        a: a,
        b: b,
        c: c,
    };

    let mut candidate = up;
    loop {
        let enough = solve(&input, mid);
        if enough {
            candidate = mid;
            down = mid + 1;
        } else {
            up = mid - 1;
        }
        if up <= down {
            break;
        }
        mid = (up + down) / 2
    }

    use std::collections::BinaryHeap;
    let mut q = BinaryHeap::new();
    for xi in 0..input.x {
        for yi in 0..input.y {
            for zi in 0..input.z {
                if input.a[xi] + input.b[yi] + input.c[zi] >= candidate {
                    q.push(input.a[xi] + input.b[yi] + input.c[zi])
                } else {
                    break;
                }
            }
        }
    }

    for _ in 0..k {
        println!("{}", q.pop().unwrap())
    }

    fn solve(input: &Input, p: i64) -> bool {
        let mut c = 0;
        for xi in 0..input.x {
            for yi in 0..input.y {
                for zi in 0..input.z {
                    if input.a[xi] + input.b[yi] + input.c[zi] < p {
                        break;
                    }
                    c += 1;
                    if c >= input.k {
                        return true;
                    }
                }
            }
        }
        false
    }
}


Measured memory_bytes: 134392
#include<iostream>
#include<bitset>
using namespace std;
int n,x,sum;
bitset<2000007>f;
int main()
{
    cin>>n;
    f[0]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        f|=f<<x;
        sum+=x;
    }
    
    for(int i=(sum+1)/2;i<=sum;i++)
    {
        if(f[i]) 
        {
            cout<<i<<endl;break;
            
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n+2];
    a[0]=0;
    a[n+1]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=1;i<=n+1;i++){
        sum+=abs(a[i]-a[i-1]);
    }
    int ans;
    for(int i=1;i<=n;i++){
        ans=sum-(abs(a[i+1]-a[i])+abs(a[i]-a[i-1]))+abs(a[i+1]-a[i-1]);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n; cin >> n;
	set<int> s;
	rep(i,n) {
		int a; cin >> a;
		s.insert(a);
	}
	int m=s.size();
	if(m==n) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 12924
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll Mod = 1000000007;
int main() {
  ll H,W;
  int N;
  cin >> H >> W;
  cin >> N;
  ll a[N],b[N];
  ll ans[10];
  for (int i = 0; i < 10; i++) ans[i] = 0;
  ans[0] = (H-2) * (W-2);
  map<P,bool> mat; 
  map<P,ll> res;
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    mat[make_pair(a[i],b[i])] = true;
  }
  for (int i = 0; i < N; i++) {
    for (int x = -2; x <= 0; x++) {
      for (int y = -2; y <= 0; y++) {
        bool inside = true;
        int cnt = 0;
        for (int j = 0; j < 3; j++) {
          for (int k = 0; k < 3; k++) {
            ll xx = a[i] + x + j;
            ll yy = b[i] + y + k;
            if (0 <= xx && xx < H && 0 <= yy && yy < W) {
              
            } else {
              inside = false;
            }
            if (mat[make_pair(xx,yy)]) {
              cnt++;
            }
          }
        }
        if (inside) {
          res[make_pair(a[i]+x,b[i]+y)] = cnt;
        }
      }
    }
  }

  for (auto p : res) {
    ans[p.S]++;
    ans[0]--;
  }

  for (int i = 0; i < 10; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 217516
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, m, q; cin >> n >> m >> q;
    vvint data(n+1,vint(n+1,0));
    rep(i,m) {
        int l, r; cin >> l >> r;
        data[l][r]++;
    }
    vvint accum_w(n+1,vint(n+1,0));
    REP(i,n+1)REP(j,n+1) {
        accum_w[i][j] = data[i][j] + accum_w[i][j-1];
    }
    vvint accum(n+1,vint(n+1,0));
    REP(i,n+1)REP(j,n+1) {
        accum[j][i] += accum_w[j][i] + accum[j-1][i]; 
    }
    rep(i,q) {
        int p, q; cin >> p >> q;
        int ans = accum[n][q] - accum[p-1][q];
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
//26

signed main(){
	int a, b;
	scanf("%lld%lld", &a, &b);
	if(a+b == 15)printf("+");
	else if(a*b == 15)printf("*");
	else printf("x");
	printf("\n");
	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    int h,w;
    cin>>h>>w;
    if(h==1||w==1)cout<<1<<endl;
    else cout<<(h*w+1)/2<<endl;
}


Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;

import java.util.*;
import java.io.*;

public class Main {
	double EPS = 1e-10;
	ArrayList<L> ls;
	HashSet<P> cr;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if( n == 0 ) break;
			
			ls = new ArrayList<L>();
			
			int sum = 1;
			for(int i=0;i<n;i++) {
				cr = new HashSet<P>();
				P p1 = new P(sc.nextDouble(), sc.nextDouble()), p2 = new P(sc.nextDouble(), sc.nextDouble());
				L l = new L(p1, p2);
				ls.add(l);
				int cnt = 0; 
				for(int j=0;j<ls.size()-1;j++) if( cross(l, ls.get(j)) ){
					P p = crossP(l, ls.get(j)); 
					if(!cr.contains(p)) cnt++;
					if(100 - abs(p.x) < EPS || 100 - abs(p.y) < EPS)  cnt--;
					else cr.add(p);
				}
				sum += cnt+1;
			}
			System.out.println(sum);
		}
	}
	
	P crossP(L l1, L l2) {
		double dx1 = l1.p1.x - l1.p2.x, dx2 = l2.p1.x - l2.p2.x,
			   dy1 = l1.p1.y - l1.p2.y, dy2 = l2.p1.y - l2.p2.y;
		double y = ( dy1 * dy2 * (l2.p1.x - l1.p1.x) + dx1*dy2*l1.p1.y - dx2*dy1*l2.p1.y ) / ( dx1*dy2 - dx2*dy1 );
		double x = ( dx1 * dx2 * (l2.p1.y - l1.p1.y) + dy1*dx2*l1.p1.x - dy2*dx1*l2.p1.x ) / ( dy1*dx2 - dy2*dx1 );
		return new P( x, y );
	}
	
	boolean cross(L l1, L l2) {
		return cross(l1.p1, l1.p2, l2.p1, l2.p2);
	}
	//線分交差判定
	boolean cross(P p1, P p2, P q1, P q2) {
		return ccw(p1, p2, q1) * ccw(p1, p2, q2) <= 0 &&
			ccw(q1, q2, p1) * ccw(q1, q2, p2) <= 0;
	}
	
	//時計回りなのか．反時計回りなのか，直線状なのか，とにかく位置関係をみる
	int ccw (P a, P b, P c) {
		P s = b.sub(a);
		P t = c.sub(a);
		if( s.det(t) > EPS ) return 1;
		if( s.det(t) < -EPS ) return -1;
		if( s.dot(t) < -EPS ) return 2;
		if( s.dot(s) + EPS < t.dot(t) ) return -2;
		return 0;
	}
	class L {
		P p1, p2;
		L(P p1, P p2) {
			this.p1 = new P(p1.x, p1.y);
			this.p2 = new P(p2.x, p2.y);
		}
	}
	
	class P {
		double x, y;
		P(double x, double y) {
			this.x = x;
			this.y = y;
		}
		double add(double a, double b) {	//誤差を考慮
			if( abs(a+b) < EPS * ( abs(a) + abs(b) ) ) return 0;
			return a + b;
		}
		
		P add(P p) {	//和
			return new P(x+p.x, y+p.y);
		}
		
		P sub(P p) {	//差
			return new P(x-p.x, y-p.y);
		}
		
		double dot(P p) {	//内積
				return add(x*p.x, y*p.y);
		}
		
		double det(P p) {	//外積
			return add(x*p.y, -y*p.x);
		}
		
		public boolean equals(Object o) {
			if( o instanceof P ) {
				P p = (P) o;
				if( d(new P(x, y), p) < EPS ) return true;
			}
			return false;
		}
		
		public int hashCode() {
			return (int)(x * 100000) + (int)(y * 100);
		}
	}
	
	double d(P p1, P p2) {
		return sqrt( (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y) );
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main()
{
    int i,j,s,f=0;
    scanf("%d",&s);
	for(i=1;i<=9;i++)
		for(j=1;j<=9;j++)
			if(i*j == s)
			{
				f=1;break;
			}
    if(s>100||s<1) f=0;
    if(f==1)
    printf("Yes");
    else
    printf("No");
    return 0;
}


Measured memory_bytes: 128
N, M = gets.split.map(&:to_i)

connects = Hash.new { |h, k| h[k] = [] }
can_speak = Hash.new

N.times do |i|
  k, *langs = gets.split.map(&:to_i)

  can_speak[i] = langs

  langs.each do |l|
    connects[l] << i
  end
end

queue = [0]
visited = Array.new(N, false)
lang_used = Array.new(N, false)

until queue.empty?
  v = queue.shift

  next if visited[v]
  visited[v] = true

  can_speak[v].each do |l|
    next if lang_used[l]
    lang_used[l] = true

    connects[l].each do |u|
      next if v == u

      queue.push(u)
    end
  end
end

if visited.all? { |t| t }
  puts 'YES'
else
  puts 'NO'
end


Measured memory_bytes: 18684
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> v(3);
  cin>>v[0]>>v[1]>>v[2];
  sort(v.begin(),v.end());
  if(v[0]==5 && v[1]==5 && v[2]==7)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            //var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var x = int.Parse(Console.ReadLine());
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());

            x -= a; // ケーキを買う

            while((x-b) >= 0) {
                x -= b;
            }


            Console.WriteLine(x);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();
		int d = sc.nextInt();

//		int a[][] = new int[h][w];
		int x[] = new int[h*w + 1];
		int y[] = new int[h*w + 1];
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				int num = sc.nextInt();

				x[num] = j;
				y[num] = i;
//				a[i][j] = sc.nextInt();
			}
		}

//		int matrix[][] = new int[h*w][h*w];
		long costFromStart[] = new long[h*w + 1];

		for(int i = 1; i <= h*w ; i++){
			if(i <= d){
				costFromStart[i] = 0;
			}
			else{
				costFromStart[i] = costFromStart[i - d] + Math.abs(x[i] - x[i - d]) + Math.abs(y[i] - y[i - d]);
			}
		}

		int q = sc.nextInt();
		for(int i = 0; i < q; i++){
			int l = sc.nextInt();
			int r = sc.nextInt();

			System.out.println(costFromStart[r] - costFromStart[l]);
		}
	}

}


Measured memory_bytes: 96368
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define pb push_back
int main(void){
  ll n,k;
  cin>>n;
  vi b(n-1);
  rep(i,n-1){
    cin>>b[i];
  }
  vi a(n);
  a[0]=b[0];
  a[1]=b[0];
  for(int i=1;i<n-1;i++){
    a[i]=min(a[i],b[i]);
    a[i+1]=b[i];
  }
  ll ans=0;
  rep(i,n){
    ans+=a[i];
  }
  cout<<ans;
  return 0;
}

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

using namespace std;

int main(){
    int N,Y;
    bool flag = false;
    cin >> N >> Y;
    for(int i=0;i<=2000;i++){
        for(int j=0;j<=2000;j++){
            if(i+j<=N && 10000*i+5000*j+(N-i-j)*1000 == Y){
                flag = true;
                cout << i << " " << j << " " << N-i-j << endl;
                break;
            }
        }
        if(flag){
            break;
        }
    }

    if(! flag){
        cout << "-1 -1 -1" << endl;
    }
}

Measured memory_bytes: 256