akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N,H,W = map(int,readline().split())
RCA = [tuple(int(x) for x in line.split()) for line in readlines()]

RCA.sort(key = lambda x: -x[2])

RCA

root = list(range(H+W))
size = [0] * (H+W)
no_cycle = [True] * (H+W)

def find_root(x):
    y = root[x]
    if x == y:
        return y
    z = find_root(y)
    root[x] = z
    return z

def merge(x,y):
    x,y = find_root(x),find_root(y)
    sx,sy = size[x],size[y]
    if sx < sy:
        sx,sy = sy,sx
        x,y = y,x
    root[y] = x
    no_cycle[x] = no_cycle[x] and no_cycle[y]

answer = 0
for R,C,A in RCA:
    x,y = R-1,H+C-1
    rx,ry = find_root(x),find_root(y)
    if rx == ry:
        if not no_cycle[rx]:
            continue
        no_cycle[rx] = False
    else:
        if (not no_cycle[rx]) and (not no_cycle[ry]):
            continue
        merge(rx,ry)
    answer += A

print(answer)



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

int gcd(int x,int y){
    int amari;
    while(x % y !=0){
        amari = x%y;
        x = y;
        y = amari;
    }
    return y;
}

int gcd(int a,int b, int c){
    return gcd(a,gcd(c,b));
}

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int k;
    ll ans=0;
    cin >> k;
    rep(a,k){
        rep(b,k){
            rep(c,k){
                ans += gcd(a+1,b+1,c+1);
            }
        }
    }

    cout << ans <<  endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

string conv(int x) {
    return to_string(x);
}

int main(){
    int n;
    cin >> n;
    int ans = 1e9;
    REP(a, 1, n) {
        int b = n - a;
        int tmp = 0;
        auto s = conv(a), t = conv(b);
        rep(i, s.size()) tmp += s[i]-'0';
        rep(i, t.size()) tmp += t[i]-'0';
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if (A + B == 15) {
			System.out.println("+");
		} else if (A * B == 15) {
			System.out.println("*");
		} else {
			System.out.println("x");
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    if((a.at(0)==a.at(1)&&a.at(1)==a.at(2))||(a.at(1)==a.at(2)&&a.at(2)==a.at(3))){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    a,b = map(str, input().split())
    
    if a == "H":
        if b == "H":
            print("H")
        else:
            print("D")
    else:
        if b == "H":
            print("D")
        else:
            print("H")
    
    
if __name__ == "__main__":
	main()


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1 != m2) << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

int main(){
  int N,i;
  int dan=0;
  int mochi_tmp = 0;
  cin >> N;
  vector<int> mochi(N);

  for(i=0 ; i<N ; i++ ){
    cin >> mochi.at(i);  
  }
  sort(mochi.begin(), mochi.end() );

  for(i=0 ; i<N ; i++ ){
     
     if( mochi_tmp < mochi.at(i)){
       dan++;
     }
     mochi_tmp = mochi.at(i);
  }
  cout << dan << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

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

    int a,b; cin>>a>>b;
    if(a<=9 and b<=9){
        cout<<a*b<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		s     string
		count int
	)

	fmt.Scan(&s)
	for i := 0; i < len(s); i++ {
		if s[i] == '1' {
			count++
		}
	}
	fmt.Println(count)

}


Measured memory_bytes: 512
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, C = mapint()
xv = [list(mapint()) for _ in range(N)]
righthand = [0]*N
lefthand = [0]*N
nowv = 0
maxv = -10**18
for i, (x, v) in enumerate(xv):
    nowv += v
    maxv = max(maxv, nowv-x)
    righthand[i] = maxv
nowv = 0
maxv = -10**18
for i, (x, v) in enumerate(xv[::-1]):
    nowv += v
    maxv = max(maxv, nowv-(C-x))
    lefthand[i] = maxv
 
xv = [(0, 0)] + xv +[(C, 0)]
righthand = [0]+righthand
lefthand = [0]+lefthand
rmax = 0
for i in range(N+1):
    rmax = max(rmax, righthand[i]-xv[i][0]+lefthand[N-i])
lmax = 0
for i in range(N):
    lmax = max(lmax, lefthand[i]-(C-xv[-i-1][0])+righthand[N-i])
print(max(rmax, lmax))

Measured memory_bytes: 94928
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

int n;
set<int> dict;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (dict.find(a) == dict.end()) dict.insert(a);
		else dict.erase(a);
	}
	cout << dict.size() << endl;
	return 0;
}

Measured memory_bytes: 4992
n=int(input())
X=[]
U=[]
ans=0
for i in range(n):
    x,u=input().split()
    x=float(x)
    X.append(x)
    U.append(u)

for i in range(n):
    if U[i]=='JPY':
        ans += X[i]
    else:
        ans += X[i]*380000
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

    template <class T, class... Args>
    void impl(T&& v, Args&&... args)
    {
        cout << std::forward<T>(v) << ' ';
        impl(std::forward<Args>(args)...);
    }
    template <class T>
    void impl(T&& v)
    {
        cout << std::forward<T>(v);
    }

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class... Args>
    void operator()(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
        cout << '\n';
    }
    template <class... Args>
    void noreturn(Args&&... args)
    {
        impl(std::forward<Args>(args)...);
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
            }
            cout << x;
            first = false;
        }
        cout << '\n';
    }
};

void prog()
{
    input in;
    output out;

    int h, n;
    in >> h, n;
    auto a = in.read<int>(n);
    out(h <= std::accumulate(std::begin(a), std::end(a), 0) ? "Yes" : "No");
}

int main()
{
    prog();
    return 0;
}


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

int main() {
  int n, k, s;
  cin >> n >> k >> s;

  vector<int> a(n);
  for(int i=0;i<n;i++) {
    if(i<=k-1) a[i] = s;
    else {
      if(s == (int)pow(10, 9)) a[i] = (int)pow(10, 9) - 1;
      else a[i] = (int)pow(10, 9);
    }
  }

  for(int i=0;i<n;i++) cout << a[i] << " ";
  cout << endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)n;(i)++)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

int W, N, v[1002], w[1002];
int dp[1002][1002];

int main() {
  int i, j, cases = 1, ans;
  char c;
  while (scanf("%d",&W),W) {
    scanf("%d",&N);
    rep(i,N) scanf("%d%c%d",&v[i],&c,&w[i]);
    memset(dp, -1, sizeof dp);

    for (i=0;i<=W;i++) dp[0][i] = 0;

    for (i=0;i<N;i++) {
      for (j=0;j<=W;j++) {
        if (j >= w[i]) {
          dp[i+1][j] = max(dp[i][j], v[i]+dp[i][j-w[i]]);
        } else {
          dp[i+1][j] = dp[i][j];
        }
      }
    }
    
    ans = W;
    for (i=0;i<=W;i++) if (dp[N][W] == dp[N][i]) {
      ans = i; break;
    }
    
    printf("Case %d:\n%d\n%d\n", cases, dp[N][ans], ans);
    cases++;
  }
  return 0;
}

Measured memory_bytes: 0
/*
      author : nishi5451
      created: 11.08.2020 20:17:43
*/

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


int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(auto a : s){
        if(a == 'o') ans++;
    }
    cout << 700+ans*100 << endl;
    return 0;
}

Measured memory_bytes: 3632
(a, b, k) = gets.chomp.split(' ').map(&:to_i)

k.times do |i|
  if i % 2 == 0 then
    if a % 2 == 1 then
      a -= 1
    end
    
      c = a / 2
      a -= c
      b += c
  else
    if b % 2 == 1 then
      b -= 1
    end
    
      c = b / 2
      a += c
      b -= c
  end
end
    
puts [a, b].map(&:to_s).join(' ')

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
vector<int> dx= {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
const int INF=100000000;

int main(){
    int n, k;
    cin>>n>>k;
    double ans =0.0;
    for(int i =1 ; i<= n ; i++){
        double b = 1.0/n;
        int now = i;
        while(now < k){
            now *= 2;
            b /= 2;
        }
        ans += b;
    }
    cout << fixed << setprecision(12);
    cout<<ans << endl;
}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));

$arr = [];
for ($i = 0; $i < $n; $i++) {
     $arr[$i] = trim(fgets(STDIN));
}

arsort($arr);
$max = [];
$i = 0;
foreach ($arr as $key => $value) {
    if($i === 2) break;
    
    $max[$i]['key'] = $key;
    $max[$i]['value'] = $value;
    $i++;
}

for ($i = 0; $i < $n; $i++) {
    if($i === $max[0]['key']) {
        echo $max[1]['value'] . "\n";
    } else {
        echo $max[0]['value'] . "\n";
    }
}

Measured memory_bytes: 42612
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    n = N//2
    print((N-n)/ N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3932
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i,j;scanf("%d",&n);
  bool B[31] = {},c[31] = {};vector<bitset<31>> a;
  int ans[n] = {};
  for(i=0;i<n;i++){
    scanf("%d",&k);
    a.push_back(bitset<31>(k));
  }
  for(i=1;i<n;i++){
    for(j=0;j<31;j++) B[j] ^= (a[i][j]==a[0][j]);
  }
  for(i=0;i<31;i++){
    ans[0] += (1<<i)*(a[0][i]==B[i]);
    c[i] = a[0][i]==B[i];
  }
  for(i=1;i<n;i++){
    for(j=0;j<31;j++) ans[i] += (1<<j)*(c[j]^(a[i][j]!=a[0][j]));
  }
  for(i=0;i<n;i++) printf("%d ",ans[i]);
  printf("\n");
}

Measured memory_bytes: 6108
#include <iostream>  
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
  
using namespace std;  
const int maxn=2e5+10;  
int par[maxn],sum[maxn]; 

int N,K,p,tot; 
  
void init(int n)  
{  
    for(int i=0;i<=n;i++)  
        par[i]=i;  
}  
  
int find(int x)  
{  
    if(par[x]==x)  
        return x;  
    return par[x]=find(par[x]);  
}  
void unit(int x,int y)  
{  
    int fx=find(x),fy=find(y);  
    if(fx!=fy)  
        par[fx]=fy;  
}  
bool same(int x,int y)  
{  
    return find(x)==find(y);  
}  
int main()  
{  
    while(~scanf("%d%d",&N,&K))  
    {  
        int ans=0;  
        memset(sum,0,sizeof(sum));  
        memset(par,0,sizeof(par));  
        tot=0;  
        init(N);  
        int t;  
        scanf("%d",&t);  
        sum[t]++;  
        p=t;  
        tot++;  
        for(int i=2;i<=N;i++)  
        {  
            scanf("%d",&t);  
            sum[t]++;  
            if(!same(t,p))  
            {  
                tot++;  
                unit(t,p);  
            }  
        }  
        sort(sum,sum+N+1);  
        if(tot<=K)  
            ans=0;  
        else  
        {  
            int cnt=tot-K;  
            int pos=lower_bound(sum,sum+N+1,1)-sum;  
            while(cnt--)  
                ans+=sum[pos++];         
        }  
        printf("%d\n",ans);  
    }  
    return 0;  
}  

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n, x;
  cin >> n >> x;
  vector<int > m(n, 0);
  int mval = 1001;
  REP(i,n){
    cin >> m[i];
    x -= m[i];
    mval = min(mval, m[i]);
  }
  cout << n + x/mval << endl;
}


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

constexpr long long int mod = 1e9 + 7;

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

	long long ans = 1;

	if (n > m) {
		while (1) {
			if (n == 0 || m == 0) break;
			ans = ans % mod * n--;
			ans = ans % mod * m--;
		}
	}
	else {
		while (1) {
			if (n == 0 || m == 0) break;
			ans = ans % mod * m--;
			ans = ans % mod * n--;
		}
	}

	if (n == m) ans = ans % mod * 2;
	else if (n + m > 1) ans = 0;

	cout << ans % mod << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    vector<double>p(N);
    for(auto& e : p) cin >> e;
    vector<vector<double>>dp(N + 1,vector<double>(N + 1, 0.0));
    dp[0][0] = 1.0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j + 1 < dp[i].size(); ++j){
            double fr = p[i];
            double bc = 1.0 - fr;
            dp[i+1][j + 1] += fr * dp[i][j];
            dp[i+1][j] += bc * dp[i][j];
        }
    }
    double ans = 0.0;
    for(int i = (N-1)/2 + 1; i <= N; ++i)
        ans += dp.back()[i];
    
    cout << setprecision(15) << fixed << ans << endl;
}


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

#define MOD 1000000007

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

  int ans;
  if (n < 600) {
    ans = 8;
  } else if (n < 800) {
    ans = 7;
  } else if (n < 1000) {
    ans = 6;
  } else if (n < 1200) {
    ans = 5;
  } else if (n < 1400) {
    ans = 4;
  } else if (n < 1600) {
    ans = 3;
  } else if (n < 1800) {
    ans = 2;
  } else {
    ans = 1;
  }


  cout << ans << endl;
}


Measured memory_bytes: 3616
n = gets.to_i
ss = n.times.map { gets.chomp }

counts = ss.each_with_object(Hash.new(0)) do |s, h|
  h[s] += 1
end

ans = counts.sort_by { |k, v| [-v, k] }
puts ans.select { |k, v| v == ans[0][1] }.map(&:first)


Measured memory_bytes: 56612
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define maxv 1e5+1
#define inf 4e18
using namespace std;
int main()
{
    ll n,W;
    cin>>n>>W;
    ll val[n+1],wt[n+1];
    vector<vector<ll>>knap(n+1,vector<ll>(maxv,inf));//2d vector with n+1 r and maxv col with value =inf
    //here the answer i.e maxvalue cant be >10^5
    for(ll i=0;i<n;i++)
        cin>>wt[i]>>val[i];
  knap[0][0]=0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<maxv;j++)
        {
            if (j<val[i-1])
                knap[i][j]=knap[i-1][j];
            else
                knap[i][j]=min(knap[i-1][j-val[i-1]] + wt[i-1],knap[i-1][j]);
        }
    }
    for(ll i=maxv-1;i>=0;i--)//max value cant be greater than maxv coz vi<=10^3 and n<=100
    {
        if(knap[n][i]<=W)
        {
            cout<<i;//max value
            break;
        }
    }
}


Measured memory_bytes: 80256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<map>
using namespace std;
int n,i,k,x,y;
double a[200005];
int main()
{
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&x);
        a[i]=(x+1)/2.0;
    }
    double cnt=0,sum=0,ans=0;
    for(i=0;i<n;i++)
    {
        if(cnt<k){sum+=a[i];cnt++;}
        else{
            sum=sum+a[i]-a[i-k];
        }
            if(sum>ans)ans=sum;
    }
    printf("%.12lf\n",ans);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A==B && B!=C){
      cout << "Yes" <<endl;
  }else if(A==C && B!=C){
      cout << "Yes" <<endl;
  }else if(B==C && B!=A){
      cout << "Yes" <<endl;
  }else{
      cout << "No" <<endl;
  }

}

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

long long int N, A, a[100001], c, d, i;

int main(){
    scanf("%lld", &N);
    for(; i < N; ++i){
        scanf("%lld", &A);
        if(a[A])c++;
        else{++a[A];d++;}
    }
    cout << d - (c & 1) << endl;
    return 0;
}


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

const int MOD = 1e9+7;

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> a(M);
  for(int i=0; i<M; i++)
    cin >> a.at(i);

  vector<long long int> fibo(N+1);
  fibo.at(0) = 1;
  fibo.at(1) = 1;
  for(int j=2; j<N+1; j++)
    fibo.at(j) = (fibo.at(j-1) + fibo.at(j-2)) % MOD;
  
  if(M==0){
    cout << fibo.at(N) << endl;
    return 0;
  }

  
  long long int sol = fibo.at(a.at(0)-1);
  
  for(int i=1; i<M; i++){
    int dif;
    if(i != 0){
      dif = a.at(i) - a.at(i-1);
      if(dif==1){
      cout << 0 << endl;
      return 0;
      }
    }
    
    sol = sol * fibo.at(dif-2) % MOD;
  }
  
  
  sol = sol * fibo.at(N - a.at(M-1)-1) % MOD;
  cout << sol << endl;
  
}

Measured memory_bytes: 1408
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int R = sc.nextInt();
		R -= N * M;
		if (R < 0) {
			System.out.println(0);
			return;
		}
		BigInteger ans = BigInteger.ONE;
		for (int i = 0; i < N - 1; ++i) {
			ans = ans.multiply(BigInteger.valueOf(R + N - 1 - i)).divide(BigInteger.valueOf(i + 1));
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 55884
#include<cstdio>

int main()
{
	int h, w;
	char mine[51][51];

	scanf("%d %d", &h, &w);
	for(int i = 0; i < h; i++)
		
			scanf("%s", mine[i]);
	
	
	int dir_h[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
	int dir_w[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
	char num[51][51];
	
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			num[i][j] = '0';
		
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			if(mine[i][j] == '#')
				num[i][j] = '#';
			
			else
				for(int k = 0; k < 8; k++)
					if(mine[i + dir_h[k]][j + dir_w[k]] == '#')
						num[i][j]++;
			
	
	
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j ++){
			printf("%c", num[i][j]);
			if(j == w - 1)
				printf("\n");
			}
}
			


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
string S;

int main(void) {

	cin >> S;

	int ans = 0;
	int cur = 0;
	
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'R') { cur++;  ans = max(ans, cur); }
		else { cur = 0; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
N=int(input())
dp=[[0]*3 for i in range(62)]
dp[0][0]=1
for i in range(61):
  if N&(1<<(60-i)):
    dp[i+1][0]=dp[i][0]
    dp[i+1][1]=dp[i][0]+dp[i][1]
    dp[i+1][2]=2*dp[i][1]+3*dp[i][2]
  else:
    dp[i+1][0]=dp[i][0]+dp[i][1]
    dp[i+1][1]=dp[i][1]
    dp[i+1][2]=dp[i][1]+3*dp[i][2]
  for j in range(3):
    dp[i+1][j]%=10**9+7
print(sum(dp[61])%(10**9+7))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;// при желании можно поменять

int main(){
    //ios_base::sync_with_stdio(false);
    //cout<<fixed<<setprecision(20);
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=1;
    if(b-a<2){
        cout<<n+1;
        return 0;
    }
    n-=a-1;
    ans=a;
    ans+=(b-a)*(n/2);
    if(n%2==1)ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
// Problem : E - Knapsack 2
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull ;
typedef long double ld;

inline ll max(ll a,ll b) {return ((a>b)?a:b);}
inline ll min(ll a,ll b) {return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b) {if(b==0) return a; a%=b;return gcd(b,a);}
ll power(ll x, ll y){if(y == 0) return 1; ll a = power(x,y/2);if (y % 2 == 0) return a * a; else return x * a * a; }
ll powermod(ll x, ll ex , ll md) {ll ans = 1ll;while (ex > 0) {if (ex & 1ll) ans = (ans * x) % md; ex >>= 1ll;x = (x * x) % md;}return ans;}

const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const ld PI = acos(-1);
const ld eps = 1e-9;

const ll N = 1e5 + 1;
const ll M = 101;
ll dp[M][N]; // dp[i][j] min wt required to obtain value j till ith item
ll n , m;
ll wt[M];
ll val[M];
void solve(){
	cin >> n >> m;
	rep(i , n) cin >> wt[i + 1] >> val[i + 1];
	rep(i ,M){
		rep(j,N) dp[i][j] = inf;
	}
	dp[0][0] = 0;
	for(ll i = 1  ; i <= n ; i++){
		for(ll j = 0 ; j < N ; j++){
			if(j - val[i] >= 0) dp[i][j] = min(dp[i - 1][j] , dp[i - 1][j - val[i]] + wt[i]);
			else dp[i][j] = dp[i - 1][j];
		}
	} 
	ll ans = -inf;
	for(ll j =0 ;  j < N ; j++) if(dp[n][j] <= m) ans = max(ans , j);
	cout << ans << endl;
}
int main(){
    IOS;
    cout << fixed << setprecision(20);
    ll NTC=1;
    // cin>>NTC;
    ll PTC=0;
    while(PTC++<NTC){
        // cout<<"Case #"<<PTC<<":"<<' ';
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 79232
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
S = lines.shift()
max = 0
cnt = 0
for(i=0;i < S.length; i++) {
    if (/[AGCT]/.test(S[i])) {
       cnt++ 
    } else {
        if (max < cnt) {
            max = cnt
        }
        cnt = 0
    }
}
if (max < cnt) {
    max = cnt
}

console.log(max)

Measured memory_bytes: 7372
lst = []

for i in range(3):
    mini_lst = []
    for x in input():
        if x == "a":
            mini_lst += [0]
        elif x == "b":
            mini_lst += [1]
        elif x == "c":
            mini_lst += [2]
    lst += [mini_lst]

i = 0
while True:
    if len(lst[i]) == 0:
        break
    j = lst[i][0]
    lst[i].pop(0)
    i = j

if i == 0:
    print("A")
elif i == 1:
    print("B")
elif i == 2:
    print("C")


Measured memory_bytes: 3064
local X = io.read("*n")

for i = X, 10^5+3 do
    local Y = math.ceil(math.sqrt(i))
    local Z = true
    for j = 2, Y do
        if i~=j and i%j==0 then
           Z = false
           break
        end
    end
    if Z then
        print(i)
        break
    end
end

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

#define ll long long int
#define pd push_back
#define mp make_pair
#define mod 1000000007
#define MAX 100001
vector<ll> obs[MAX];
ll ans=0;
ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1){ans = (ans*a);}b>>=1;a=a*a;}return ans;}
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
void bfs(vector<ll> &h,vector<ll> &vis,ll u,ll n,ll m){
    list<ll> q; 
    vis[u] = 1; 
    q.push_back(u); 
    while(!q.empty()) 
    { 
        u = q.front(); 
        q.pop_front(); 
        ll fl=0;
        for (ll i = 0; i < obs[u].size(); i++) 
        { 
            if(!vis[obs[u][i]]){
                vis[obs[u][i]]=1;
                q.push_back(obs[u][i]);
            }
            if(h[u] <= h[obs[u][i]]){
                fl=1;
            }
        } 
        if(!fl){
            // cout<<u<<endl;
            ans++;
        }
    } 
}
int main() {
   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
   // cout << fixed << setprecision(10);
   ll n,m,x,y;
   cin>>n>>m;
   vector<ll> height(n+1,0);
   for(ll i=1;i<=n;i++){
       cin>>x;
       height[i]=x;
   }
   for(ll i=0;i<m;i++){
       cin>>x>>y;
       obs[x].push_back(y);
       obs[y].push_back(x);
   }
   vector<ll> vis(n+1,0);
   for(ll i=1;i<=n;i++){
       if(vis[i]==0)
       {
           bfs(height,vis,i,n,m);
       }
   }
   cout<<ans<<endl;
	return 0;
}


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

int A, B;

int main() {
    cin >> A >> B;

    if (A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
sum = 0

a0 = a[0]
a[0]=0
for i in range(len(a)-1):
    a[i+1] = a[i+1] - a0
    if a[i]>a[i+1]:
        sum = sum + a[i] - a[i+1]
        a[i+1] = a[i]

print(sum)

Measured memory_bytes: 32152
N = int(input())
x = []
for i in range(5):
	x.append(int(input()))

a = min(x)
if a >= N:
	print(5)
else:
	if N % a == 0:
		print(int(N // a) + 4)
	else:
		print(int(N // a) + 5)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int x = in.nextInt();
		int t = in.nextInt();
		System.out.println((int)Math.ceil((double)n / (double)x) * t);
		in.close();
	}
}


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

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

    int h, w, k;
    cin >> h >> w >> k;
    vector<string> board(h);
    int sx, sy;
    for (int i = 0; i < h; i++) {
        cin >> board[i];
        for (int j = 0; j < w; j++) {
            if (board[i][j] == 'S') {
                sx = i, sy = j;
            }
        }
    }
    queue<pair<int, int>> que;
    que.emplace(sx, sy);
    vector<vector<int>> dist(h, vector<int>(w, 1e9));
    dist[sx][sy] = 0;
    int dx[] = {-1, 1, 0, 0};
    int dy[] = {0, 0, -1, 1};
    while (!que.empty()) {
        pair<int, int> t = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int x = t.first + dx[i];
            int y = t.second + dy[i];
            if (0 <= x && x < h && 0 <= y && y < w && board[x][y] == '.' && dist[t.first][t.second] + 1 < dist[x][y]) {
                dist[x][y] = dist[t.first][t.second] + 1;
                que.emplace(x, y);
            }
        }
    }

    int ans = 1e9;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (dist[i][j] <= k) {
                ans = min(
                    ans, 1 + min({(i + k - 1) / k, (h - 1 - i + k - 1) / k, (j + k - 1) / k, (w - 1 - j + k - 1) / k}));
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3456
using System;
using System.Linq;
using System.Text;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int q = sc.NextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++)
        {
            sb.AppendLine(Q(sc.NextLong(), sc.NextLong()).ToString());
        }
        Console.Write(sb);
    }

    long Q(long a, long b)
    {
        if (a == b)
        {
            // どちらかの順位が低い人
            // (x+y)(x-y) = x^2-y^2なので 値が小さくなるようにできる
            return (a - 1) * 2;
        }
        if (a > b) return Q(b, a);
        // a < b
        long ab = a * b;

        // 1回目の順位が低い かつ 2回目が高い人
        long aa = (ab - 1) / (b + 1);
        // 2回目が低い人
        // (a+1)*c <= ab-1
        // (a+c)*1 <= ab-1
        // ((a+1+c)/2)^2 <= ab-1
        long sqrt = 0;
        long ng = 1000000000;
        while (ng - sqrt > 1)
        {
            long mid = (sqrt + ng) / 2;
            if (mid * mid <= (ab - 1)) sqrt = mid;
            else ng = mid;
        }
        // Console.WriteLine($"{sqrt}^2<{ab}");
        long bb;
        if (sqrt * (sqrt + 1) <= ab - 1)
        {
            bb = 2 * sqrt - a;
        }
        else
        {
            bb = 2 * sqrt - a - 1;
        }


        return aa + bb;
    }
    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n; cin >> n;
  vector<lint> a(n); for(lint i=0;i<n;i++) { cin >> a[i]; }

  lint cnt=0, abs_min=1000000000, ans=0;
  for(lint i=0;i<n;i++) {
    if(abs(a[i]) < abs_min) { abs_min = abs(a[i]); }
    if(a[i] < 0) { cnt++; }
    ans += abs(a[i]);
  }

  if(cnt%2 != 0) { ans -= 2*abs_min; } 

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

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

int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    if(x - r >= 0 && x + r <= w){
        if(y - r >= 0 && y + r <= h){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		Set<String> set = new HashSet<String>();
		
		for(int i = 0; i < n; i++){
			final String ops = sc.next();
			final String key = sc.next();
		
			if("insert".equals(ops)){
				set.add(key);
			}else{
				System.out.println(set.contains(key) ? "yes" : "no");
			}
			
		}
		
	}
	
	public static class Scanner {
	    private BufferedReader br;
	    private StringTokenizer tok;

	    public Scanner(InputStream is) throws IOException {
	        br = new BufferedReader(new InputStreamReader(is));
	    }

	    private void getLine() throws IOException {
	        while (!hasNext()) { tok = new StringTokenizer(br.readLine()); }
	    }

	    private boolean hasNext() {
	        return tok != null && tok.hasMoreTokens();
	    }

	    public String next() throws IOException {
	        getLine(); return tok.nextToken();
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(next());
	    }
	    
	    public long nextLong() throws IOException {
	    	return Long.parseLong(next());
	    }
	    
	    public void close() throws IOException {
	        br.close();
	    }
	}

}

Measured memory_bytes: 128552
#085-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
import math
n,h=IL()
a=0
B=[0]*n
for i in range(n):
    ta,tb=IL()
    a=max(a,ta)
    B[i]=tb
B.sort()
ans=0
for i in range(n):
    if B[-1-i]>=a and h>0:
        h-=B[-1-i]
        ans+=1
    else:
        break
if h>0:
    ans+=math.ceil(h/a)
print(ans)

Measured memory_bytes: 7472
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  vi a(3);
  rep(i, 3) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[2] - a[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, modinv, bitSearch, bitList, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 1;
vl flag, color; vll path; vl D;
//***********//
int main() {
	ll Q;
	cin >> N >> M >> Q;
	vll A(N, vl(N, 0));
	for (i = 0; i < M; i++) {
		ll l, r;
		cin >> l >> r;
		l--; r--;
		A[l][r]++;
	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < N-1; j++) {
			A[i][j+1] += A[i][j];
		}
	}
	for (i = N-2; i >= 0; i--) {
		for (j = 0; j < N; j++) {
			A[i][j] += A[i+1][j];
		}
	}
	for (i = 0; i < Q; i++) {
		ll p, q;
		cin >> p >> q;
		p--; q--;
		cout << A[p][q] << endl;
	}
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector <int> ans(n + 1, 0);
  REP(i, n - 1) {
	int a;
	cin >> a;
	ans[a]++;
  }
  REP1(i, n) {
	cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;2*i<s.size();i++){
    if(s.substr(0,i)==s.substr(i,i)){ans=max(ans,i);}
  }
  cout<<2*ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int MAX=1e5+10;
const ll INF=1e18;
const double PI=acos(-1);


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

    int n;
    cin >> n;
    vector<int> cnt(100010);
    rep(i,n) {
        int a;
        cin >> a;
        ++cnt[a];
    }
    int ans=0,s=cnt[0]+cnt[1];
    repr(i,2,100010) {
        s+=cnt[i];
        ans=max(ans,s);
        s-=cnt[i-2];
    }
    cout << ans << endl;

    return 0;   
}

Measured memory_bytes: 3764
X, N = map(int,input().split())
P = list(map(int, input().split()))
forbid = set(P)

l, r = X, X
ans = float("inf")
while True:
    if l not in forbid:
        ans = l
        break
    if r not in forbid:
        ans = r
        break
    l -= 1
    r += 1

print(ans)


Measured memory_bytes: 61832
#include <algorithm>
#include <iostream>
#include <vector>
#include <functional>

using namespace std;


int main()
{

string N;
cin>>N;

if(N=="A")cout<<"T"<<endl;
if(N=="T")cout<<"A"<<endl;
if(N=="C")cout<<"G"<<endl;
if(N=="G")cout<<"C"<<endl;



return 0;
}

Measured memory_bytes: 256
def prime_factorize(n):
    dic = {}
    while n % 2 == 0:
        if 2 in dic:
            dic[2] += 1
        else:
            dic[2] = 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            if f in dic:
                dic[f] += 1
            else:
                dic[f] = 1
            n //= f
        else:
            f += 2
    if n != 1:
        if n in dic:
            dic[n] += 1
        else:
            dic[n] = 1
    return dic

n = int(input())

dic = {}
for i in range(1, n+1):
    dici = prime_factorize(i)
    for key in dici:
        if key in dic:
            dic[key] += dici[key]
        else:
            dic[key] = dici[key]

num74 = 0
num24 = 0
num2 = 0
num4 = 0
num14 = 0
for key, value in dic.items():
    if value >= 74:
        num74 += 1
    if value >= 24:
        num24 += 1
    if value >= 2:
        num2 += 1
    if value >= 4:
        num4 += 1
    if value >= 14:
        num14 += 1
    
ans = num74 + num24*(num2-1) + (num4-1)*num14 + (num2-2)*(num4*(num4-1)//2)
print(ans)

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

int main() {

  char input1,c,input2;

  char ans = 'A';

  while( cin >> input1 >> c >> input2 ) {
    if ( ans == input1 ) {
      ans = input2;
    }else if ( ans == input2 ) {
      ans = input1;
    }
  }

  cout << ans << endl;

  return 0;

}

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

using namespace std;

const int N_MAX = 200002;

const int MOD = 998244353;

int pwr (int a, int b)
{
    if(b == 0)
        return 1;
    if(b & 1)
        return 1LL * a * pwr(a, (b ^ 1)) % MOD;
    int aux = pwr(a, (b >> 1));
    return 1LL * aux * aux % MOD;
}

int n, m, k;

int fact[N_MAX], ifact[N_MAX];

int comb (int a, int b)
{
    return 1LL * fact[a] * ifact[b] % MOD * ifact[a - b] % MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    fact[0] = ifact[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        fact[i] = 1LL * fact[i - 1] * i % MOD;
        ifact[i] = pwr(fact[i], MOD - 2);
    }
    int sum = 0;
    for(int i = 0; i <= k; i++)
    {
        sum += 1LL * comb(n - 1, i) * m % MOD * pwr(m - 1, n - i - 1) % MOD;
        if(sum >= MOD)
            sum -= MOD;
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 5252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll maxk = 1e9+7;
#define MAX_N 100005
int A[MAX_N];
int block[MAX_N];
int main()
{
	long long n;
	cin>>n;
	int m;
	cin>>m;
	for(int i=0;i<m;i++)
	{
		int a;
		cin>>a;
		block[a] = 1;
	}
	A[0] = 1;
	for( int i=1; i<=n; i++ )
	{
		//if( !block[i] )
		{
			if( !block[i-1] )
			{
				A[i] += A[i-1];
			}
			if( i>1 && !block[i-2] )
			{
				A[i] += A[i-2];
			}
			A[i] %= maxk;
		}
	}
	cout << A[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    vector <int> a(n);
    int p = 0, ans = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        int x = min(p, a[i]);
        ans += x;
        a[i] -= x;
        ans += a[i] / 2;
        p = a[i] & 1;
    }   
    cout << ans << endl;    
}

Measured memory_bytes: 1024