akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
sc.nextInt();
int m = sc.nextInt();
int x = sc.nextInt();
int leftFeeAreaCnt = 0;
int rightFeeAreaCnt = 0;
for (int i = 0; i < m; i++) {
int feeArea = sc.nextInt();
if (feeArea < x) {
leftFeeAreaCnt++;
} else if (x < feeArea) {
rightFeeAreaCnt++;
}
}
if (leftFeeAreaCnt <= rightFeeAreaCnt) {
System.out.println(leftFeeAreaCnt);
} else {
System.out.println(rightFeeAreaCnt);
}
}
}

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

int f(int x, int y, int z) {
  int n = x*x + y*y + z*z + x*y + y*z + z*x;
  return n;
}

int main() {
  int N;
  cin >> N;
  map<int,int> m;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j < N; j++) {
      for (int k = 1; k < N; k++) {
        int n = f(i,j,k);
        if (n > N) break;
        m[n]++;
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    cout << m[i] << endl;
  }
}


Measured memory_bytes: 3968
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

main:-
    get_number(S),
    get_number(W),
    (W >= S) -> writeln("unsafe") ; writeln("safe").


Measured memory_bytes: 8044
#include<iostream>

using namespace std;

int main(){
   string s;

   cin >> s;
   int n = 15;
   int win = 0;
   for(char c:s){
      if(c == 'o'){
         win ++;
      }
      n--;
   }

   cout << (win + n >= 8 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var n,i int
  var u string
  var x,s float64
  fmt.Scan(&n)
  s = 0
  for i=0;i<n;i++ {
    fmt.Scan(&x,&u)
    if u == "JPY" {
      s += x
    } else {
      s += 380000.0*x
    }
  }
  fmt.Println(s)
}

Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}

		for(int i = 0; i < n; i++) {
			double[] angle = new double[n];
			int p = 0;
			for(int j = 0; j < n; j++) {
				if(j != i) {
					angle[p++] = Math.atan2(y[j] - y[i], x[j] - x[i]);
				}
			}
			Arrays.sort(angle, 0, p);
			angle[p++] = angle[0] + 2 * Math.PI;
			double max = 0;
			for(int j = 0; j + 1 < angle.length; j++) {
				max = Math.max(max, angle[j+1] - angle[j]);
			}
			max = Math.max(max - Math.PI, 0.0);
			System.out.printf("%.15f\n", max / (2 * Math.PI));
		}
	}
}

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

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	int a[3]={A,B,C};;
	int rec1=0;
	int rec2=0;
	for(int i=0;i<3;i++){
		if(a[i]==5){
			rec1++;
		}
		if(a[i]==7){
			rec2++;
		}
	}
	if(rec1==2 && rec2==1){
		cout << "YES";
	}
	else{
		cout << "NO";
	}
} 

Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()

    d = {}
    m = M
    for i in range(2,int(math.sqrt(M))+1):
        while m % i == 0:
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
            m //= i
    if m > 1:
        d[m] = 1

    a = [1]
    b = [1]
    c = 1
    for i in range(1,N+int(math.log(M,2)) +1):
        c = (c * i) % MOD
        a.append(c)
        b.append(pow(c,MOD-2,MOD))

    ans = 1
    for v in d.values():
        ans = (ans * a[N+v-1] * b[v]* b[N-1]) % MOD
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 51692
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 

int main() 
{
    fastio
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto& it : a) cin>>it;

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

    for(int i = 1; i<=n; ++i) {
        cout<<ans[i]<<endl;
    }
}   

Measured memory_bytes: 4784
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
class UnionFind {
private:
    int sz;
    vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};

int main(){
    int n;
    cin >> n;
    UnionFind uf(n);
    vector<pair<pair<int,int>,int> > a;
    vector<int> h(n);
    vector<int> id(n);
    priority_queue<pair<int,int> > pq;

    rep(i,n){
        int x,y;
        cin >> x >> y;
        x--;y--;
        h[x] = y;
        id[x] = i;
        pq.push(MP(y,x));
    } 
    int mi = n+1;
    int lo = -1;
    while(!pq.empty()){
        auto s = pq.top();
        pq.pop();
        int val = s.first;
        int x = s.second;
        if(chmin(mi,val)){
            for(int i=x;i>lo;i--){
                chmin(mi,h[i]);
                if(i!=lo+1)uf.unite(i,i-1);
            }
            chmax(lo,x);
        }else{
            for(int i=x;i>lo;i--){
                chmin(mi,h[i]);
                uf.unite(i,i-1);    
            }
            chmax(lo,x);
        }
    }
    vector<int> res(n);
    rep(i,n){
        res[id[i]] = uf.size(i);
    }
    rep(i,n){
        cout << res[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 8752
#include<bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
#define task "tet"
using namespace std;
const ll N = 2e5 + 9;
const ll inf = 1e9 + 7;
typedef pair<ll,ll> LL;
vector<ll> g[N];
ll n,m,x,y,d[N],i,trace[N];
bool vis[N];
queue<ll> q;
bool chk(){
    for (i = 2;i <= n;i++) if (d[i] == inf) return false;
    return true;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    cin>>n>>m;
    while(m--){
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    fill(d + 1,d + n + 1,inf); d[1] = 0;
    q.push(1);
    while(!q.empty()){
        ll t = q.front(); q.pop();
        for (auto i : g[t]){
            if (d[i] > d[t] + 1){
                d[i] = d[t] + 1;
                trace[i] = t;
            }
            if (!vis[i]){
                vis[i] = true;
                q.push(i);
            }
        }
    }
    if (chk()){
        cout<<"Yes\n";
        for (i = 2;i <= n;i++) cout<<trace[i]<<"\n";
    }
    else cout<<"No";
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans = 0;
    rep(i, S.length()) {
        ans += S[i] - '0';
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <string>
#include <set>
#include <iostream>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int cnt[2][30];
	for (int i = 0; i < 30; i++)cnt[0][i] = cnt[1][i] = 0;
	for (auto e : s) cnt[0][e - 'a']++;
	for (auto e : t) cnt[1][e - 'a']++;
	multiset<int> c[2];
	for (int i = 0; i < 2; i++)for (auto e : cnt[i])c[i].insert(e);
	if (c[0] == c[1]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<ll,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    map<ll,int> m;
    rep(i,n) {
        ll a;
        cin >> a;
        m[a]++;
    }
    vector<ll> edge;
    for(P p : m) {
        ll pf = p.first;
        int ps = p.second;
        if(ps < 2) continue;
        edge.pb(pf);
        if(ps >= 4) edge.pb(pf);
    }
    sort(all(edge));
    if(edge.size() < 2) cout << 0 << endl;
    else cout << edge[edge.size()-1]*edge[edge.size()-2] << endl;
}

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

int main()
{
    string s;
    cin >> s;
    int N = s.size();
    rep(i, N)
    {
        if (i % 2 == 0)
        {
            cout << s[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n = int(input())

graph = [[] for _ in range(n)]
for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    graph[u].append((v, w%2))
    graph[v].append((u, w%2))

memo = [-1] * n

def dfs(v, memo, color):
    memo[v] = color
    for (nv, dist) in graph[v]:
        if memo[nv] != -1:
            continue
        if dist == 0:
            dfs(nv, memo, color)
        else:
            dfs(nv, memo, (color + 1)%2)

dfs(0, memo, 0)

for i in memo:
    print(i)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;


int main() {
  string s;
  cin>>s;
  int n=3,c=0;
  while(n--){
    if(s[n]=='A') ++c;
  }

  if(c==0 || c==3){
    cout<<"No"<<endl;
  } else {
    cout<<"Yes"<<endl;
  }
  

  return 0;
}


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

int tsum(int i){
  int total;
  total = 0;
  while(i>0)total+=i%10,i /=10;
  return total;
}


int main(){
  int N, A, B,total;
  cin >> N >> A >> B;
  total = 0;
  int res;
  for(int i = 1;i<=N;i++){
    res=tsum(i);
    if(A<=res&&res<=B)total+=i;
  }
  cout << total << endl;
}



Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split(" ").map(Number);
var a = arr[0];
var b = arr[1];
var c = arr[2];
var d = arr[3];
if (a == b && c == d) console.log("yes");
else if (a == c && b == d) console.log("yes");
else if (a == d && b == c) console.log("yes");
else console.log("no");

Measured memory_bytes: 15460
def inpl(): return [int(i) for i in input().split()]
def comb(a,b):
    return math.factorial(a)//math.factorial(a-b)//math.factorial(b)

N, A, B = inpl()
V = inpl()
V = list(reversed(sorted(V)))
x1 = N-1
x2 = 0
for i in range(N):
    if V[i] == V[A]:
        x1 = min(x1,i)
        x2 = max(x2,i)

print(sum(V[0:A])/A)
import math
ans = 0
if x1 == 0:
    for l in range(A-1,min(B,x2+1)):
        ans += comb(x2-x1+1,l-x1+1)
    print(ans)
else:
    print(comb(x2-x1+1,A-x1))

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for i := 1; i <= 9; i++ {
		for j := 1; j <= 9; j++ {
			if n == i*j {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
n = int(input())
X = input()
pc = X.count('1')
nx = int(X, 2)

def f(n):
    c = 0
    while n > 0:
        n %= bin(n).count('1')
        c += 1
    return c

nxp = nx%(pc+1)
nxm = nx%(pc-1) if pc > 1 else 0
for i in range(n-1, -1, -1):
    if (nx>>i)&1:
        # 2**iを引く
        if pc-1 == 0:
            print(0)
            continue
        p = pow(2, i, pc-1)
        r = (nxm-p)%(pc-1)
    else:
        # 2**iを足す
        r = (nxp+pow(2, i, pc+1))%(pc+1)

    print(f(r) + 1)
    

Measured memory_bytes: 90248
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
   int a=kbd.nextInt();
   int b=kbd.nextInt();
   int m=kbd.nextInt();

   int[] A = new int[a];
   for(int n=0;n<a;n++){
     A[n] = kbd.nextInt();
   }
   int[] B = new int[b];
   for(int n=0;n<b;n++){
     B[n] = kbd.nextInt();
   }

  int[] wari = new int[m];
   for(int i=0;i<m; i++){
     int x = kbd.nextInt();
     int x1=A[x-1];
     int y = kbd.nextInt();
     int y1=B[y-1];
     int z = kbd.nextInt();
     wari[i]=x1+y1-z;
     }

   int am=200000;
   for(int i=0;i<a;i++){
     if(A[i]<am){
       am=A[i];
     }
   }
   int bm=200000;
   for(int i=0;i<b;i++){
     if(B[i]<bm){
       bm=B[i];
     }
   }
    int mab=am+bm;

    int wm=200000;
    for(int i=0;i<m;i++){
      if(wari[i]<wm){
        wm=wari[i];
      }
    }

    if(wm>mab){
      System.out.println(mab);
    }else{
      System.out.println(wm);
    }

}
}

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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int INF = 1e18;

signed main() {
	string s;
	cin >> s;
	int ans0 = (s[0] - '0') - 1;
	ans0 += 9 * (s.size()-1);
	int ans1 = 0;
	each(c, s) {
		ans1 += c - '0';
	}
	cout << max(ans0, ans1) << endl;

	return 0;
}


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

using namespace std;

long long gcd(long long a, long long b) {
	if(a == 0) return b;
	if(b == 0) return a;
	return gcd(b, a % b);
}

int main(void) {
	long long N;
	cin >> N;
	vector<long long> A;
	for(int i = 0; i < N; ++i) {
		long long a;
		cin >> a;
		A.push_back(a);
	}
	vector<long long> lgcds;
	lgcds.push_back(0);
	for(int i = 0; i < N; ++i) {
		lgcds.push_back(gcd(lgcds.back(), A[i]));
	}
	vector<long long> rgcds(N);
	rgcds[N - 1] = 0;
	for(int i = N - 2; i >= 0; --i) {
		rgcds[i] = gcd(A[i + 1], rgcds[i + 1]);
	}
	long long ans = 0;
	for(int i = 0; i < N; ++i) {
		long long g = gcd(lgcds[i], rgcds[i]);
		if(g > ans) ans = g;
	}
	cout << ans << '\n';
	return 0;
}



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

sunuke = [0 for i in range(N)]

for i in range(K):
  d = int(input())
  As = list(map(int, input().split()))
  for A in As:
    sunuke[A-1] += 1

treat = 0

for i in range(N):
  if sunuke[i] == 0:
    treat += 1
    
print(treat)


Measured memory_bytes: 9188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int n = Integer.parseInt(str);
		Long answer = (long) 1;
		int pow = (int)(Math.pow(10, 9) + 7);

		for(int i=1; i<=n; i++){
			answer = answer * i;
			answer = answer % pow;
		}
		System.out.println(answer);

	}

}


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

vector<bool> D(125*125*125*125);

int getw(char * str)
{
	int w = 0;
	while (1)
	{
		w *= 5;
		switch(*str++)
		{
		case 'A': w += 1; break;
		case 'C': w += 2; break;
		case 'G': w += 3; break;
		case 'T': w += 4; break;
		default: return w/5;
		}
	}
}

 int main()
{
	int n;
	cin >> n;
	char inst[16];
	char str[16];
	while(n--)
	{
		cin >> inst >> str;
		int w = getw(str);
		if (inst[0] == 'i')
		{
			D[w] = true;
		}
		else
		{
			cout << (D[w] ? "yes\n" : "no\n");
		}
	}
}

Measured memory_bytes: 30740
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		int sum = 0;
		for(int i = 0; i < n; i++) {
			int diff = 0;
			if(a[i] - 0 > k - a[i]) {
				diff = k - a[i];
			}
			else if (a[i] - 0 <= k - a[i]) {
				diff = a[i] - 0;
			}
			sum += diff * 2;
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 21972
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    for j, (a, i) in enumerate(sorted([(a, i) for i, a in enumerate(A)], key=lambda x: x[0])):
        A[i] = j
    ans2 = sum((i + a) & 1 for i, a in enumerate(A))
    print(ans2 // 2)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    A = [int(input()) for _ in range(N)]
    main(N, A)


Measured memory_bytes: 86124
#include <bits/stdc++.h>
     
    using namespace std;
     
    #define MOD 1000000007
    #define N 100005
    #define M 102
    #define ll long long 
    #define ld long double
    #define pb push_back
    #define ff first
    #define ss second
     
    ll dp[N], v[M], w[M];
     
    int main(){
    	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    	//freopen("input.txt", "r", stdin);
    	//freopen("output.txt", "w", stdout);
    	ll n, i, t, ans = 0, W;
        cin>>n>>W;
        ll sum = 0;
        for(t=1; t<=n; t++){
            cin>>w[t]>>v[t];
            sum = sum + v[t];
        }
        for(i=1; i<=sum; i++)
            dp[i] = 2e9;
        for(t=1; t<=n; t++){
            for(i=sum; i>=v[t]; i--){
                dp[i] = min(dp[i], dp[i - v[t]] + w[t]);
                if(dp[i] <= W)
                    ans = max(ans,i);
                //cout<<dp[i]<<" ";
            }
            //out<<endl;
        }
        cout<<ans;
    	return 0;
    }

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

using namespace std;

template <typename T> void debug(T v) { cout << v << endl; } /* {{{ */
template <typename T, typename... Rest> void debug(T v, Rest... r) {
  cout << v << " ";
  debug(r...);
}
template <typename T> void debug(const vector<T> &v) {
  for (const auto &e : v) {
    cout << e << " ";
  }
  cout << endl;
}
template <typename T> void debug(const vector<vector<T>> &vv) {
  for (const auto &v : vv) {
    debug(v);
  }
} /* }}} */

int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  vector<vector<int>> LR(N + 1, vector<int>(N + 1));
  for (int i = 1; i <= M; i++) {
    int l, r;
    cin >> l >> r;
    LR[l][r]++;
  }
  vector<vector<int>> LRS(N + 1, vector<int>(N + 1));
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      LRS[i][j] = LRS[i - 1][j] + LRS[i][j - 1] - LRS[i - 1][j - 1] + LR[i][j];
    }
  }
  vector<pair<int, int>> query(Q);
  for (int i = 0; i < Q; i++) {
    cin >> query[i].first >> query[i].second;
  }
  for (auto qr : query) {
    int p = qr.first, q = qr.second;
    int ans = LRS[q][q] - LRS[p - 1][q] - LRS[q][p - 1] + LRS[p - 1][p - 1];
    cout << ans << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <numeric>
#include <cstring>
#include <cmath>
#include <set>
#include <climits>
#include <queue>
#include <stack>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

int main()
{
    int n;

    while (cin >> n, n)
    {
        int s = 0;
        int maxs = 0, mins = iINF, sum = 0;

        rep(i, n)
        {
            cin >> s;
            maxs = max(maxs, s);
            mins = min(mins, s);
            sum += s;
        }

        cout << (sum - maxs - mins) / (n - 2) << endl;
    }

    return 0;
}


Measured memory_bytes: 3056
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var c = int.Parse(Console.ReadLine().Trim());
            if (c == 0) break;
            var ctotal = 0;
            var ans = 0;
            for (int i = 0; i < 12; i++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var m = int.Parse(line[0]);
                var n = int.Parse(line[1]);
                ctotal += m - n;
                if (ctotal >= c)
                {
                    if (ans == 0)
                    { Console.WriteLine(i + 1); ans = 1; }
                }
            }
            if (ans == 0) Console.WriteLine("NA");
        }
    }
}

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

int main() {
  int K, N; cin >> K >> N;
  int A[N];

  int maxLen = 0;
  cin >> A[0];

  int tmp;
  for (int i = 1; i < N; i++) {
    cin >> A[i];
    tmp = A[i] - A[i-1];
    maxLen = max(maxLen, tmp);
  }

  int ans = min(K - maxLen, A[N-1] - A[0]);

  cout << ans << endl;

  return 0;
}


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

const int MAXN = 100005;

struct node {
	int to, next;
} edge[MAXN*2];
int head[MAXN], top = 0;
inline void push(int i, int j)
{ edge[++top] = (node) {j, head[i]}, head[i] = top; }

int col[MAXN], vis[MAXN];
int n, m;
int flag = 1, cc = 0;

void dfs(int nd, int fa, int c)
{
	if (!flag) return;
	col[nd] = c;
	if (c == 1) cc++;
	for (int i = head[nd]; i; i = edge[i].next) {
		int to = edge[i].to;
		if (to == fa) continue;
		if (col[to] != 0 && col[to] != -c) { flag = 0; return; }
		if (col[to] == 0) dfs(to, nd, -c);
	}
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		int u, v; scanf("%d%d", &u, &v);
		push(u, v), push(v, u);
	}
	dfs(1, 0, 1);
	if (!flag) {
		cout << (long long)n*(n-1)/2-m << endl;
	} else {
		cout << (long long)cc*(n-cc)-m << endl;
	}
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<int> dx = {-1, 1};

int main(){
    ll n, m;
    ll ans = 0;
    cin >> n >> m;
    vector<ll> x(n), y(n), z(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> z[i];
    }
    rep(a, 2) {
        rep(b, 2) {
            rep(c, 2) {
                vector<ll> s(n);
                rep(i, n) {
                    s[i] = dx[a]*x[i] + dx[b]*y[i] + dx[c]*z[i];
                }
                sort(s.begin(), s.end());
                ll res = 0;
                rep(i, m) {
                    res += s[n-i-1];
                }
                chmax(ans, res);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<ll> vl;
typedef vector<vl> mat;
int W,N,x;
ll H,y,mod=1e9+9;
P ob[30];
mat E,A,p[70];
void add(ll &x, ll y){
	x+=y;
	x%=mod;
}
mat pro(mat a,mat b,int n){
	mat c(n,vl(n,0));
	rep(i,n) rep(j,n) rep(k,n) add(c[i][j],a[i][k]*b[k][j]);
	return c;
}
void showmat(mat a,int n){
	rep(i,n){
		rep(j,n) cout<<a[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
}
void preex(ll mx,int n){
//	show(mx);
//	show(n);
	p[0]=A;
	mx/=2;
	for(int i=0;mx>0;i++){
		p[i+1]=pro(p[i],p[i],n);
		mx/=2;
//		cout<<"p["<<i+1<<"]="<<endl;
//		showmat(p[i+1],n);
	}
}
mat ex(mat a,ll e,int n){
	mat c=E;
	for(int i=0;e>0;i++){
//		cout<<i<<endl;
		if(e%2) c=pro(c,p[i],n);
		e/=2;
	}
	return c;
}
int main(){
	for(int tt=1;;tt++){
		cin>>W>>H>>N;
		if(W==0) break;
		rep(i,N){
			cin>>x>>y;
			x--,y--;
			ob[i]=P(y,x);
		}
		sort(ob,ob+N);
		E.assign(W,vl(W,0));
		rep(i,W) E[i][i]=1;
		A.assign(W,vl(W,0));
		rep(i,W) A[i][i]=1;
		rep(i,W-1) A[i][i+1]=1;
		rep(i,W-1) A[i+1][i]=1;
		ll mx=ob[0].fs;
		rep(i,N-1) mx=max(mx,ob[i+1].fs-ob[i].fs);
		if(N>0) mx=max(mx,H-1-ob[N-1].fs);
		else mx=H-1;
		preex(mx,W);
//		cout<<"preexend\n";
		mat ret=E;
		ll now=0;
		rep(i,N){
			mat c=ex(A,ob[i].fs-now,W);
			ret=pro(c,ret,W);
			rep(j,W) ret[ob[i].sc][j]=0;
			now=ob[i].fs;
		}
		mat c=ex(A,H-1-now,W);
		ret=pro(c,ret,W);
		printf("Case %d: %lld\n",tt,ret[W-1][0]);
	}
}

Measured memory_bytes: 4360
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;
using ll = long long;

int main() {

	std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

	string N; cin >> N;

	string opposite = N;

	reverse(opposite.begin(), opposite.end());

	if (opposite == N)cout << "Yes";
	else cout << "No";

	return 0;

}

Measured memory_bytes: 256
def bubble(a, n)
	1.upto(n-1) do |i| 
	    (n-1).downto(i) do |j|
	        a[j-1], a[j] = a[j], a[j-1] if a[j-1][1] > a[j][1]
	    end
	end
end

def selection(a, n)
	0.upto(n-1) do |i|
	    minj = i
	     
	    i.upto(n-1) do |j|
	        minj = j if a[j][1] < a[minj][1]
	    end
	 
	    a[i], a[minj] = a[minj], a[i]
	end
end

def stablecheck(a, n)
	0.upto(n-2) do |i|
		return "Not stable" if a[i][1] == a[i+1][1] && A.index(a[i]) > A.index(a[i+1])
	end
	
	return "Stable"
end

N = gets.to_i
A = gets.chomp.split

a_temp = [*A]
bubble(a_temp, N)
puts a_temp.join(" ")
puts stablecheck(a_temp, N)

a_temp = [*A]
selection(a_temp, N)
puts a_temp.join(" ")
puts stablecheck(a_temp, N)


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
const ld eps = 1e-9;
struct point {ld x, y; };
struct line {point a, b; }; //Be sure that a and b are distinct.
void ReadPointInt(point &a) {read(a.x), read(a.y); }
void ReadLineInt(line &a) {ReadPointInt(a.a), ReadPointInt(a.b); }
point operator + (point a, point b) {return (point) {a.x + b.x, a.y + b.y}; }
point operator - (point a, point b) {return (point) {a.x - b.x, a.y - b.y}; }
point operator * (point a, ld b) {return (point) {a.x * b, a.y * b}; }
ld dot(point a, point b) {return a.x * b.x + a.y * b.y; }
ld operator * (point a, point b) {return a.x * b.y - a.y * b.x; }
ld moo(point a) {return sqrtl(a.x * a.x + a.y * a.y); }
ld dist(point a, point b) {return moo(a - b); }
point unit(point a) {
	ld tmp = moo(a);
	assert(tmp > eps);
	return a * (1.0 / tmp);
}
point Projection(point x, line a) {
	ld d = dot(x - a.a, a.b - a.a) / dist(a.a, a.b);
	return a.a + unit(a.b - a.a) * d;
}
point Reflection(point x, line a) {
	return Projection(x, a) * 2 - x;
}
bool OnLine(point x, line a) {
	return fabsl((a.b - a.a) * (x - a.a)) <= eps;
}
bool OnSegment(point x, line a) {
	return dist(x, a.a) + dist(x, a.b) - dist(a.a, a.b) <= eps;
}
int main() {
	line a; ReadLineInt(a);
	int q; read(q);
	while (q--) {
		point x; ReadPointInt(x);
		if (OnLine(x, a)) {
			if (OnSegment(x, a)) printf("ON_SEGMENT\n");
			else if (dist(x, a.a) > dist(x, a.b)) printf("ONLINE_FRONT\n");
			else printf("ONLINE_BACK\n");
		} else if ((a.b - a.a) * (x - a.a) > 0) printf("COUNTER_CLOCKWISE\n");
		else printf("CLOCKWISE\n");
	}
	return 0;
}


Measured memory_bytes: 3104
#include <iostream> // cout, endl, cin
#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
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
int main(){
  int k,sum=0;
  cin >> k;
  for(int i=1; i<=k; i++){
    for(int j=1; j<=k; j++){
      for(int l=1; l<=k; l++){
        int a=__gcd(i,j);
        sum+=__gcd(a,l);
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int r1 = scanner.nextInt();
		int c1 = scanner.nextInt();
		int r2 = scanner.nextInt() + 1;
		int c2 = scanner.nextInt() + 1;

		long sum = (f(r2, c2) - f(r1, c2) - f(r2, c1) + f(r1, c1)) % PRIME;

		if (sum < 0)
			sum += PRIME;

		System.out.println(sum);

		scanner.close();
	}

	static long f(int r, int c) {
		return fact(r + c) * inverse(fact(r) * fact(c) % PRIME) % PRIME;
	}

	static long fact(int n) {
		if (n == 0)
			return 1;
		return fact(n - 1) * n % PRIME;
	}

	static int inverse(long denom) {
		if (denom == 0)
			return 0;

		int a = PRIME;
		int b = (int) denom;
		int x = 0;
		int y = 1;
		int temp;

		while (a % b != 0) {
			x -= a / b * y;
			temp = x;
			x = y;
			y = temp;
			temp = a % b;
			a = b;
			b = temp;
		}

		//		while (y < 0)
		//			y += PRIME;

		return y;
	}

	static final int PRIME = 1000000007;
}


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

using vec = vector<int64_t>;
using mat = vector<vec>;

mat mul(mat &a, mat &b)
{
    mat c(a.size(), vec(b[0].size(), 0));
    for (int k = 0; k < a[0].size(); k++)
    {
        for (int i = 0; i < a.size(); i++)
        {
            for (int j = 0; j < b[0].size(); j++)
            {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    return c;
}

mat pow(mat a, int64_t n)
{
    mat r(a.size(), vec(a.size(), 0));
    for (int i = 0; i < a.size(); i++)
    {
        r[i][i] = 1;
    }
    for (; n; n >>= 1)
    {
        if (n & 1)
        {
            r = mul(r, a);
        }
        a = mul(a, a);
    }
    return r;
}

int main()
{
    int64_t a, b, c, k;
    cin >> a >> b >> c >> k;
    mat m(3, vec(3, 0));
    m[0][1] = m[0][2] = m[1][0] = m[1][2] = m[2][0] = m[2][1] = 1;
    m = pow(m, k);
    mat n(3, vec(1));
    n[0][0] = a;
    n[1][0] = b;
    n[2][0] = c;
    n = mul(m, n);
    cout << (1000000000000000000ll < abs(n[0][0] - n[1][0]) ? "Unfair" : to_string(n[0][0] - n[1][0])) << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,*a=map(int,open(0).read().split())
c=(0,2,5,5,4,5,6,3,7,6)
d=[0]+[-1]*n*9
for i in range(n):
 for j in a:
  if d[i]>=0:d[i+c[j]]=max(d[i+c[j]],d[i]*10+j)
print(d[n])

Measured memory_bytes: 15268
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  ll prev=-1,cnt=0,ans=0;

  rep(i,0,n){
    ll h;
    std::cin>>h;
    if(prev<h){
      ans=std::max(ans,cnt);
      cnt=0;
    }else{
      cnt++;
    }
    prev=h;
  }

  ans=std::max(ans,cnt);

  std::cout<<ans;

  return 0;
}

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

typedef long long ll;
ll n, m;
string a, b;

ll f(ll p, ll q) {
	if (q == 0) return p;
	return f(q, p % q);
}

int main()
{
	ll i, j, t;
	cin >> n >> m >> a >> b;
	t = f(n, m);
	n /= t;
	m /= t;
	t *= n * m;
	for (i = j = 0; i < a.size() && j < b.size(); i += n, j += m) {
		if (a[i] != b[j]) {cout << "-1"; return 0;}
	}
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}


#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb fflush(stdout)

int mod = 1e9 + 7;
const int max_n = 1e5+5;
int f[max_n];

int main () {
	make2(a, b);
	f[0] = 1;
	FOR(i,1,max(a,b)+1) {
		f[i] = (f[i-1] * 1LL * i) % mod;
	}
	if (a < b) swap(a,b);
	if (a-b>=2) {
		printf("0\n");
	} else if (a-b==1) {
		printf("%lld\n", (f[a]*1LL*f[b]) % mod);
	} else {
		printf("%lld\n", (f[a]*2LL*f[b]) % mod);
	}
	return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 20;
int n;
PII a[N];

int solve(vector<PII> x)
{
	vector<PII> odd, even;
	FOR(i, 0, n) if (((x[i].Y >> 1) + x[i].Y) & 1) odd.PB(x[i]);
	else even.PB(x[i]);
	
	if (SZ(even) != (n + 1) / 2) return INF;
	
	sort(ALL(even));
	sort(ALL(odd));
	reverse(ALL(even));
	reverse(ALL(odd));
	
	//for(auto i: even) cout << i.X << ' ' << i.Y << endl;
	//cout << endl;
	//for(auto i: odd) cout << i.X << ' ' << i.Y << endl;
	
	int ans = 0;	
	vector<int> tut;
	FOR(it, 0, n)
	{
		if (it % 2 == 0)
		{
			auto zad = even.back();
			even.pop_back();
			tut.PB(zad.X);
			int pos = zad.Y >> 1;
			assert(pos >= it);
			ans += pos - it;
			for(auto& i: even) if ((i.Y >> 1) < pos)
				i.Y += 2;
			for(auto& i: odd) if ((i.Y >> 1) < pos)
				i.Y += 2;
		}
		else
		{
			auto zad = odd.back();
			odd.pop_back();
			tut.PB(zad.X);
			int pos = zad.Y >> 1;
			assert(pos >= it);
			ans += pos - it;
			for(auto& i: even) if ((i.Y >> 1) < pos)
				i.Y += 2;
			for(auto& i: odd) if ((i.Y >> 1) < pos)
				i.Y += 2;
		}
	}
	
	auto lol = tut;
	sort(ALL(lol));
	if (tut != lol) return INF;	
	//debug(ans)
	return ans;	
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> n;
	FOR(i, 0, n) cin >> a[i].X;
	FOR(i, 0, n) cin >> a[i].Y;
	
	int ans = INF;
	
	FOR(mask, 0, 1 << n)
	{
		vector<PII> tut;
		FOR(i, 0, n) if (mask & (1 << i))
			tut.PB({a[i].X, i * 2});
		else
			tut.PB({a[i].Y, i * 2 + 1});
		setmin(ans, solve(tut));
	}
	
	if (ans == INF) ans = -1;
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
#define _[2<<17]
n,i;A _,B _,T _,F _;long M,D _,P _,R _;s(u,i,p,I){R[i]=i?s(u,T[i],p,0),(I=B[i])-p?s(I,F[I],u,0),D[u]=D[u]*-~D[I]%M:D[u]:++D[u];}S(u,x,p,i,I){for(i=F[u];I=B[i];I-p?S(I,R[i]*x%M+1,u,0,0),x=x*-~D[I]%M:0)i=T[i];P[u]=x%M;}main(u,v){for(;~scanf("%d%d",&u,&v);)i++?A[i-1]=B[i]=u,B[i-1]=A[i++]=v:(n=u,M=v);for(;--i;F[A[i]]=i)T[i]=F[A[i]];s(1,F[1],0,0);for(S(1,1,0,0,0);i++<n;)printf("%d ",P[i]);}

Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pi 3.14159265358979323846
#define mod 100000
int main()
{ 
    IOS;
    ll p;
    p=1;
    while(p--)
    {
        ll a,b,c,d,e,n;
        cin>>a>>b>>c;
        if(b*c>=a) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        
    }
}

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


class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        uint[] A = new uint[100001];//1にするところ注意
        string[] In = Console.ReadLine().Split(' ');
        //long sum = 0;
        ulong sum = 0;
        for (int i = 0; i < n; i++)
        {
            A[int.Parse(In[i])]++;
            sum += uint.Parse(In[i]);
            //sum += int.Parse(In[i]);
        }
        int q = int.Parse(Console.ReadLine());
        var que = new Queue<ulong>();
        //var que = new Queue<long>();
        for (int i = 0; i < q; i++)
        {
            string[] In2 = Console.ReadLine().Split(' ');
            uint b = uint.Parse(In2[0]);
            uint c = uint.Parse(In2[1]);
            //int temp_num = A[b];
            uint temp_num = A[b];
            sum -= temp_num * b;
            sum += temp_num * c;
            A[b] = 0;
            A[c] += temp_num;
            que.Enqueue(sum);
        }
        while (!(que.Count == 0))
        {
            Console.WriteLine(que.Dequeue());
        }
    }
}



Measured memory_bytes: 50444
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 1e3 + 5, P = 1e9 + 7;
int n, m, dp[N][N] = {1};
char c[N][N];

inline void readInput() {
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			cin >> c[i][j];
}

inline void solve() {
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (c[i][j] ^ '#') {
				if (i && c[i - 1][j] ^ '#')
					(dp[i][j] += dp[i - 1][j]) %= P;
				if (j && c[i][j - 1] ^ '#')
					(dp[i][j] += dp[i][j - 1]) %= P;
			}
	cout << dp[--n][--m] << endl;
}

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}


Measured memory_bytes: 5120
import sys

stdin = sys.stdin

mod = 1000000007

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
a = na()

ans = 0
for i in range(61):
	z, o = [0] * 2
	for j in range(n):
		if a[j] & (1 << i):
			o += 1
		else:
			z += 1
	ans += z * o * (2 ** i)
	ans %= mod

print(ans)

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<int, int> P;
typedef tuple<int, int, int> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;

int main() {
	ll n;
	cin >> n;
	vector<P> as(n);
	rep(i, n) { 
		ll a;
		cin >> a;
		as[i] = { a,i };
	}
	sort(as.begin(), as.end(), greater<P>());
	vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
	//数値が大きい順に先頭か、末端に配置すればよい
	//左からi人埋めて、右からj人埋めたときのスコア=dp[i][j]
	//dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + as[i].first  * (as[i].second - j)
	for(ll i = 0;i < n;i++){
		for (ll left = 0; i-left >= 0;left++) {
			//dp[left][right] から dp[left+1][right], dp[left][right+1]にpush
			ll right = i - left;
			ll n1 = left + 1;
			ll add1 = as[i].first * abs(as[i].second - left);
			dp[n1][right] = max(dp[n1][right], dp[left][right] + add1);
			ll n2 = right + 1;
			ll add2 = as[i].first * abs(as[i].second - (n-1 - right));
			dp[left][n2] = max(dp[left][n2], dp[left][right] + add2);
		}
	}
	ll u = 0;
	rep(i, n + 1) {
		rep(j, n + 1) {
			u = max(u, dp[i][j]);
		}
	}
	cout << u << endl;
	return 0;
}


Measured memory_bytes: 34660
#include <stdio.h>
int main(void){
    int i,n,a,min=1000,max=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(min>a){
            min=a;
        }
        if(max<a){
            max=a;
        }
    }
    printf("%d",max-min);
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int A, B, C;
  cin >> A >> B >> C;
  int k = B/A;
  mins(k, C);
  cout << k << '\n';
}


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

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

  double odd = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 1) odd++;
  }
  cout << odd / n << endl;
}


Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long int ll;
int main() {
	int n,cnt = 0; cin >> n; vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	ll sum = 0;
	rep(i, n - 1) {
		sum += a[i];
		if (sum * 2 < a[i + 1]) cnt = i+1;
	}cout << n - cnt << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		String b=sc.next();
		String c=sc.next();
		String bb=(a.charAt(0)+"").toUpperCase()+(b.charAt(0)+"").toUpperCase()+(c.charAt(0)+"").toUpperCase();
		System.out.println(bb);
	}
}

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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)
int main()
{
  string T,S;
  int ans=0;
  cin>>S>>T;
  int i=0;
  while (i<=S.size()-T.size())
  {
    int count=0;
    for(int j=0;j<T.size();j++){
      if(S[i+j]==T[j]){
        count++;
      }
    }
    ans=max(count,ans);
    i++;
  }
  cout<<T.size()-ans;
  return 0;
}




Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

string s;

int main(){
	while(cin>>s){
		int a1=0,a2=0;
		string s2=s;
		while(s.find("JOI")!=string::npos){
			s=s.substr(s.find("JOI")+1);
			a1++;
		}
		while(s2.find("IOI")!=string::npos){
			s2=s2.substr(s2.find("IOI")+1);
			a2++;
		}
		cout<<a1<<endl<<a2<<endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	string b1 = a.substr(0,1);
	string b2 = a.substr(1,1);
	string b3 = a.substr(2,1);
	if(b1==b2 && b2==b3)cout<<"No";
	else cout<<"Yes";
	return 0;
}

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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    vi a(3); REP(i, 3) cin >> a[i];
    sort(ALL(a));
    if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3624