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

int main() {
  int n;
  cin >> n;
  ll a[n+4];
  rep(i, n) cin >> a[i];
  sort(a, a+n, greater<int>());
  rep(i, 4) a[n+i] = 0;
  
  ll ans = 1;
  int cnt = 0;
  for (int i = 0; i < n+4; ++i) {
    if (a[i] == a[i+1]) {
      ans *= a[++i];
      ++cnt;
    }
    if (cnt == 2) break;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if((A+B) > (C+D)){
    cout << "Left" << endl;
  }
  else if((A+B) == (C+D)){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
s = [int(i) for i in input()]
for i in range(8):
    a = s[0]
    lst = []
    for j in range(3):
        if i>>j & 1 == 1:
            a += s[j+1]
            lst.append("+")
        else:
            a -= s[j+1]
            lst.append("-")
    if a == 7:
        lst.append("=7")
        break

for i,j in zip(s,lst):
    print(i,j,sep="",end="")
else:
    print("")

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int parse(string str, map<char,pair<int, map<int,int>>>& m) {
  if ('0' <= str[0] && str[0] <= '9') return stoi(str);
  char name = str[0];
  if (m.find(name) == end(m)) return -1;
  int index = parse(str.substr(2), m);
  if (index < 0 || index >= m[name].first ||
    m[name].second.find(index) == end(m[name].second)) return -1;
  return m[name].second[index];
}

void exbug(int& bug, int i) {
  if (bug == 0)
    bug = i;
}

int main() {
  while(1) {
    map<char, pair<int, map<int, int>>> m;
    int bug = 0;
    int i = 0;
    while(1) {
      ++i;
      string line;
      if(!(cin>>line)) break;
      if (line == ".") {
        if (i > 1)
          cout << bug << endl;
        break;
      } else if (line.find("=") == string::npos) {
        int len = stoi(line.substr(2));
        m[line[0]] = make_pair(len, map<int,int>());
      } else {
        if (m.find(line[0]) == end(m)) {
          exbug(bug, i);
        } else {
          int index = parse(line.substr(2), m);
          int val = parse(line.substr(line.find("=") + 1), m);
          if (val < 0) exbug(bug, i);
          else if (index < 0 || index >= m[line[0]].first) exbug(bug, i);
          else m[line[0]].second[index] = val;
        }
      }
    }
    if (i <= 1) break;
  }
  return 0;
}

Measured memory_bytes: 1276
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int N;
ll W;
ll w[110], v[110];
vector<ll> key;
vector<ll> val[4];
int sz;

map<ll, ll> memo;

ll calc(int k, ll rem) {
    if (k == sz) return 0;
    ll idx = rem * 10 + k;
    if (memo.count(idx) == 0) {
        ll res = calc(k+1, rem), sum = 0;
        for (int i = 0; i < val[k].size() && key[k]*(i+1) <= rem; i++) {
            sum += val[k][i];
            res = max(res, sum + calc(k+1, rem - key[k]*(i+1)));
        }
        memo[idx] = res;
    }
    return memo[idx];
}

ll solve() {
    for (int i = 0; i < N; i++) key.push_back(w[i]);
    sort(ALL(key));
    UNIQ(key);
    sz = key.size();
    map<ll, int> m;
    for (int i = 0; i < sz; i++) m[key[i]] = i;
    for (int i = 0; i < N; i++) val[m[w[i]]].push_back(v[i]);
    for (int i = 0; i < sz; i++) sort(RALL(val[i]));

    return calc(0, W);
}

void input() {
    cin >> N >> W;
    for (int i = 0; i < N; i++) cin >> w[i] >> v[i];
}

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

    input();
    cout << solve() << endl;
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N;
    cin >> N;
    Vec<i32 > v(N);
    for (i32 i = 0; i < N; i++) cin >> v[i];
    sort(ALL(v));
    f64 ans = v[0];
    for (i32 i = 1; i < N; i++) {
        ans = (ans + v[i]) / 2.0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3760
while True:
  h, w = map(int, input().split())
  
  if h==0 and w==0:
    break
    
  else:
    for j in range(h):
      for k in range(w):
        if j==0 or j==h-1 or k==0 or k==w-1:
          print('#', end='')
        else:
          print('.', end='')
      print('')
  
  print('')



Measured memory_bytes: 7008
// Hopcroft-Karp Algorithm
// O(|E| * |V|^(1/2))
// http://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm
// aoj 1163

#include <vector>
#include <queue>
#include <iostream>
using namespace std;

int NIL;
const int inf = 1<<29;

typedef vector<int> vi;
typedef vector<vector<int> > Graph;

bool bfs(const Graph &g,vi &dist,const vi &pair,int m) {
    queue<int> q;

    for(int i=0; i<m; ++i)
        if(pair[i] == NIL) {
            dist[i] = 0;
            q.push(i);
        }else
            dist[i] = inf;
    dist[NIL] = inf;

    while(!q.empty()) {
        int v = q.front(); q.pop();
        if(v == NIL) continue;
        for(int i=0; i<g[v].size(); ++i) {
            int u = g[v][i];
            if(dist[pair[u]] == inf) {
                dist[pair[u]] = dist[v]+1;
                q.push(pair[u]);
            }
        }
    }
    return dist[NIL] != inf;
}

bool dfs(int v,const Graph &g,vi &dist,vi &pair) {
    if(v != NIL) {
        for(int i=0; i<g[v].size(); ++i) {
            int u = g[v][i];
            if(dist[pair[u]] == dist[v]+1) {
                if(dfs(pair[u],g,dist,pair)) {
                    pair[u] = v, pair[v] = u;
                    return true;
                }
            }
        }
        dist[v] = inf;
        return false;
    }
    return true;
}

// 0ツつゥツづァm-1ツづ慊づづ個静淞点ツづツつゥツづァn-1ツづ慊づづ個静淞点ツづづ個催妥・ツマツッツチツδ督グツづーツ仰づ淞づゥ
int hopcroft_karp(Graph &graph,int m) {
    const int n = graph.size();
    NIL = n;
    vi pair(n+1, NIL), dist(n+1, 0);
    int ret = 0;
    while(bfs(graph,dist,pair,m)) {
        for(int i=0; i<m; ++i)
            if(pair[i] == NIL)
                if(dfs(i,graph,dist,pair)) ret++;
    }
    return ret;
}

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

int main() {
    ios::sync_with_stdio(false);
    int m,n;
    while(cin>>m>>n, m|n) {
        Graph g(m+n);
        vector<int> b(m), r(n);
        for(int i=0; i<m; ++i) cin>>b[i];
        for(int i=0; i<n; ++i) cin>>r[i];

        for(int i=0; i<m; ++i)
            for(int j=0; j<n; ++j)
                if(gcd(b[i],r[j]) > 1)
                    g[i].push_back(j+m);
        cout<<hopcroft_karp(g,m)<<endl;
    }
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    int sum = 0;
    int k = n;
    while (n > 0){
        int d = n%10;
        sum += d;
        n /= 10;
    }
    if (k % sum == 0) cout << "Yes\n";
    else cout << "No\n";
}

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

    //int t; cin >> t; while (t--)
        solve();
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

int n;
ll a[100100];

int main(){
  cin >> n;
  string ans ="Yes";
  ll x = 0;
  rep(i,0,n){
    cin >> a[i];
    if(a[i]%4==0)x+=2;
    else if(a[i]%2==0)x++;
  }
  // cout << x << endl;
  if(n%2!=0 && x+1 < n)ans="No";
  if(n%2==0 && x < n)ans="No";
  cout << ans << endl;

}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
int dx[8]={0,1,1,1,0,-1,-1,-1};
int dy[8]={1,1,0,-1,-1,-1,0,1};
int main(){
    int H,W;
    cin>>H>>W;
    vector<string> s;
    for(int i=0;i<H;i++){
        string tmp;
        cin>>tmp;
        s.push_back(tmp);
    }
    for(int i=0;i<H;i++){
        string tmp="";
        for(int j=0;j<W;j++){
            if(s[i][j]=='.'){
                int count=0;
                for(int k=0;k<8;k++){
                    int ny=i+dy[k],nx=j+dx[k];
                    if((0<=nx&&nx<W)&&(0<=ny&&ny<H)){
                        if(s[ny][nx]=='#')count++;
                    }
                }
                tmp+=count+'0';
            }
            else {
                tmp+='#';
            }
        }
        cout<<tmp<<endl;
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0, tmp = a[0], cnt = 1;
  for(int i = 0 ; i < n - 1 ; i++){
    if(a[i] == a[i+1]){
      cnt++;
    }else{
      if(cnt < tmp){
        ans += cnt;
      }else if(cnt > tmp){
        ans += (cnt - tmp);
      }
      cnt = 1;
      tmp = a[i+1];
    }
  }
  if(cnt < tmp){
    ans += cnt;
  }else if(cnt > tmp){
    ans += (cnt - tmp);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

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

    long double ans=0;
    for(int i=0;i<n;i++){
        long double x;
        string u;
        cin >> x >> u;

        if(u=="BTC") x*=380000;
        ans+=x;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc[1000];
char ca,cb,cc,cd[1000][1000];
vector<int> va,vb,vc;

vector<int> krk(vector<int> target){
    vector<int> result;
    int repeats=1,number=target[0];
    for(int i=1;i<target.size();i++){
        if(number==target[i])repeats++;
        else{
            number=target[i];
            result.push_back(repeats);
            repeats=1;
        }
    }
    result.push_back(repeats);
    return result;
}

int main(){
    cin>>s;
    for(auto it:s)va.push_back(it);
    vb=krk(va);
    C vb.size()-1 E;
}

Measured memory_bytes: 1912
# そもそも人数分布は一意。
import numpy as np
MOD = 10**9 + 7
N = int(input())
A = np.array([int(x) for x in input().split()])

left = np.arange(N)
right = N-1-left
cnt_1 = np.bincount(np.abs(left-right))
cnt_2 = np.bincount(A)

if cnt_1.shape != cnt_2.shape or (cnt_1 != cnt_2).any():
  answer = 0
else:
  answer = pow(2, N//2, MOD)
  
print(answer)

Measured memory_bytes: 23392
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long A, long long B, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> x, std::vector<long long> y, std::vector<long long> c){
    ll minA=INF, minB=INF, ans2=INF;
    REP(i, A) minA = min(minA, a[i]);
    REP(i, B) minB = min(minB, b[i]);
    REP(i, M){
        ans2 = min(ans2, a[x[i]]+b[y[i]]-c[i]);
    }
    cout<<min(minA+minB, ans2)<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&b[i]);
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&c[i]);
        x[i]--; y[i]--;
    }
    solve(A, B, M, std::move(a), std::move(b), std::move(x), std::move(y), std::move(c));
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int n;
    in(n);
    vector<int> vec(n);
    int ans=0;
    in(vec);
    rep(i,n-1){
        if(vec[i]==i+1&&vec[i+1]==i+2){
            ans++;
            swap(vec[i],vec[i+1]);
        }
    }
    rep(i,n){
        if(vec[i]==i+1)ans++;
    }
    out(ans);
}

Measured memory_bytes: 3788
import Data.List  -- isPrefixOf

table1 = zip (['A'..'Z'] ++ " .,-'?") (binaryStr 5)
binaryStr 0 = [""]
binaryStr n = map ('0':) bs ++ map ('1':) bs
  where  bs = binaryStr (n - 1)

table2 = zip (" ',-.?" ++ ['A'..'Z'])
  (words ("101 000000 000011 10010001 010001 000001 100101 10011010 " ++
          "0101 0001 110 01001 10011011 010000 0111 10011000 " ++
          "0110 00100 10011001 10011110 00101 111 10011111 1000 " ++
          "00110 00111 10011100 10011101 000010 10010010 10010011 10010000"))

encode tbl str = concat $ map (replaceBy tbl) str
replaceBy tbl c = snd . head $ dropWhile ((/= c) . fst) tbl

decode tbl str
  | c == '/'   = []
  | otherwise  = c : decode tbl rest
  where (c,rest) = replacePrefixBy tbl str

replacePrefixBy tbl str = (c, drop (length bin) str)
  where (c,bin) = head $ dropWhile (not . (`isPrefixOf` str) . snd) tbl'
        tbl' = tbl ++ [('/', str)]  -- a sentinel

main = do
  s <- getContents
  putStr . unlines . map (decode table2 . encode table1) . lines $ s

Measured memory_bytes: 4272
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
bool is_prime(ll x){
if(x<=1) return 0;
for(int i=2;i*i<=x;i++){
    if(x%i==0)return 0;
}
return 1;
}
int main(){
ll x;
cin>>x;
while(true){
    if(is_prime(x)){
        cout<< x << "\n";
        return 0;
    }
    x++;
}
return 0;

}



Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int d = Integer.parseInt(sa[1]);
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			x[i] = Integer.parseInt(sa[0]);
			y[i] = Integer.parseInt(sa[1]);
		}
		br.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (Math.hypot(x[i], y[i]) <= d) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 57648
#include <iostream>
#include <vector>

#define MOD 1000000007
using namespace std;

vector <int> prime;
vector <int> num;

 int a[10005];
 int s;


long long int b(long long int a) {
	long long int b = 1;
	for (long long int i = 0; i < prime.size(); i++) {
		long long int k = 0;
		while (a % prime[i] == 0 && k < num[i]) {
			a /= prime[i];
			k++;
		}
		for (int j = 0; j < num[i] - k; j++) {
			b *= prime[i];
			b %= MOD;
		}
	}
	return b;
}

void numcount(long long int a) {
	for (int i = 0;i<s; i++) {
		int k = 0;
		while (a % prime[i] == 0) {
			a /= prime[i];
			k++;
		}
		if (num[i] < k)num[i] = k;
		if (a == 1) return;
	}
	for (int i = s - 1; i < prime.size(); i++) {
		if (prime[i] == a)return;
	}
	prime.push_back(a);
	num.push_back(1);
	return;
}

int main() {
	int n;
	long long int ans = 0;
	cin >> n;
	prime.push_back(2);
	num.push_back(0);
	for (int i = 3; i <= 1000; i += 2) {
		for (int j = 0; j < prime.size(); j++) {
			if (i % prime[j] == 0) break;
			long long int k = prime[j];
			if (k*k>i) {
				prime.push_back(i);
				num.push_back(0);
				break;
			}
		}
	}
	s = prime.size();
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		numcount(a[i]);
	}
	for (int i = 0; i < n; i++) {
		ans += b(a[i]);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

vector<vector<int>> relations;
vector<int> done;
vector<ll> points;

int main() {
  int n, q;
  scanf("%d %d", &n, &q);

  relations = vector<vector<int>>(n + 1);
  done = vector<int>(n + 1);
  points = vector<ll>(n + 1);

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);

    relations[a].push_back(b);
    relations[b].push_back(a);
  }

  for (int i = 0; i < q; i++) {
    int p, x;
    scanf("%d %d", &p, &x);
    points[p] += x;
  }

  queue<int> s;
  s.push(1);

  for (;;) {
    if (s.size() == 0) {
      break;
    }

    int parent = s.front();
    s.pop();

    if (done[parent] == 1) {
      continue;
    }

    done[parent] = 1;

    vector<int> children = relations[parent];

    for (int j = 0; j < children.size(); j++) {
      int child = children[j];

      if (done[child] == 0) {
        points[child] += points[parent];

        s.push(child);
      }
    }
  }

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


Measured memory_bytes: 17124
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 26 Apr 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        st = new StringTokenizer(br.readLine(), " ");
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        int d = Integer.parseInt(st.nextToken());
        br.close();
        for (int i = 0; true; i++) {
            if (i % 2 == 0) {
                c = c-b;
                if (c <= 0) {
                    System.out.println("Yes");
                    break;
                }
            }
            else {
                a = a-d;
                if (a <= 0) {
                    System.out.println("No");
                    break;
                }
            }
        }
    }
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
const int A = 1000005;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> c(A);
	rep(i,n){
		cin >> a[i];
		c[a[i]]++;
	}
	bool pairwise = true;
	for (int i = 2; i < A; i++){
		int cnt = 0;
		for (int j = i; j < A; j += i) {
			cnt += c[j];
		}
		if (cnt > 1) pairwise = false;
	}
	if(pairwise){
		cout << "pairwise coprime" << endl;
		return 0;
	}
	int g = 0;
	rep(i,n) g = __gcd(g,a[i]);
	if (g == 1) {
		cout << "setwise coprime" << endl;
	} else {
		cout << "not coprime" << endl;
	}
}


Measured memory_bytes: 11108
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<numeric>
#include<sstream>
#include<cmath>
using namespace std;
long long int mod = 1e9+7;

int main(){
  int a, b, c; cin >> a >> b >> c;
  if(a > b) swap(a, b);
  if(a <= c && c <= b) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


// EOF


Measured memory_bytes: 256
n,k = map(int,input().split())
if k>(n-1)*(n-2)//2:print(-1)
else:print(str(n*(n-1)//2 - k)+"\n"+"\n".join([str(i)+" "+str(j) for i in range(1,n+1) for j in range(i+1,n+1)][:n*(n-1)//2 - k]))

Measured memory_bytes: 3312
from collections import deque,defaultdict
def gcd(a,b):
    return b if not a%b else gcd(b,a%b)
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
tmp = A[0]
for i in range(1,n):
    tmp = lcm(tmp,A[i])
ans = m//tmp
lis = set()
for i in A:
    r = i
    k=0
    while(r%2==0):
        k+=1
        r//=2
    lis.add(k)
if(m//(tmp)*tmp+tmp//2<=m):
    ans += 1
if(len(lis)!=1):
    ans=0

print(ans)



Measured memory_bytes: 20408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 50;
int main()
{
    std::ios::sync_with_stdio(false);
    int n, x, t;
    cin >> n >> x >> t;
    ll ans = n / x * t;
    if(n % x) ans += t;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int n,a,b;
int main()
{
	cin>>n;
	if(n==1)
	{
		cout<<"Hello World"<<endl; return 0;	
	}
	if(n==2)
	{
		cin>>a>>b;
		cout<<a+b<<endl;
		return 0;
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int A[12] = {0};
	int B[12] = {0};
	int C[12] = {0};
	int borrow[12] = {0};
	int a, b, i, k;

	scanf("%d %d %d", &a, &b, &k);
	for (i = 0; a > 0; i++) {
		A[i] = a % 10;
		a /= 10;
	}
	for (i = 0; b > 0; i++) {
		B[i] = b % 10;
		b /= 10;
	}
	for (i = 0; i < 10; i++) {
		if (A[i] - borrow[i] >= B[i]) {
			C[i] = A[i] - borrow[i] - B[i];
			borrow[i+1] = 0;
		} else {
			C[i] = A[i] - borrow[i] + 10 - B[i];
			borrow[i+1] = 1;
		}
	}
	if (k > 0) {
		for (i = 10; i >= 0; i--) {
			if (borrow[i] == 1) {
				if (C[i] != 9)
					C[i]++;
				k--;
				if (k == 0)
					break;
			}
		}
	}
	a = 0;
	for (i = 10; i>=0; i--) {
		a *= 10;
		a += C[i];
	}
	printf("%d\n", a);
	return 0;
		
}

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

int main(void)
{
    int H, W;
    cin >> H >> W;
    char a[H][W];
    for(int i = 0; i < H; i++){
        for( int j = 0; j < W; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < H+2; i++){
        for( int j = 0; j < W+2; j++){
            if( i == 0 || i == H+1 ) cout << '#';
            else if( j == 0 || j == W+1 ) cout << '#';            
            else if( 0 < j && j < W+1 )     cout << a[i-1][j-1];
        }
        puts("");
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
  
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(int a, int m)
{
    int g = gcd(a, m);
   
    {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
      
             return power(a, m-2, m);
    }
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
//void spf(ll num)
//{
//    fore(i,0,num+1)arr[i]=i;
//    for(ll i=2;i<=num;i+=2)
//    {
//        arr[i]=2;
//    }
//    for(ll i=3;i<=num;i+=2)
//    {
//        if(arr[i]==i)
//        for(ll j=i;j<=num;j+=i)
//        {
//           if(arr[j]==j) arr[j]=i;
//        }
//    }
//}
 
 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll arr[300006][100]={0};
    ll n;cin>>n;
     fore(i,0,n)
    {
        ll x;cin>>x;
        ll b=0;
        while(x)
        {
            arr[i][b]=x%2;
            x/=2;
            b++;
        }
    }
    ll ans[300005]={0};
    ll carry=0;
    fore(i,0,100)
    {
        ll one=0,zero=0;
        for(ll j=0;j<n;j++)
        {
            if(arr[j][i]==0)zero++;
            else one++;
        }
        ll prod=zero*one+carry;
        ans[i]=prod%2;
        carry=prod/2;
    }
    ll dd=0;ll k=1;
    for(ll i=0;i<100;i++)
    {
        dd+=(k*ans[i])%MOD;
        k=(k*2)%MOD;
        dd%=MOD;
    }
    cout<<dd<<endl;
    return 0;
    }


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

int dat[100005];
constexpr int MOD = 1000000007;

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &dat[i]);
	}

	dat[0] = 1;
	for (int i = 1; i < n; i++)
	{
		dat[i] = min(dat[i], dat[i - 1] + 2);
	}

	if (n == 1) printf("1\n");
	else if (n == 2) printf("2\n");
	else
	{
		int ret = 2;
		int cnt = (dat[0] + 1 == dat[1] ? 1 : 0);
		for (int i = 2; i < n; i++)
		{
			ret = ret * 1ll * (i + 1 - (cnt + 1) / 2) % MOD;
			if (dat[i - 1] + 1 == dat[i]) ++cnt;
		}
		printf("%d\n", ret);
	}
}

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

int main() {

	int n,x; float sum=0; cin>>n;
	vector<int>a;
	for(int i=0;i<n;i++) {
		cin>>x; a.push_back(x);
	}
	sort(a.begin(),a.end());  sum=a[0];
	for(int i=1;i<n;i++) {
		sum=(sum+a[i])/2;
	}
	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
S = input()
A = [str(i%2) for i in range(len(S))]
B = [str(1-i%2) for i in range(len(S))]
a = b = 0
for i in range(len(S)):
    if S[i] != A[i]:
        a += 1
    if S[i] != B[i]:
        b += 1

print(min(a, b))

Measured memory_bytes: 15988
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


def naive(N, K, A):
    X = list(A)
    for _ in range(K):
        start = [0] * N
        end = [0] * N
        for i, x in enumerate(X):
            start[(max(0, i - x))] += 1
            end[min(i + x, N - 1)] += 1
        current = 0
        end_flag = True
        for i in range(N):
            current += start[i]
            X[i] = current
            if X[i] != N:
                end_flag = False
            current -= end[i]
        if end_flag:
            return X
    #     if all(x == N for x in X):
    #     print(X,start,end)
    #         return
    return X


def solve(N: int, K: int, A: "List[int]"):
    V = naive(N, K, A)
    print(' '.join(map(str, V)))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)


if __name__ == '__main__':
    main()


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


using namespace std;

int main(void) {

	vector<int> a(3);

	cin >> a[0] >> a[1] >> a[2];

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

	cout << 10 * a[2] + a[1] + a[0];

	return 0;
}


Measured memory_bytes: 256
/*

                                  In the name of Allah, Most Gracious, Most Merciful


*/
#include<bits/stdc++.h>
#include<numeric>
using namespace std;

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********

int main()
{
    IOS;
    float d,t,s;
    cin>>d>>t>>s;

    d *= 1.0;
    t *= 1.0;
    s *= 1.0;

    if(d/s <= t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;



return 0;
}


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

const int MOD = 998244353;

int bin(int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1) res = 1LL * res * a % MOD;
        a = 1LL * a * a % MOD;
        n >>= 1;
    }
    return res;
}

map<string, int> mp;

void add(int &x, ll y) {
    x = (x + y) % MOD;
}

int rec(string s) {
    if (mp.count(s)) return mp[s];
    if (s.length() == 1) {
        return mp[s] = 1 + (s == "1");
    }

    int n = s.length();
    vector<vector<int> > dp(n + 1, vector<int>(2));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        add(dp[i][1], dp[i][0]);
        for (int j = 0; j < 2; j++) {
            if (dp[i][j] == 0) continue;
            for (int k = i; k < n; k++) {
                if (j == 0) {
                    int d = 1;
                    for (int o = i; o <= k; o++) if (s[o] == '1') d = 2LL * d % MOD;
                    add(dp[k + 1][j ^ 1], 1LL * dp[i][j] * d);
                } else {
                    for (int d = 1; d < k - i + 1; d++) if ((k - i + 1) % d == 0) {
                            string t(d, '1');
                            for (int o = i; o <= k; o++) if (s[o] == '0') t[(o - i) % d] = '0';
                            add(dp[k + 1][j ^ 1], 1LL * dp[i][j] * rec(t));
                        }
                }
            }
        }
    }
    /*vector<int> dp(n + 1);
    for (int i = 0; i < n; i++) {
        for (int k = i; k < n; k++) {
            int len = k - i + 1;
            for (int d = 1; d < k - i + 1; d++) {
                if (len % d) continue;
                if (len == )
                string t(d, '1');
                for (int o = i; o <= k; o++) if (s[o] == '0') t[(o - i) % d] = '0';
                add(dp[k + 1], 1LL * dp[i] * bin(rec(t), len / d));
            }
        }
    }*/
    int val = (dp[n][0] + dp[n][1]) % MOD;
    return mp[s] = val;
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    string s;
    while (cin >> s) {
        cout << rec(s) << endl;
    }

    return 0;
}

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



int main() {
	int N;
	cin >> N;
	int A[110];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	bool can = false;

	for (int i = 0; i < N; i++) {
		
		if (A[i] % 2 == 0) {
			if ((A[i] % 3 == 0) || (A[i] % 5 == 0)) {
				can = true;
			}
			else {
				can = false;
					break;
			}
		}
		else can = true;
	}

	if (can) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	

	return 0;
}

Measured memory_bytes: 256
import sys
bbn=1000000007
	
#+++++
		
def main():
	n = int(input())
	ss = input()
	s=ss[:n]
	t=ss[n+1:]
	st=[cs+ct for cs,ct in zip(s,t)]
	ret=''.join(st)
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38512
s = input()
if s == 'SUN':
  print(7)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s == 'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)
elif s == 'SAT':
  print(1)


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main() {
  int num,change,x,y;
  cin>>num;
  cin>>change;
  char c;
  int *now=new int[num+1]; 
  now[0]=0;
  for(int i=1;i<=num;i++) 
    now[i]=i;
  for(int i=0;i<change;i++) {
    cin>>x>>c>>y;
    int tmp=now[x];
    now[x]=now[y];
    now[y]=tmp;
  }
  for(int i=1;i<=num;i++)
    cout<<now[i]<<endl;
  return 0;
}



Measured memory_bytes: 2988
#include<stdio.h>

int main(void){
  int i;
  int n;
  int a,b,c;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d",&a,&b,&c);
    if(a*a==b*b+c*c
       || b*b==c*c+a*a
       || c*c==a*a+b*b){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void){
   int S,h,m,s;
   
   scanf("%d",&S);
   
   h = S / 3600;
   m = (S - h * 3600) / 60;
   s = S % 60;
   
   printf("%d:%d:%d\n",h,m,s);
    
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    int a[3][3],aa[3][3] = {};
    bool flag = false;
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> a[i][j];
        }
    }
    int n,b[10];
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> b[i];
    }
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            for(int k = 0;k < n;k++){
                if(a[i][j] == b[k]){
                    aa[i][j] = 1;
                }
            }
        }
    }
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            if(aa[i][0] && aa[i][1] && aa[i][2]){
                flag = true;
                break;
            }
            if(aa[0][i] && aa[1][i] && aa[2][i]){
                flag = true;
                break;
            }
        }
    }
    if(aa[0][0] && aa[1][1] && aa[2][2]){
        flag = true;
    }
    if(aa[0][2] && aa[1][1] && aa[2][0]){
        flag = true;
    }
    if(flag){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}

template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

bool fun(vi &a,vi &b)
{
    if(a[1]!=b[1])
    {
        return a[1]<b[1];
    }
    return a[2]<b[2];
}

int main()
{
    fast();
    ll n,m,q;
    cin>>n>>m>>q;
    vv a(m+q,vi(2));
    cin>>a;
    for(ll i=0;i<m;i++)
    {
        a[i].pb(-1);
    }
    for(ll i=m;i<m+q;i++)
    {
        a[i].pb(i-m);
    }
    sort(all(a),fun);

    vi count(501,0);
    vi ans(q,0);
    for(ll i=0;i<m+q;i++)
    {
        if(a[i][2]==-1)
        {
            count[a[i][0]]++;
        }
        else
        {
            ll ind=a[i][2];
            for(ll j=a[i][0];j<=a[i][1];j++)
                ans[ind]+=count[j];
        }
    }
    for(ll i=0;i<q;i++)
    {
        cout<<ans[i]<<"\n";
    }
}


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

ll kadomatsu(ll n,ll ar[],ll a,ll b,ll c,ll suma,ll sumb,ll sumc,ll i){

    if(i==n){
        if( !suma || !sumb || !sumc ){ return INT_MAX;}

        return abs(a-suma)+abs(b-sumb)+abs(c-sumc);
    }

    ll o1=kadomatsu(n,ar,a,b,c,suma,sumb,sumc,i+1);
    ll o2=kadomatsu(n,ar,a,b,c,suma+ar[i],sumb,sumc,i+1)+(suma?10:0);
    ll o3=kadomatsu(n,ar,a,b,c,suma,sumb+ar[i],sumc,i+1)+(sumb?10:0);
    ll o4=kadomatsu(n,ar,a,b,c,suma,sumb,sumc+ar[i],i+1)+(sumc?10:0);

    return min(o1, min(o2, min(o3, o4)));
}

int main() {
    
    ll n,a,b,c;
    cin>>n>>a>>b>>c;
    ll ar[n];

    for(ll i=0;i<n;i++){
        cin>>ar[i];
    }

    ll k=kadomatsu(n,ar,a,b,c,0,0,0,0);
    cout<<k<<endl;
	return 0;
}


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

//ABC99C
int main(void) {
  int n, k, i, cou=0, tmp, six[10], nin[10];
  scanf("%d", &n);
  int dp[n+1];
  for(i=0; i<10; i++){
    six[i]=pow(6, i+1), nin[i]=pow(9, i+1);
  }

  for(i=0; i<=n; i++){
    dp[i]=i;
  }
  for(i=1; i<=n; i++){
    k=0;
    while(i-six[k]>=0){
      dp[i]=dp[i]>dp[i-six[k]]+1 ? dp[i-six[k]]+1 : dp[i];
      k++;
    }
    k=0;
    while(i-nin[k]>=0){
      dp[i]=dp[i]>dp[i-nin[k]]+1 ? dp[i-nin[k]]+1 : dp[i];
      k++;
    }
  }
  //for(i=0; i<=n; i++) printf("dp[%d]=%d\n", i, dp[i]);
  printf("%d", dp[n]);
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a<=b){
    cout << "unsafe" << endl;
  }
  else{
    cout << "safe" << endl;
  }
}




Measured memory_bytes: 3636
#include <stdio.h>
#define MAX_N (51)
#define rep(i, n) for(int i = 1; i <= n; i++)

int main(void) {
  int N, M;
  scanf("%d %d", &N, &M);
  int ANS[MAX_N];
  rep(i, N) {
    ANS[i] = 0;
  }
  rep(i, M) {
    int a, b;
    scanf("%d %d", &a, &b);
    ANS[a]++;
    ANS[b]++;
  }

  rep(i, N) {
    printf("%d\n", ANS[i]);
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}
int a[300000];
int b[300000];
signed main(){
    int n;
    cin >> n;
    REP(i,n){
        cin >> a[i] >> b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    if(n%2==0){
        int a1 = a[n/2-1] + a[n/2];
        int b1 = b[n/2-1] + b[n/2];
        int c = b1-a1 + 1;
        cout << c << endl;
    }
    else{
        int a1 = a[n/2];
        int b1 = b[n/2];
        int c = b1-a1 + 1;
        cout << c << endl;
    }

    return 0;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>      
#define pb push_back 
#define fr first 
#define sc second
#define len(s) s.size()
#define MOD 1000000007
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i,a,n) for(int i=a;i<n;i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef map<int,int> mii; 

void solve() {
	
}

int main() {

    /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif  */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    int a,b,c,k;
    cin>>a>>b>>c>>k;
    //while(n--) { solve(); }
    if(k<=a) cout<<k;
    else if(k<=a+b) cout<<a;
    else cout<<2*a+b-k;
    
	return 0 ;
}

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

int main() {
    string s; cin >> s;
    int n = 0;
    int m = 0;
    for(char c : s){
        if(c == 'A' || c == 'C' || c == 'G' || c == 'T'){
            m++;
        }
        else{
            n = max(n,m);
            m = 0;
        }
    }
    n = max(n,m);
    cout << n << endl;
}


Measured memory_bytes: 256
n = int(input())
a_l = list(map(int,input().split()))

boundary = []
for i in range(8):
    boundary.append(400*(i+1))

colors = set()
free_choice = 0
for i in range(n):
    if a_l[i] < boundary[0]:
        colors.add('gray')
    elif boundary[0] <= a_l[i] < boundary[1]:
        colors.add('brown')
    elif boundary[1] <= a_l[i] < boundary[2]:
        colors.add('green')
    elif boundary[2] <= a_l[i] < boundary[3]:
        colors.add('lblue')
    elif boundary[3] <= a_l[i] < boundary[4]:
        colors.add('blue')
    elif boundary[4] <= a_l[i] < boundary[5]:
        colors.add('yellow')
    elif boundary[5] <= a_l[i] < boundary[6]:
        colors.add('orange')
    elif boundary[6] <= a_l[i] < boundary[7]:
        colors.add('red')
    else:
        free_choice += 1

ans = len(colors)
print(max(1,ans), ans+free_choice)

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

using namespace std;
typedef long long ll;

const int N = 200'010;
int a[N];
pair<int, int> d[N], s[N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        d[i] = {i - a[i], i};
        s[i] = {i + a[i], i};
    }
    sort(d, d + n);
    sort(s, s + n);
    ll ans = 0;
    int j = 0, prev = 0;
    for (int i = 0; i < n; i++) {
        while (j < n && s[j].first < d[i].first) j++;
        int res = 0;
        if (i > 0 && d[i].first == d[i - 1].first) res = prev;
        while (j < n && s[j].first == d[i].first && s[j].second < d[i].second) j++, res++;
        prev = res;
        ans += res;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 7616
#include <bits/stdc++.h>
// #include<iostream>
// #include<vector>
// #include<cmath>
// #include<iomanip>
using namespace std;

const double PI= acos(-1.0);

int gcd_func(int a, int b){
    return b? gcd_func(b, a%b) : a;
} 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long x,y; cin >> x >> y;
    long long ns = (y - 2*x)/2;
    if(ns*2 != (y-2*x)){
        cout << "No";
        return 0;
    }
    long long res = ns*4 + (x-ns)*2;
    if(ns < 0 || x - ns < 0){
        cout << "No";
        return 0;
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 3600