akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;


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


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll p;
  rep(i,n){
    ll t;
    cin >> t;
    if(i == 0) p = t;
    else p = lcm(p, t);
  }
  cout << p << endl;
  
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;
	lli nowT=0,nowX=0,nowY=0;

	REP(i,0,n){
		lli t,x,y;
		cin>>t>>x>>y;
		lli diffT = t - nowT;
		lli diff =abs(nowX-x)+abs(nowY-y);
		if(diffT < diff){
			cout<<"No"<<endl;
			return 0;
		}
		if((diffT % 2 ) != (( diff)%2))
		{
			cout<<"No"<<endl;
			return 0;
		}
		nowX=x;
		nowY=y;
		nowT=t;
	}
	cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    
    val lucas = mutableListOf<Long>()
    
    lucas.add(2L)
    lucas.add(1L)
    
    for (i in 2..n) {
        lucas.add(lucas[i - 1] + lucas[i - 2])
    }
    
    println(lucas[n])
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 33736
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int ans=0;
		int c[]=new int[b];
		for(int i=0;i!=b;i++) {
			c[i]=scan.nextInt();
		}
		int count=0;
		String val="0";
		for(ans=a;;ans++) {
			int i=ans;
			int e=100;
			int f=100;
			int g=100;
			int h=100;
			val=String.valueOf(i);
			int d=i%10;
			i/=10;
			if(val.length()>=2) {
			e=i%10;
			i/=10;
			if(val.length()>=3) {
			f=i%10;
			i/=10;
			if(val.length()>=4) {
			g=i%10;
			i/=10;
			if(val.length()>=5) {
			h=i%10;
			}
			}
			}
			}
			for(int j=0;j!=b+1;j++) {
				if(j==b) {
					count=1;
					break;
				}
				if(c[j]==d||c[j]==e||c[j]==f||c[j]==g||c[j]==h) {
					break;
				}
			}
			if(count==1) {
				System.out.println(ans);
				break;
			}
		}
		}
	}

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

int main()
{
    int k,s;cin>>k>>s;
    int cnt=0;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;i+j<=s&&j<=k;j++)
        {
            if(s-(i+j)<=k)
            {
//                cout<<i<<" "<<j<<" "<<s-(i+j)<<endl;
                cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}




main(){
    ll h=lin();
    ll t=1;
    ll ans=0;
    while(h){
        ans+=t;
        t*=2ll;
        h/=2ll;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import Foundation

private func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

prefix operator *
private prefix func *<T>(a: inout IndexingIterator<[T]>) -> T {
    return a.next()!
}

func mainC() {
    var nmk = readWords { Int($0)! }.makeIterator()
    let n = *nmk
    let m = *nmk
    var k = *nmk
    
    var A = readWords { Int($0)! }
    var B = readWords { Int($0)! }
    
    var cumA = [Int]()
    cumA.append(0)
    var cumB = [Int]()
    var totalA = 0
    for a in A {
        let x = totalA + a
        if x > k {
            break
        }
        cumA.append(x)
        totalA = x
    }
    
    var totalB = 0
    for b in B {
        let x = totalB + b
        if x > k {
            break
        }
        cumB.append(x)
        totalB = x
    }
    
    if cumA.count == 1 && cumB.isEmpty {
        print(0)
        return
    }
    
    if cumA.count == 1 {
        print(cumB.count)
        return
    }
    
    if cumB.isEmpty {
        print(cumA.count)
        return
    }
    
    // 先に読んでしまった方がいい場合がある
    // 貪欲じゃない
    // 希望的観測
    // AのKを超えない範囲
    // BのKを超えない範囲
    // 累積和をとる
    // その中から最大の個数を取得
    // 二分探索?
    
    // Aを固定してBの位置を決める
    var ans = 0
    for (i, a) in cumA.enumerated() {
        var l = -1
        var r = cumB.count
        while r - l > 1 {
            let mid = l + (r - l) / 2
            if cumB[mid] + a > k {
                r = mid
            } else {
                l = mid
            }
        }
        ans = max(ans, i+r)
    }
    
    print(ans)
    

}

mainC()


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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define F first
#define precise std::cout << std::fixed;std::cout << std::setprecision(6); 
#define S second  
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

int binexpo(int x, int y, int p) {    
    int res = 1;     // Initialize result  
    x = x % p; // Update x if it is more than or  
                // equal to p  

    while (y > 0)  {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;
}
// --------------------------template ends here------------------------------

int dp[200005] = {0};

void solve() {
    int n;
    cin >> n;

    vector <int> v(n);

    for(int i=0;i<n;i++)
        cin >> v[i];

    dp[0] = 0;

    dp[1] = abs(v[1]- v[0]);

    for(int i=2;i<n;i++)
        dp[i] = min(dp[i-2] + abs(v[i] - v[i-2]), dp[i-1] + abs(v[i] - v[i-1]));    

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

    cout << dp[n-1] << endl;
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	
  string str;
  str = "abcdefghijklmnopqrstuvwxyz";
  char A;
  cin >> A;
  for (int i = 0; i < 26; i++) {
  	if (str.at(i) == A) {
  		cout << str.at(i+1) << endl;
      	break;
    }
  }
}

Measured memory_bytes: 256
def solve(string):
    n, m, *xyz = map(int, string.split())
    t = [-1] * (n + 1)

    def union(r1, r2):
        if r1 != r2:
            t[max(r1, r2)] = min(r1, r2)

    def find(x):
        if t[x] < 0:
            return x
        t[x] = find(t[x])
        return t[x]

    for x, y, z in zip(*[iter(xyz)] * 3):
        union(find(x), find(y))
    return str(t[1:].count(-1))


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m)])))


Measured memory_bytes: 34876
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef unsigned long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n; cin >> n;
  cout << (n * n * n) << endl;
  
}


Measured memory_bytes: 256
x = input()
y = input()

xResult = "No"
    
for i in range(len(x)):
    if i + len(y) <= len(x):
        if x[i:i+len(y)] == y:
            xResult = "Yes"
            break
    else:
        a = i + len(y) - len(x)
        if x[i:i+len(y)-a] + x[0:a] == y:
            xResult = "Yes"
            break

print(xResult)
    


Measured memory_bytes: 5560
s = gets.chomp
M = 2019

m = Hash.new(0)
sc = 1
dm = 0

s.reverse.each_char do |c|
    
    dm += c.to_i * sc
    dm %= M
    
    #puts "#{c} #{dm}"
    
    m[dm % M] += 1
    
    sc *= 10
    sc %= M

end

ans = 0
m.each do |key, value| 
  ans += value * (value-1) / 2 if 2 <= value
end
puts ans + m[0]




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

int main(){
    int c1,c5,c10,c50,c100,c500;
    cin >>c1>>c5>>c10>>c50>>c100>>c500;
    if(c1+5*c5+10*c10+50*c50+100*c100+500*c500>=1000){
        cout<<1<<endl;
    }
    else{
        cout <<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N;
	int d[110];
	cin >> N;
	vector<int>V;
	for (int i = 0; i < N; ++i) {
		cin >> d[i];
		V.push_back(d[i]);
	}
	sort(V.begin(), V.end());
	int ans = 1;
	for (int i = 0; i < N-1; ++i) {
		if (V[i] != V[i + 1]) {
			ans++;
		}
	}
	cout << ans;
	return 0;
}

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

#define STACK_SIZE 1000
#define MAX_LENGTH 1000

int stack[STACK_SIZE];
int stack_size = 0;

int pop() {
  if (stack_size <= 0) {
    return 0;
  }
  return stack[--stack_size];
}

void push(int x) {
  stack[stack_size++] = x;
}

int check_number(char *s) {
  // 符号あり
  if (*s == '+' || *s == '-') {
    s++;
    if (*s >= '0' && *s <= '9') {
      return 1;
    } else {
      return 0;
    }
  }
  // 符号なし
  if (*s >= '0' && *s <= '9') {
    return 1;
  } else {
    return 0;
  }
}

int get_number(char *s) {
  int sign = 0;
  int n = 0;

  if (*s == '+') {
    s++;
  } else if (*s == '-') {
    sign = 1;
    s++;
  }
  while(*s >= '0' && *s <= '9') {
    n = n * 10 + (*s - '0');
    s++;
  }
  if (sign) {
    return -n;
  } else {
    return n;
  }
}

int calc(char *s) {
  int x, y, n;

  while(*s) {
    if (check_number(s)) {
      n = get_number(s);
      push(n);
      while (*s == '+' || *s == '-') {
        s++;
      }
      while (n) {
        n /= 10;
        s++;
      }
    } else {
      switch (*s) {
        case '+':
          x = pop();
          y = pop();
          push(y+x);
          break;
        case '-':
          x = pop();
          y = pop();
          push(y-x);
          break;
        case '*':
          x = pop();
          y = pop();
          push(y*x);
          break;
      }
      s++;
    }
  }
  return pop();
}

int main() {
  char s[MAX_LENGTH];
  scanf("%[^\n]*s", s);
	printf("%d\n", calc(s));

  return 0;
}



Measured memory_bytes: 2100
import sys
input = sys.stdin.readline

from heapq import heappush, heappop

N, D, A = map(int, input().split())
XH = [[int(i) for i in input().split()] for _ in range(N)]

XH.sort()

ret = 0
hp = []
s = 0
for i, (x, h) in enumerate(XH) :
  while len(hp) > 0 and hp[0][0] < x - D :
    s -= heappop(hp)[1]
    
  if s > h :
    continue
  
  cnt = (h - s + A - 1) // A
  ret += cnt
  heappush(hp, (x + D, cnt * A))
  s += cnt * A

print(ret)

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

using namespace std;


int main()
{
    long long int n,pd,i;
    cin>>n;
    pd = 2;
    cout<<n<<":";
    while(n%2 == 0){

       cout<<" "<<2;
       n/=2;

    }
    for (i=3;i<=sqrt(n);){

        if(n%i == 0){

            cout<<" "<<i;
            n/=i;

        }
        else i+=2;

    }
    if (n>2)cout<<" "<<n;

    cout<<endl;

    return 0;



}




Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	int n, m, reward;
	int a, b, c, d;
	int x1, x2, y1, y2;
	int cost[21][21];
	char ch;

	cin >> n >> m;

	for (int i = 0; i < 21; i++)
	{
		for (int j = 0; j < 21; j++)
		{
			cost[i][j] = 10000;			//????°?????????¨?????????????????????cost>1000
		}
	}

	for (int i = 0; i < m; i++)
	{
		cin >> a >> ch >> b >> ch >> c >> ch >> d;
		cost[a][b] = c;
		cost[b][a] = d;
	}
	cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			for (int k = 1; k <= n; k++)
			{
				cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);		//???????????£??????????????????????????£?????????????????????????????????
			}
		}
	}
	reward = y1 - y2 - cost[x1][x2] - cost[x2][x1];
	
	cout << reward << endl;

	return 0;
}

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

public class Main {

    public static void main(String[] args) {
        try {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] strArray = br.readLine().split("\\s");
        Integer[] intArray = new Integer[2];
        for (int i = 0; i < strArray.length; i++) {
            intArray[i] = Integer.valueOf(strArray[i]);
        }
        switch (intArray[0].compareTo(intArray[1])) {
            case 1:
                System.out.println("a > b");
                break;
            case -1:
                System.out.println("a < b");
                break;
            case 0:
                System.out.println("a == b");
                break;
        }
        
                } catch(IOException e) {
            System.err.println(e);
        }

    }
}

Measured memory_bytes: 16892
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(void) {
    int64_t N, M, K;
    cin >> N >> M >> K;
    vector<int64_t> A(N+1), B(M+1);
    for(int i=1; i<=N; i++) {
        cin >> A[i];
    }
    for(int j=1; j<=M; j++) {
        cin >> B[j];
    }

    int ans = 0;
    partial_sum(A.begin(), A.end(), A.begin());
    partial_sum(B.begin(), B.end(), B.begin());

    int j = M;
    for(int i=0; i<=N; i++) {
        if(A[i] > K) continue;
        while(A[i] + B[j] > K) {
            --j;
        }
        ans = max(ans, i+j);
    }

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


Measured memory_bytes: 6436
#include<bits/stdc++.h>
using namespace std;
int main(){
    int count[26]={};
    for(int i=0;i<26;i++) count[i]=0;
    char ch;
    while(scanf("%c", &ch)!=EOF){
        
        if('a'<=ch && ch<='z'){
            int num=ch-'a';
            count[num]++;
        }
        else if('A'<=ch && ch<='Z'){
            int numb=ch-'A';
            count[numb]++;
        }
    }

    for(int i=0;i<26;i++){
        printf("%c : %d\n", i+'a', count[i]);
    }
    return 0;
}


Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<iostream>
using namespace std;
#define INF (1<<29)
struct st{
  int x,y;
  st(int x,int y){this->x=x;this->y=y;}
};
int W,H;
int co;
int gx,gy;
vector<st> G[2501];
int dp[2501][2501];
inline int ab(int a){ return a>0?a:-a;}
int solve(int no,int i){
  if(dp[no][i]!=-1) return dp[no][i];
  if(no==co){
    return ab(G[no][i].x-gx)+ab(G[no][i].y-gy);
  }
  int ret=INF;
  for(int j=0;j<(int)G[no+1].size();j++){
    ret=min(ret,
	    solve(no+1,j)+ab(G[no][i].x-G[no+1][j].x)+ab(G[no][i].y-G[no+1][j].y));
  }
  return dp[no][i]=ret;
}
main(){
  while(1){
    int sx,sy;
    memset(dp,-1,sizeof(dp));
    cin >> W >> H;
    if(!W && !H) break;
    co=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	string c;
	cin >> c;
	if(c=="S"){
	  G[0].push_back(st(j,i));
	} else if(c=="G"){
	  gx=j;gy=i;
	} else if(c=="."){
	} else{
	  G[atoi(c.c_str())].push_back(st(j,i));
	  co=max(co,atoi(c.c_str()));
	}
      }
    }
    cout << solve(0,0) << endl;
    for(int i=0;i<2501;i++)
      G[i].clear();
  }  
}

Measured memory_bytes: 26060
R, G, B, N = map(int, input().split())
ans = 0
for i in range(N + 1):
    r = i * R
    if r > N:
        break
    for j in range(N + 1):
        g = j * G
        if r + g > N:
            break
        b = N - r - g
        if b >= 0 and b % B == 0:
            ans += 1
print(ans)


Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <map>
#include <sstream>
#include <algorithm>

std::map<std::string, int> mp;

void split(const std::string &str, char sep) {
    std::stringstream ss(str);
    std::string buf;
    while ( std::getline(ss, buf, sep)  ) {
        std::transform(buf.begin(), buf.end(), buf.begin(), tolower);
        if (mp.find(buf) != mp.end()) {
            mp[buf]++;
        } else {
            mp[buf] = 1;
        }
    }
    /*
    for (std::map<std::string, int>::iterator itr=mp.begin();itr!=mp.end(); itr++) {
        std::cout << itr->first << " : " << (itr->first).length() << std::endl;
    }
    */
}

void solve() {
    int m_freq = -1;
    std::string freq, len_str;
    std::string tmp_f;
    int         tmp_s;
    int m_len  = 0;
    for (std::map<std::string, int>::iterator itr=mp.begin(); itr!=mp.end(); itr++) {
        tmp_f = itr->first;
        tmp_s = itr->second;
        if (m_freq < tmp_s) {
            m_freq = tmp_s;
            freq   = tmp_f;
        }
        // std::cout << tmp_f << " : length ... " << tmp_f.length() << std::endl;
        if (m_len < tmp_f.length()) {
            m_len   = tmp_f.length();
            len_str = tmp_f;
        }
    }
    std::cout << freq << ' ';
    std::cout << len_str << std::endl;
}

int main() {
    std::string s;
    std::getline(std::cin, s);
    split(s, ' ');
    solve();
}



Measured memory_bytes: 3184
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int a[26];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		getchar();
		for(int j=1;j<=m;j++){
			char c;
			scanf("%c",&c);
			a[c-'a']++;
		}
	}
	int need4;
	int need1;
	int need2;
	if(n%2==0&&m%2==0){
		need4=(n/2)*(m/2);
		need1=need2=0;
	}
	else if(n%2==1&&m%2==1){
		need4=(n/2)*(m/2);
		need2=n/2+m/2;
		need1=1;
	}
	else{
		need4=(n/2)*(m/2);
		if(n&1)
			need2=m/2;
		else
			need2=n/2;
		need1=0;
	}
	for(int i=25;i>=0;i--){
		if(a[i]>=4&&need4>0){
			if(need4>=a[i]/4){
				need4-=a[i]/4;
				a[i]%=4;
			}			
			else{
				a[i]-=need4*4;
				need4=0;
			}			
		}
	}
	for(int i=25;i>=0;i--){
		if(a[i]>=2&&need2>0){
			if(need2>=a[i]/2){
				need2-=a[i]/2;
				a[i]%=2;
			}			
			else{
				a[i]-=need2*2;
				need2=0;
			}
		}
	}
	for(int i=25;i>=0;i--){
		if(a[i]>=1&&need1>0){
			a[i]--;
			need1=0;
			break;
		}
	}
	bool flag=true;
	if(need2!=0||need4!=0||need1!=0)
		flag=false;
	for(int i=25;i>=0;i--){
		if(a[i]!=0)
			flag=false;
	}
	if(flag)
		puts("Yes");
	else
		puts("No");
	return 0;
}

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

vector<int> sieve(int n) {
  vector<int> prime(n);
  for(int i=2; i<n; i++) prime[i]=i;
  for(int i=2; i*i<n; i++) {
    if(prime[i]) {
      for(int j=i*i; j<=n; j+=i) prime[j]=0;
    }
  }
  prime.erase(remove(prime.begin(),prime.end(),0),prime.end());
  return prime;
}

int main() {
  vector<int> prime=sieve(123456*2+1);
  int n;
  while(cin >> n && n!=0) {
    int cnt=0;
    for(int i=0; i<prime.size(); i++) {
      if(prime[i]>n*2) break;
      if(prime[i]>n) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}


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

int main(){
  int A, B, C, X, ans = 0;
  cin >> A >> B >> C >> X;
  for (int i = 0; i <= A; i++){
    for (int j = 0; j <= B; j++){
      for (int k = 0; k <= C; k++){
        if (500 * i + 100 * j + 50 * k == X){
          if(i != 0 || j != 0 || k != 0){
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int N = sc.nextInt();
            int M = sc.nextInt();
            int[] A = new int[M];

            for(int i=0; i<M; i++) {
                A[i] = sc.nextInt();
            }

            int res = N;
            for(int i=0; i<M; i++) {
                res -= A[i];
            }

            if(res<0) {
                System.out.println("-1");
            } else {
                System.out.println(res);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 34456
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main(){
int E,O;
cin>>E>>O;
cout<<E*(E-1)/2+O*(O-1)/2<<endl;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int sx,sy,tx,ty;
  cin>> sx >>sy >>tx >>ty;
  	int a=tx-sx, b=ty-sy; 
	for(int i=0;i<b;i++){
    	cout<<"U";
    }  	
  	for(int i=0;i<a;i++){
    	cout<<"R";
    }
  	for(int i=0;i<b;i++){
    	cout<<"D";
    }
	for(int i=0;i<a;i++){
    	cout<<"L";
    }
  	cout<<"L";
    for(int i=0;i<b+1;i++){
    	cout<<"U";
    }
	for(int i=0;i<a+1;i++){
    	cout<<"R";
    }
  	cout <<"DR";
  	for(int i=0;i<b+1;i++){
    	cout<<"D";
    }
	for(int i=0;i<a+1;i++){
    	cout<<"L";
    }
  	cout<<"U";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n,h,w,c=0;
	cin>>n>>h>>w;
	for(int i=1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		int q1=(a/h),q2=(b/w);
		if(q1>0 && q2>0)
		c++;
	}
	cout<<c;
	return 0; 
} 
 


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

int main()
{
  int64_t N, r = 0, b = 0, g = 0;
  cin >> N;
  string S;
  cin >> S;
  for (int i = 0; i < N; i++)
  {
    if (S[i] == 'R')
      r++;
    else if (S[i] == 'G')
      g++;
    else
      b++;
  }
  int64_t ans = r * g * b;
  for (int i = 0; i < N; i++)
  {
    for (int l = 1; l < N; l++)
    {
      int j = i + l, k = i + 2 * l;
      if (k >= N)
      {
        break;
      }
      if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i])
      {
        ans--;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int n;cin>>n;
  vector<int> p(n),q(n),vec(n);
  rep(i,n)cin>>p[i];
  rep(i,n)cin>>q[i];
  rep(i,n)vec[i]=i+1;
  map<vector<int>,int> mp;
  do{
    mp[vec]=mp.size();
  }while(next_permutation(all(vec)));
  int ans=abs(mp[q]-mp[p]);
  cout<<ans<<endl;
}

Measured memory_bytes: 8516
N,M = map(int, input().split())
ac = [0]*N
pn = [0]*N

for i in range(0,M):
    pi,si = input().split()
    pi = int(pi)
    if ac[pi-1] == 0:
        if si == "WA":
            pn[pi-1] += 1
        else:
            ac[pi-1] = 1

for i in range(0,N):
    if ac[i] == 0:
        pn[i] = 0
        
print(sum(ac),sum(pn))

Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


vector<int> sieve() {
    const int MAX_N = 1000 + 1;
    vector<int> v(MAX_N, 0);
    v[0] = v[1] = 1;
    for (int i = 2; i * i <= MAX_N; ++i) {
        int tmp = 2;
        while (tmp * i <= MAX_N) {
            v[tmp++ * i] = 1;
        }
    }
    return v;
}

int main() {
    
    int n;
    cin >> n;
    
    auto v = sieve();
    ll ans = 1;
    
    // rep(i, sz(v)) cout << v[i] << " "; cout << '\n';
    
    rep(i, n + 1) {
        if (v[i] == 1) continue;
        int now = i;
        // cout << now << '\n';
        ll tmp = 0;
        while (now <= n) {
            (tmp += n / now) %= inf;
            now *= i;
        }
        (ans *= tmp + 1) %= inf;
    }
    
    cout << ans << '\n';
}

/*
 1 2 3 4 5 6 7 8 9 10
   2   2   2   2    2
       2       2
               2
     3     3     3
                 3
         5          5
             7
 */


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  int sum = 0;
  int count = 0;
  cin >> n;
  vector<int> garden(n);
  for (int i = 0; i < n; i++)
  {
    cin >> garden[i];
    sum += garden[i];
  }

  while (sum > 0)
  {
    int p = 0;
    while (p < n)
    {
      int min = 101;
      while ((p < n)&&(garden[p] != 0))
      {
        if (min > garden[p]) min = garden[p];
        ++p;
      }

      if (min < 101)
      {
        int q = p-1;
        while ((q >= 0)&&(garden[q] > 0))
        {
          garden[q] -= min;
          sum -= min;
          --q;
        }
        count += min;
      }

      while ((p < n)&&(garden[p] == 0)) ++p;
    }
  }

  cout << count << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, c, d;
    
    printf("\n");
    scanf("%d %d %d %d", &a, &b, &c, &d);
    
    if(a<b&&c<d)
    {
        printf("%d", a+c);
    }
    else if(a<b&&d<c)
    {
        printf("%d", a+d);
    }
    else if(b<a&&c<d)
    {
        printf("%d", b+c);
    }
    else if(b<a&&d<c)
    {
        printf("%d", b+d);
    }
    else if(a<b&&c==d)
    {
        printf("%d", a+c);
    }
    else if(b<a&&c==d)
    {
        printf("%d", b+c);
    }
    else if(a==b&&c<d)
    {
        printf("%d", a+c);
    }
    else if(a==b&&d<c)
    {
        printf("%d", a+d);
    }
    else if(a==b&&c==d)
    {
        printf("%d", a+c);
    }
   
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true) {
            int H = input.nextInt();
            int W = input.nextInt();
            if (H == 0 && W == 0) break;
            char[] cs = new char[W];
            Arrays.fill(cs, '#');
            for (int i = 0; i < H; i++) {
                System.out.println(cs);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 21232
from collections import Counter

N = int(input())
A = list(map(int,input().split()))

c = list(Counter(A).items())
ans = len(c)
even = 0
for x, y in c:
    if y % 2 == 0:
        even += 1
if even % 2 == 0:
    pass
else:
    ans -= 1
print(ans)

Measured memory_bytes: 21468
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

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

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

vector<int> v = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
void solve() {
	int n; cin >> n;
	cout << v[n - 1] << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;



int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n; cin >> n;
    string s; cin >> s;
    int c1 = 0, c2 = 0;
    trav(i, s)
    {
        if (i == 'W') c1++;
        else c2++;
    }
    int c = 0;
    FOR(i, 0, c2)
    {
        if (s[i] == 'W') c++;
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

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

    int ans = -1;
    for(int N = 0; N < n; ++N)
    {
        int fail1[n - N + 1]; fail1[0] = fail1[1] = 0;
        int fail2[n - N + 1]; fail2[0] = fail2[1] = 0;
        int len1 = 0, len2 = 0;
        for(int i = 1; i < n - N; ++i)
        {
            while(len1 > 0 && s[N + len1] != s[N + i]) len1 = fail1[len1];
            if(s[N + len1] == s[N + i]) ++len1;
            fail1[i + 1] = len1;

            while(2 * len2 + 1 > i || (len2 > 0 && s[N + len2] != s[N + i])) len2 = fail1[len2];
            if(s[N + len2] == s[N + i]) ++len2;
            fail2[i + 1] = len2;
        }
        for(int i = 0; i <= n - N; ++i)
            ans = max(ans, fail2[i]);
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N=int(input())
A=np.array(list(map(int,input().split(' '))))
A=A-np.arange(N)
Amed=np.int(np.median(A))
err=[]
for b in (Amed,Amed+1):
    err.append(np.sum(np.abs(A-b)))
print(min(err))


Measured memory_bytes: 34204
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    string s;
    cin >> n >> s;
    int r = 0, g = 0, b = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'R') ++r;
        if(s[i] == 'G') ++g;
        if(s[i] == 'B') ++b;
    }
    ll ans = (ll) r * g * b;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(s[i] == s[j])    continue;
            int len = j - i;
            if(j + len >= n)    break;
            int k = j + len;
            if(s[k] != s[i] && s[k] != s[j])    --ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

const int M = 13;

string s;
ll t = 1, ans;
ll dp[2][13];
int ho = 0, ge = 1;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    dp[ho][0] = 1;
    for (int i = (int)s.size()-1; i >= 0; i--) {
        rep(j,M) dp[ge][j] = 0;
        if (s[i] != '?') {
            int x = t*(s[i]-'0')%M;
            rep(j,M) {
                if (x == M) x -= M;
                dp[ge][x++] = dp[ho][j];
            }
        } else {
            int x = 0;
            rep(j,10) {
                int y = x;
                rep(k,M) {
                    if (y == M) y -= M;
                    dp[ge][y++] += dp[ho][k];
                }
                x += t;
                if (x >= M) x -= M;
            }
            rep(j,M) while (dp[ge][j] >= MOD) dp[ge][j] -= MOD;
        }
        t = t * 10 % M;
        swap(ho,ge);
    }
    cout << dp[ho][5] << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
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; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int n,q; cin>>n>>q; 
    vector <int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end()); 
    rep(i,q){
        int l,r; cin>>l>>r;
        cout<<upper_bound(all(a),r) - lower_bound(all(a), l)<<endl;
    }
}


Measured memory_bytes: 3636
# Coding is about expressing your feeling, and
# there is always a better way to express your feeling_feelme
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=int(1e9 + 7)

def divisor(n):
    ans={}
    m=int(n**0.5)+1
    for i in range(1,m):
        if n%i==0:
            ans[i]=1
            ans[n//i]=1
    return ans
def prime(n):
    if n<=3:
        return True
    m=int(n**0.5)+1
    if n%2==0:
        return False
    for i in range(3,m,2):
        if n%i==0:
            return False
    return True

a,b=iia()
ans=divisor(a)
ans2=divisor(b)
res=[]
for i,j in ans.items():
    if i in ans2:
        res.append(i)

#print(res)
count=0
for i in res:
    if prime(i):
        count+=1
print(count)



Measured memory_bytes: 10740
fun main() {
    val size = readLine()!!.toInt()
    val heights = readLine()!!.split(' ').map { it.toInt() }

    val dp = IntArray(size) { 0 }
    dp[1] = Math.abs(heights[0] - heights[1])
    var count = 2
    while (count < size) {
        val c1 = Math.abs(heights[count - 1] - heights[count]) + dp[count - 1]
        val c2 = Math.abs(heights[count - 2] - heights[count]) + dp[count - 2]
        dp[count] = Math.min(c1, c2)
        count++
    }
    println(dp[size - 1])
}

Measured memory_bytes: 49824
#include <iostream>
#include <functional>

struct Closed_Section {
    bool valid;
    int64_t begin;
    int64_t end;
    Closed_Section(bool _valid, int64_t _begin, int64_t _end) {
        valid = _valid; begin = _begin; end = _end;
    }
    Closed_Section() {
        valid = false, begin = 0; end = -1; //配列を定義するためにデフォルトコンストラクタが必要。
    }
    int64_t size() { return valid ? end - begin + 1 : 0; }
    void dump() { std::cout << "valid:" << valid << " begin:" << begin << " end:" << end << std::endl; }
};

Closed_Section binary_search(const int64_t L, const int64_t R, std::function<bool(int64_t)> func) {
    if (R < L) { return Closed_Section(false, L, R); }
    const bool res_L = func(L);
    const bool res_R = func(R);
    if (res_L && res_R) {
        return Closed_Section(true, L, R);
    } else if (!res_L && !res_R) {
        return Closed_Section(false, 0, -1);
    } else {
        int64_t lb = L;
        int64_t ub = R;
        while (lb + 1 < ub) {
            int64_t mid = (lb + ub) / 2;
            if (res_L == func(mid)) {
                lb = mid;
            } else {
                ub = mid;
            }
        }
        return res_L ? Closed_Section(true, L, lb) : Closed_Section(true, ub, R);
    }
}

Closed_Section binary_search(const Closed_Section& cs, std::function<bool(int64_t)> func) {
    return cs.valid ? binary_search(cs.begin, cs.end, func) : cs;
}

// end of template

int64_t N;
const int64_t MAX_N = 2e5 + 10;
int64_t A[MAX_N] = {};
int64_t S[MAX_N] = {};
int64_t X[MAX_N] = {};

int main(int argc, char **argv) {
    std::cin >> N;
    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
        S[i] = S[i-1] + A[i];
        X[i] = (X[i-1] ^ A[i]);
    }
    int64_t ret = 0;
    for (int64_t i = 1; i <= N; i++) {
        auto cs = binary_search(i, N, [&](int64_t j){
            return S[j] - S[i-1] == (X[j] ^ X[i-1]);
        });
        ret += cs.size();
    }
    std::cout << ret << std::endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef int64_t Int;
const double pi = M_PI;

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

    int a[n][m] = {}, b[m] = {}, c[n] = {};
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            c[i] += a[i][j] * b[j];
        }
    }

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



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

#define rep(i, n) for(int i = 0, i_length = (n); i < i_length; i++)
#define MOD 1000000007

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

	int a, b;
	a = 1;
	b = n;

	if (n % 2 == 1) {
		rep(i, m) {
			cout << a << " " << b << endl;
			a++;
			b--;
		}
	}
	else {
		rep(i, min(n / 4, m)) {
			cout << a << " " << b << endl;
			a++;
			b--;
		}
		b--;
		rep(i, m - n / 4) {
			cout << a << " " << b << endl;
			a++;
			b--;
		}
	}

	return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"

using namespace std;

using ll  =          long long;
using ull = unsigned long long;
const char en='\n';

int main(){
	int a,b;
	cin>>a>>b;
	a+=11;
	a%=13;
	b+=11;
	b%=13;
	if(a>b){
		cout<<"Alice"<<en;
	}else if(a<b){
		cout<<"Bob"<<en;
	}else{
		cout<<"Draw"<<en;
	}
	return 0;
}

Measured memory_bytes: 256