akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define print(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if ((a == b && b != c) || (a == c && b != c) || (b == c && a != b)) print("Yes");
    else print("No");
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np

    N, M, X = map(int, input().split())
    CA = np.array([list(map(int, input().split())) for i in range(N)])

    Z = [list(format(i, '0{}b'.format(N))) for i in range(2**N)]

    cost = np.inf
    for z in Z[1:]:
        ind = np.array(z) == '1'
        ca = np.sum(CA[np.where(ind)], axis=0)
        if np.sum(ca[1:] >= X) == M:
            cost = min(cost, ca[0])
    if cost == np.inf:
        cost = (-1)
    print(cost)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27584
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

ll GCD(ll a, ll b){
  ll M = max(a, b), m = min(a, b);
  while (M % m != 0){
    ll keep = m;
    m = M % m;
    M = keep;
  }
  return m;
}

int main(){
  ll A, B; cin >> A >> B;
  ll G = GCD(A, B);

  vector <ll> soinsuu;
  soinsuu.push_back(1);
  ll gcd = G;
  for (ll i = 2; i * i <= G; i++){
    int cnt = 0;
    while (gcd % i == 0){
      if (cnt == 0){
        soinsuu.push_back(i);
      }
      cnt++;
      gcd = gcd / i;
    }
  }
  if (gcd != 1){
    soinsuu.push_back(gcd);
  }
  cout << soinsuu.size() << endl;
  
  return 0;
}


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

typedef long long ll;

int main() {
	ll A, B, res = 0;
	cin >> A >> B;
	for (ll i = A; i <= B; i++) {
		string s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3]) res++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ans = 0;
        for (int i = 1; i < 1000; i++) {
            ans += k;
            if (ans >= a && ans <= b) {
                System.out.println("OK");
                return;
            }
        }
        System.out.println("NG");
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;


ll N, K; 
ll A[200000];
ll F[200000];


bool solve(ll m) {
	ll n = 0;

	for (int i = 0; i < N; i++) {
		ll a = A[i];
		ll f = F[i];

		if ( a * f > m) {
			ll tmp;
			tmp = m / f;
			n += a - tmp;
		}
	}

	if (n > K)
		return false;
	else
		return true;
}



int main(){

	cin >> N >> K;

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

	sort(A, A + N);
	sort(F, F + N, greater<ll>());


	ll l = 0;
	ll r = LLONG_MAX;

	for (int i = 0; i <= 512; i++) {
		ll mid = (l+r) / 2;

		bool ok = solve(mid);
		if (ok) {
			r = mid;
		} else {
			l = mid;
		}

	}

	cout << r << endl;

	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
using namespace std;

int main() {
	int num;
	cin >> num;
	int ans = 1;
	ans *= num * num * num;
	cout << ans;
	return 0;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        a_s: [[u16;3];3],
        n: usize,
        b: [u16;n],
    }
    let mut asss = a_s.clone();
    for i in b.iter(){
        for ass in asss.iter_mut(){
            match ass.iter().enumerate().find(|&(_,a)| a == i).map(|(k,_)|k) {
                Some(k) => ass[k] = 0,
                None => (),                
            }
         }
    }
    if asss[0][0] == 0 && asss[0][1] == 0 && asss[0][2] == 0 
    || asss[1][0] == 0 && asss[1][1] == 0 && asss[1][2] == 0
    || asss[2][0] == 0 && asss[2][1] == 0 && asss[2][2] == 0
    || asss[0][0] == 0 && asss[1][0] == 0 && asss[2][0] == 0
    || asss[0][1] == 0 && asss[1][1] == 0 && asss[2][1] == 0
    || asss[0][2] == 0 && asss[1][2] == 0 && asss[2][2] == 0
    || asss[0][0] == 0 && asss[1][1] == 0 && asss[2][2] == 0
    || asss[0][2] == 0 && asss[1][1] == 0 && asss[2][0] == 0{
        println!("Yes");
    }else{
        println!("No");
    }
}    


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

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

double x;

int main() {
    scanf("%lf", &x);
    x /= 3;
    printf("%.10f", x * x * x);
    return 0;
}

Measured memory_bytes: 256
def solve(N):
    s = 1
    e = int(pow(N, 0.5)) + 1
    ds = []
    for i in range(s, e):
        if N % i == 0:
            m = (N // i) - 1
            if m and N // m == N % m:
                ds.append(N // i)

    return sum([i - 1 for i in ds])

if __name__ == "__main__":
    N = int(input())
    print(solve(N))


Measured memory_bytes: 3188
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
	string S,T="CODEFESTIVAL2016";
	int i,a=0;
	cin >> S;
	for (i = 0; i < 16; i++) {
		if (S[i] != T[i]) {
			a +=1 ;

		}
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;;

int main() {
  int n, m;  cin >> n >> m;
  vector<int> r(n, INF);
  for(int i=0; i<m; i++){
    int a, b;  cin >> a >> b;
    --a; --b;
    r[a] = min(r[a], b);
  }

  int x = INF, ans = 0;
  for(int i=0; i<n; i++){
    if (x == i) x = INF, ans++;
    x = min(x, r[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
12
757232153 372327760 440075441 195848680 354974235 458054863 463477172 740174259 615762794 632963102 529866931 64991604
74164189 98239366 465611891 362739947 147060907 118867039 63189252 78303147 501410831 110823640 122948912 572905212
)");
#define cin input
#endif

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

	vector<int> a(n), b(n);

	for (auto& i : a)
		cin >> i;

	for (auto& i : b)
		cin >> i;

	vector<int> d(n);
	ll s = 0;
	REP (i, n)
	{
		d[i] = a[i] - b[i];
		s += d[i];
	}

	if (s < 0)
	{
		cout << -1 << endl;
		return 0;
	}

	sort(d.begin(), d.end());

	auto li = d.begin();
	auto ri = d.rbegin();

	int t = 0;

	while (*li < 0)
	{
		while (t < -*li)
		{
			t += *ri;
			*ri = 0;
			++ri;
		}
		t += *li;
		*li = 0;
		++li;
	}

	cout << ((li - d.begin()) + (ri - d.rbegin())) << endl;

	return 0;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;
  n -= 400;

  cout << (8 - n / 200) << endl;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

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

ll f(ll n,ll x){
    if (n == -1){
        return 0;
    }
    return n/x + 1;
}

int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll ans = f(b,x) - f(a-1,x);
    
    cout << setprecision(18) << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int A,B;
	string S;
	cin>>A>>B;
	cin>>S;
	if (S[A]!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	int len=S.length();
	if (len!=A+B+1){
		cout<<"No"<<endl;
		return 0;
	}
	int i;
	for (i=0;i<A;i++){
		if (S[i]<'0' || S[i]>'9'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	for (i=A+1;i<len;i++){
		if (S[i]<'0' || S[i]>'9'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int p;
    cin >> p;
    auto mod = [&](int x) {
        return (x % p + p) % p;
    };
    function<int (int, int)> pow = [&](int a, int r) {
        if (r == 0) return 1;
        int y = pow(a, r/2);
        int z = (y*y)%p;
        return r % 2 == 1 ? (z*a) % p : z;
    };
    auto inv = [&](int x) {
        return pow(x, p-2);
    };
    // Let g(x) = (x - x^p)/(x-1)
    // Clearly g(x) = 0 for all x != 1.
    // We can also write g as:
    // g(x) = - x - x^2 - ... - x^{p-1}
    // Hence g(1) = -(p-1) = 1
    // So we have g(x) = [x=1] in iversion notation.
    // So now the algorithm is simple:
    // Let I be the set of indices i for which a_i = 1.
    // The answer is then p(x) = \sum_{i \in I} g(x/i).
    // There is one small issue: What about i=0?
    // Here we can simply choose 1 - x^(p-1) instead of g(x/0).
    // Note:
    // We could also avoid the special case by instead of adding g(x/i) we would add:
    // 1 - (i^(p-1) - i^(p-2) x - i^(p-3) x^2 - .... - i x^(p-2) - x^(p-1))
    vector<int> cs(p, 0);
    for (int i = 0; i < p; ++i) {
        int a;
        cin >> a;
        if (a == 1) {
            if (i == 0) { // special case since g(x/0) doesn't make sense.
                cs[0] = mod(cs[0] + 1);
                cs[p-1] = mod(cs[p-1] - 1);
            } else {
                int inv_i = inv(i);
                int inv_i_j = inv_i; // this will equal i^{-j} during the for loop
                for (int j = 1; j <= p-1; ++j) {
                    cs[j] = mod(cs[j] - inv_i_j);
                    inv_i_j = (inv_i_j * inv_i) % p;
                }
            }
        }
    }
    for (int c : cs) {
        cout << c << " ";
    }
    cout << endl;
    return 0;
}


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

int n;
pair<long long, long long>p[200003];
long long ans=0;

bool cmp1(pair<long long, long long>a, pair<long long, long long>b){
	return a.first+a.second<b.first+b.second;
}

bool cmp2(pair<long long, long long>a, pair<long long, long long>b){
	return a.second-a.first>b.second-b.first;
}

bool cmp3(pair<long long, long long>a, pair<long long, long long>b){
	return a.first-a.second>b.first-b.second;
}

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> p[i].first >> p[i].second;
	sort(p,p+n,cmp1);
	ans=max(ans,p[n-1].first-p[0].first+p[n-1].second-p[0].second);
	sort(p,p+n,cmp2);
	pair<long long, long long>tmp=p[0];
	sort(p,p+n,cmp3);
	ans=max(ans,abs(tmp.first-p[0].first)+abs(tmp.second-p[0].second));
	cout << ans << "\n";
}

Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int n;
  cin >> n >> s;
  int len = s.size();
  for(int i = 0; i < len; i ++){
    s[i] = ((s[i] - 'A') + n )% 26 + 'A';
  }
  cout << s << endl;
  return 0;
}


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


public class MyProgram
{	

    public static void Main()
	{
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = n[0];
        int K = n[1];
        
        int cnt = 1;
        for(int i = K ; i < N ; i+=(K-1))
        {
            cnt++;
        }
        Console.WriteLine(cnt);
	}
}

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

int main(){
	int a,b,h;
	scanf("%d%d%d", &a,&b,&h);
	//for(int i = 1; i<=N; i++){
	//a+=i*double(10000)/N;	
	//}
	printf("%d\n", (a+b)*h/2);
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

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

    int ans = 1;
    char a = s[0];

    for (int i = 1; i < n; i++) {
        if(s[i] != a) {
            ans++;
            a = s[i];
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
bool arr[100100];
int Nmax=100100;
void Eratosthenes(){
	for(int i = 0; i < Nmax; i++){
		arr[i] = true;
	}
	arr[0]=false; arr[1]=false;
	for(int i = 2; i < sqrt(Nmax); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < Nmax; j++){
				arr[i *(j + 2)] = false;
			}
		}
	}
}
int main(){
	Eratosthenes();
	int X;
	scan(X);
	for(int i=X;;i++){
		if(arr[i]){
			prin(i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  ll H, W;
  cin >> H >> W;

  ll ans;
  if (H == 1 || W == 1) {
    ans = 1;
  } else {
    ll m = H*W;
    if (m % 2 == 0) ans = m/2;
    else ans = m/2+1;
  }
  cout << ans << endl;
  return 0;
}


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

#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define mp make_pair
#define ll long long int

int main()
{
	fastIO;
	
	string s;
	int k,i;
	cin>>s>>k;
	for(i=0;i<s.length();i++)
	{
		int x=s[i]-'0';
		if(x!=1)
		{
			cout<<x;
			return 0;
		}
		k--;
		if(k==0)
		{
			cout<<x;
			return 0;
		}
	}

	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = K; i < N; i++) {
    if (A[i - K] < A[i]) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 3988
from collections import Counter
N = int(input())
MAXBIT = 60
MOD = 10 ** 9 + 7
A = list(map(int, input().split()))
B = []
C = [[] for _ in range(MAXBIT)]
for a in A:
    for d in range(MAXBIT):
        C[d].append(a >> d & 1)
ans = 0
for d in range(MAXBIT):
    num0 = C[d].count(0)
    num1 = N - num0
    ans += ((num0 * num1) % MOD) * pow(2, d, MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 318136
import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string s_) {
    auto NT = s_.split.map!(to!int)();
    immutable N=NT[0], T=NT[1];
    auto A = readln.split.map!(to!int).array();
    int m=0,d=0,nl=0, nr=0, n=0, nm=0;
    foreach_reverse(v;A) {
        if(v>m) m=v,++n,nm=1;
        else if(v==m) ++n,++nm;
        else if(m-v>d) d=m-v,nl=1,nr=nm,n=nm;
        else if(m-v==d) ++nl,nr=n;
    }
    return min(nl,nr);

}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }

Measured memory_bytes: 3380
function Main(input) {

	input = input.split("\n");
    
    let S = input[0];
    let T = input[1];
    
    let cnt = Infinity;
    
    for (let i = 0; i <= S.length - T.length; i++) {
        
        let str = S.substr(i, T.length);
        
        let diff = checkDiff(str, T);
        
        if (diff < cnt) cnt = diff;
        
    }
    
    console.log(cnt);
    
}

function checkDiff(str1, str2){
    
    if (str1.length != str2.length) return;
    
    let cnt = 0;
    
    for (let i = 0; i < str1.length; i++) {
        
        if (str1[i] != str2[i]) cnt++;
        
    }
    
    return cnt;
    
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32256
#include <iostream>
#include <map>
#include <queue>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    string sa, sb, sc;
    cin >> sa >> sb >> sc;

    map<char, queue<char>> s;
    REP(i, sa.size()) s['a'].push(sa[i]);
    REP(i, sb.size()) s['b'].push(sb[i]);
    REP(i, sc.size()) s['c'].push(sc[i]);

    char next = 'a', prev = 'a';
    while (true) {
        if (s[next].size() == 0) {
            cout << (char)toupper(next) << '\n';
            return 0;
        }
        prev = next;
        next = s[next].front();
        s[prev].pop();
    }
    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#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, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    REP(i, 3){
        if(s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){

  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  if((a<c&&c<b)||(b<c&&c<a)){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<fstream>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
#define pb push_back
#define MP make_pair

using namespace std;

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



return 0;
}

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

ll dp[(1<<13)];

int main(void){
    int n,m;
    cin >> n >> m;
    
    ll a[m],b[m];
    int c[m][n];
    
    for(int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
        for(int j = 0;j < b[i];j++){
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    
    for(int i = 0;i <= (1<<n);i++){
        dp[i] = 1e10;
    }
    
    dp[0] = 0;
    for(int bit = 0;bit <= (1 << n);bit++){
        for(int i = 0;i < m;i++){
            int bit2 = 0;
            for(int j = 0;j < b[i];j++){
                bit2 |= (1 << c[i][j]);
            }
            dp[bit | bit2] = min(dp[bit | bit2],dp[bit] + a[i]);
        }
    }
    if(dp[(1<<n)-1] == 1e10)dp[(1<<n)-1] = -1;
    cout << dp[(1<<n)-1] << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	int mod = A%B;
	int mod2=A*2%B;
	int i = 2;
	while (mod2 != mod) {
		mod2 = A*i % B;
		if (mod2 == C) {
			cout << "YES" << endl;
			return 0;
		}
		i++;
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))
res = []
for i in range(N):
    if b[i] > i + 1:
        print(-1)
        exit()
for i in range(N):
    res.insert(b[i] - 1, b[i])
for i in range(N):
    print(res[i])

Measured memory_bytes: 38384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

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

    static class RemainderMinimization2019 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            HashSet<Long> set = new HashSet<>();
            long l = in.nextLong();
            long r = in.nextLong();
            long[] mods = new long[2019];

            for (long i = l; i <= r; i++) {
                mods[(int) (i % 2019)]++;
                if (mods[0] > 1) {
                    out.println(0);
                    return;
                }
            }

            long result = Long.MAX_VALUE;
            for (int i = 0; i < 2019; i++) {
                if (mods[i] < 1) {
                    continue;
                }
                for (int j = 0; j < 2019; j++) {
                    if (mods[j] < 1) {
                        continue;
                    }

                    if (i == j && mods[j] < 2) {
                        continue;
                    }
                    result = Math.min(result, (i * j) % 2019);
                }
            }

            out.println(result);
        }

    }
}



Measured memory_bytes: 36296
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int64_t n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  int64_t m;
  m = min(a, b);
  m = min(m, c);
  m = min(m, d);
  m = min(m, e);
  m = (m+n-1)/m;
  cout << m+4 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	int n, cou = 0;
	cin >> n;
	vector<int> h(n);
	vector<int> k;

	FOR(n)
		cin >> h[i];
	FOR(n-1) {
		if (h[i] >= h[i + 1])
			cou++;
		else {
			k.PB(cou);
			cou = 0;
		}
	}
	k.PB(cou);
	int max = k[0];
	FOR(k.size())
		if (k[i] > max)	max = k[i];
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define int long long
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
char c[110];
int a[110],w[5],sum[110],ans=0;
inline void check(){
	if(m==1){
		if(w[1]!=1)ans+=9;
		else ans+=a[1];
		return;
	}
	if(m==2){
		if(w[1]==1){
			if(sum[w[2]-1]-sum[w[1]]==0){
				ans+=(a[1]-1)*9+a[w[2]];
			}
			else ans+=a[1]*9;
		}
		else ans+=81;
		return;
	}
	if(m==3){
		if(w[1]==1){
			int now=0;
			ans+=(a[1]-1)*9*9;
			for(register int i=1;i<=9;i++){	
				if(sum[w[2]-1]-sum[w[1]]==0 && i>a[w[2]])continue;
				for(register int j=1;j<=9;j++){
					if(sum[w[2]-1]-sum[w[1]]==0 && sum[w[3]-1]-sum[w[2]]==0 && i==a[w[2]] && j>a[w[3]])continue;
					ans++;
				}
			}
		}
		else ans+=9*9*9;
	}
	return;
}

inline void dfs(int x,int now){
	if(x==m+1){check();return;}
	for(register int i=now;i<=n;i++){
		w[x]=i;
		dfs(x+1,i+1);
		w[x]=0;
	}
	return;
}
signed main(){
	scanf("%s",c+1);n=strlen(c+1);
	m=read();
	for(register int i=1;i<=n;i++){
		a[i]=c[i]-'0';
		sum[i]=sum[i-1]+a[i];
	}
	dfs(1,1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX_V 100001
#define MOD 1000000007
typedef vector<vector<int> > Graph;
const int MAX=10000;
ll fac[MAX],finv[MAX],inv[MAX];

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

long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    COMinit();
    ll n,k;cin>>n>>k;
    for(int i=1;i<k+1;i++){
        ll a=COM(n-k+1,i);
        ll b=COM(k-1,i-1);
        ll ans=a*b;
        cout<<ans%MOD<<endl;
    }
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli dp[2][26];

void func(long long N, std::string S){

    dp[0][S.at(0)-'a']++;

    REP(i,1,S.size()){
        dp[1][S.at(i)-'a']++;
    }

    lli cnt=0;
    REP(i,0,26){
        if(dp[0][i] > 0 && dp[1][i]>0)cnt++;
    }

    lli ans = cnt;

    REP(i,1,S.size()){
        dp[0][S.at(i)-'a']++;
        dp[1][S.at(i)-'a']--;

        lli cnt2=0;
        REP(j,0,26){
            if(dp[0][j]>0 && dp[1][j]>0)cnt2++;
        }

        chmax(ans,cnt2);
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    func(N, S);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner;

    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        int a = nextInt();
        int b = nextInt();
        int d = nextInt();
        int r = 0;
        for (int i = a; i <= b; i++) {
            if (i % d == 0) r++;
        }
        System.out.println(r);
    }

    public static void println(Object o) {
        System.out.println(o);
    }

    public static void print(Object o) {
        System.out.print(o);
    }

    public static void printf(String format, Object... o) {
        System.out.printf(format, o);
    }

    public static int nextInt() {
        return Integer.parseInt(scanner.next());
    }

    public static long nextLong() {
        return Long.parseLong(scanner.next());
    }

    public static double nextDouble() {
        return Double.parseDouble(scanner.next());
    }

    public static short nextShort() {
        return Short.parseShort(scanner.next());
    }

    public static float nextFloat() {
        return Float.parseFloat(scanner.next());
    }

    public static void printYes() {
        System.out.println("Yes");
    }

    public static void printYES() {
        System.out.println("YES");
    }

    public static void printNo() {
        System.out.println("No");
    }

    public static void printNO() {
        System.out.println("NO");
    }

    public static String nextLine() {
        return scanner.nextLine();
    }

    public static double distance(double x, double y, double x2, double y2) {
        return Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
    }

    public static int MOD = 1_000_000_007;
    public static int MAX = 100000;
    public static long[] fac = new long[MAX];
    public static long[] finv = new long[MAX];
    public static long[] inv = new long[MAX];

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

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

    public static long factorial(long n) {
        return n <= 0 ? 1 : n * factorial(n - 1);
    }
}

Measured memory_bytes: 29280
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define all(v)          v.begin(), v.end()
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mem(dp,x)       memset(dp,x,sizeof dp);
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int dx[] = { -1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int dx2[] = { -1 , -1 , -1, 0 , 0 , 1 , 1 , 1};
int dy2[] = { -1 , 0 , 1 , -1, 1 , -1, 0, 1};

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
// 1, 1, 2, 5, 14, 42, 132, 429, 1430, CATALAN NUMBER
int32_t main()
{
	g_b();
	int n; cin >> n;
	vi a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(abs(a[i] - a[i - 1]) + dp[i - 1] , abs(a[i] - a[i - 2]) + dp[i - 2] );
	}
	for (auto x  : dp) cerr << x << " ";
	cout << dp[n - 1];
	return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  int64_t ans=0;
  if(K!=0){
  for(int b=K+1;b<=N;++b){
    int d=N-K;
    int q=d/b;
    int r=d%b;
    ans += (b-K)*q+min(r+1,b-K);
  }
  }
  else ans=int64_t(N)*int64_t(N);
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
open System.IO
open System
open System.Linq
open System.Collections.Generic

let sw = new StreamWriter(Console.OpenStandardOutput())
sw.AutoFlush <- false

let _n = stdin.ReadLine() |> int64
let _a = stdin.ReadLine().Split() 

let memoize fn = 
    let cache = new System.Collections.Generic.Dictionary<_,_>()
    (fun x ->
    match cache.TryGetValue x with
    | true, v -> v
    | false, _ -> 
        let v = fn (x)
        cache.Add(x,v)
        v)

/// nC2
let c2 n = n * (n - 1L) / 2L
let memC2 = memoize c2

//let countByA = _a |> Array.countBy id |> Map.ofSeq
//let countByA =  _a |> Array.countBy id |> dict
let countByA =  _a |> Array.countBy id |>fun x -> x.ToDictionary(fst,snd)

// 全部の答えを出して余分な数を引く方針
let ansWhole = 
    countByA
    |> Seq.map (fun x -> memC2 (int64 x.Value))
    |> Seq.sum

let unNeeded aNum = 
    let x = int64 countByA.[aNum]
    // xC2 - (x-1)C2 = x-1
    x-1L

let memUnNeeded = memoize unNeeded
/// それぞれの答え
let ansEach aNum = ansWhole - memUnNeeded aNum |> string

_a
|> Seq.map ansEach
|> Seq.iter stdout.WriteLine

stdout.Flush()
stdout.Close()

Measured memory_bytes: 52676
#include <bits/stdc++.h>
using namespace std;
    int main(void){
        // Your code here!
        string S, T;
            cin >> S >> T;
        int A, B;
            cin >> A >> B;
        string U;
            cin >> U;
        if(U == S){
            cout << A - 1 << " " << B;
        }else{
            cout << A << " " << B - 1;
        }
        
    }


Measured memory_bytes: 256
n=int(input())
a_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a_list[n-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int r;in(r);
  out(r*r);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int N;
    int h, n, w;
    n = -1;
    cin >> N;

    for (h = 1; h <= 3500; ++h) {
        for (w = 1; w <= 3500; ++w) {
            long long a = h * w * (long long)N;
            long long b = 4LL * h * w - (long long)N * (h + w);

            if (b > 0 && a % b == 0) {
                n = a / b;
                break;
            }
        }
        if (n != -1) {
            break;
        }
    }

    cout << h << " " << n << " " << w << endl;
}

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

int N,ans[555][555],t[555][555];

int solve(int p, int q){
	if(p > N || q == 0){
		return 0;
	}
	if(ans[p][q] == -1){
		ans[p][q] = solve(p,q-1) + solve(p+1,q) - solve(p+1,q-1) + t[p][q];
	}
	return ans[p][q];
}

int main(void){
	int M,Q,i,L,R,p,q;
	fill(t[0],t[555],0);
	fill(ans[0],ans[555],-1);
	cin >> N >> M >> Q;
	for(i=0; i<M; ++i){
		cin >> L >> R;
		++t[L][R];
	}
	for(i=0; i<Q; ++i){
		cin >> p >> q;
		cout << (solve(p,q)) << endl;
	}
	return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>

int main()
{
	char arabi[7]={'I','V','X','L','C','D','M'};
	int s[7]={1,5,10,50,100,500,1000};
	char c;
	int sum,h,a,t;
	int i,j,flag;
	sum=t=0;
	h=-1;
	j=0;
	while(scanf("%c",&c)!=EOF){
		if(c=='\n'){
			j=0;
			if(flag==0)
				sum+=t;
			printf("%d\n",sum);
			t=0;
			sum=0;
			continue;
		}
		for(i=0;i<8;i++){
			if(c==arabi[i]){
				if(i>h && j==1){
					a=s[i]-t;
					sum+=a;
					sum-=2*flag;
					t=0;
					h=i;
				}
				else if(h==i && j==1) {
					t+=s[i];
					flag=0;
					h=i;
				}
				else{
					sum+=s[i];
					sum+=t;
					t=0;
					h=i;
					j=1;
					flag=s[i];
				}
				break;
			}
		}
	}
	return 0;
}

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

int main(){
int n,a;
int pri[99999];
pri[0]=2;
int ans=1;
while(cin>>n){
ans=1;
for(int i=3;i<n+1;i++){
pri[ans]=i;
for(int j=0;j<ans&&pri[j]*pri[j]<i+1;j++){
a=i%pri[j];
if(a==0){
ans--;
break;}
}
ans++;
}
if(n==1){ans=0;}
cout<<ans<<endl;}}

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

int main() {
    int N;
    cin >> N;
    if(N % 2 == 0) {
        cout << N / 2 << endl;
        return 0;
    }
    cout << N / 2 + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  ll h, w, n;
  cin >> h >> w >> n;
  map<pii, ll> count;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    for (int dy = -2; dy <= 0; ++dy) {
      for (int dx = -2; dx <= 0; ++dx) {
	int y = a + dy;
	int x = b + dx;
	count[pii(y, x)]++;
      }
    }
  }

  vl ans(10, 0);
  for (auto entry : count) {
    if (!in_range(entry.first.first, 1, h-1) or
	!in_range(entry.first.second, 1, w-1)) {
      continue;
    }
    ans[entry.second]++;
  }
  ans[0] = (h - 2) * (w - 2);
  for (int i = 1; i <= 9; ++i) {
    ans[0] -= ans[i];
  }
  for (int i = 0; i <= 9; ++i) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 56576
a = int(input())                                                        
b = int(input())                                                        
c = int(input())                                                        
d = int(input())                                                        
e = int(input())                                                        
k = int(input())                                                        
                                                                        
ok = "Yay!"                                                             
ng = ":("                                                               
                                                                        
dots = [a, b, c, d, e]                                                  
                                                                        
for i, p in enumerate(dots):                                            
    for q in dots[i:]:                                                  
        d = q-p                                                         
        if d <= k:                                                      
            None                                                        
        else:                                                           
            print(ng)                                                   
            exit()                                                      
                                                                        
print(ok) 

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

int main() {
    long long n,k;cin>>n>>k;
    long long ans=0;
    const int MOD=1000000007;

    for(long long i=k;i<=n+1;i++){
        long long low=(i+1)*i/2;
        long long tmp=n-i+1;
        long long high=(n+2)*(n+1)/2 -(tmp+1)*tmp/2;
        ans+=high-low+1;
        ans%=MOD;
        //cout<<high-low+1<<endl;
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 3600
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] p = new int[n];
        for(int i = 0;i<n;i++){
            p[i] = Integer.parseInt(sc.next());
        }
        int[] p2 = p.clone();
        Arrays.sort(p2);
        int tmp = 0;
        boolean flag = true;
        for(int i = 0;i<n;i++){
            if(p[i] != p2[i]){
                if(tmp == 0){
                    tmp = p[i];
                }else{
                    if(tmp != p2[i]){
                        flag = false;
                    }
                }
            }
        }
        if(flag == true){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define pb push_back
//#define int long long
using namespace std;
//const int inf = 1e18 + 7;
const int N = 1e5 + 1;
const int md = 1e9 + 7;
//dist[0] - takahashi, dist[1] - aoki
std::vector<vector<int>> dist(2, vector<int>(N, 0));
vector<int> g[N];
void dfs(int from, int l, int par, int q) {
  dist[q][from] = l;
  for(int to : g[from]) {
    if(to == par) 
      continue;
    dfs(to, l + 1, from, q);
  }
}
void sol() {
  int n, T, A, u, v;
  int ans = 0;
  cin >> n >> T >> A;
  for(int i=0; i<n-1; i++) {
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);  
  }
  dfs(T, 0, T, 0);
  dfs(A, 0, A, 1);
  for(int i=1; i<=n; i++) {
    if(dist[0][i] < dist[1][i]) {
      ans = max(ans, dist[1][i]);
    }
  }
  ans--;
  cout << ans;
}

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


Measured memory_bytes: 11640
#include<stdio.h>
#include<iostream>

using namespace std;

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}


int main(){
    int n,cnt=0;
    cin>>n;

    for(int i=1;i<=n;i++){
        if(keta(i)%2==1){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

using ll = long long int;

int x;

int main(void) {
    // Here your code !
    scanf("%lld", &x);

    ll acc = 0;

    int i = 0;
    while (true) {
      acc += i;
      if (acc >= x) break;
      i += 1;
    }

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

    return 0;
}


Measured memory_bytes: 256
n = int(input())
l = [0] * n
for i in range(n):
    l[i] = input().split()
#l.sort(key=lambda x: x[0]
s = sorted(list(set([l[i][0] for i in range(n)])))
for q in s:
    p = sorted([int(l[i][1]) for i in range(n) if l[i][0] == q], reverse=1)
    for pp in p:
        ans = l.index([q,str(pp)]) + 1
        print(ans)


Measured memory_bytes: 3064