akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var an = new List<int>();
            an.AddRange(Console.ReadLine().Split().Select(s=>int.Parse(s)));
            var colors = new bool[8];
            var asta = 0;
            foreach(var a in an)
            {
                if (a < 400) colors[0] = true;
                else if (a < 800) colors[1] = true;
                else if (a < 1200) colors[2] = true;
                else if (a < 1600) colors[3] = true;
                else if (a < 2000) colors[4] = true;
                else if (a < 2400) colors[5] = true;
                else if (a < 2800) colors[6] = true;
                else if (a < 3200) colors[7] = true;
                else asta++;
            }
            var min = colors.Count(b => b);
            if (min == 0)
            {
                min++;
                asta--;
            }
            Console.WriteLine($"{min} {min + asta}");
        }
    }
}

Measured memory_bytes: 11348
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define ri register int
#define max maxx
#define min minn
using namespace std;
template <class T> void in(T &x) {
	x = 0;
	bool f = 0;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') f = 1;
		c = getchar();
	}
	while ('0' <= c && c <= '9') {
		x = (x << 3) + (x << 1) + (c ^ 48);
		c = getchar();
	}
	if (f) x = -x;
}
inline int maxx(int x,int y) {
	return x>y?x:y;
}
inline int minn(int x,int y) {
	return x<y?x:y;
}
inline int gcd(int x,int y) {return !y?x:gcd(y,x%y);}
int n,m;
int main()
{
	in(n),in(m);
	printf("%d",n-m+1);
	return 0;
 } 


Measured memory_bytes: 256
op = [list(map(int, inp.split())) for inp in open(0)]
n = op[0][0]
m = op[0][1]
list_s = []
list_c = []
for i in range(1, m + 1):
  s = op[i][0]
  c = op[i][1]
  list_s.append(s)
  list_c.append(c)
res = -1
for num in range(10 ** (n - 1), 10 ** n):
  list_ = [int(num_) for num_ in list(str(num))]
  flag = True
  for i in range(m):
    if list_[list_s[i] - 1] == list_c[i]:
      pass
    else:
      flag = False
  if flag:
    res = num
    break
if n == 1:
  flag = True
  for i in range(m):
    if list_s[i] == 1:
      if list_c[i] == 0:
        pass
      else:
        flag = False
    else:
      flag = False
  if flag:
    res = 0
print(res)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        int n = Integer.valueOf(arr01[0]);
        String s = arr02[0];

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            int x = (int) c;

            if (x + n <= 65 + 25) {

                sb.append(String.valueOf((char) (x + n)));
            } else {
                sb.append(String.valueOf((char) (x + n - 26)));
            }
        }

        System.out.println(sb);
    }

}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,count;
    count = 0;
    while (cin >> n) {
        for (int i=9;i>-1;i--) {
            if (n-i>=0) {
                for (int j=9;j>-1;j--) {
                    if (n-i-j>=0) {
                        for (int k=9;k>-1;k--) {
                            if (n-i-j-k>=0) {
                                for (int l=9;l>-1;l--) {
                                    if (n-i-j-k-l==0) {
                                        count++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        cout << count << endl;
        count = 0;
    }
}



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

long long dp[101][100001];

int main(){
    int N,W;
    cin >> N >> W;
    rep(i, N) dp[0][i] = 0;

    for (int i = 1; i <= N; i++) {
        int w, v;
        cin >> w >> v;
        for (int j = 0; j <= W; j++) {
            if (j >= w)
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v);
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 81764
#include<stdio.h>

int main(){
  long d_p, d_m, n_m;
  scanf("%ld %ld %ld", &n_m, &d_m, &d_p);

  long del;

  if(d_p <= d_m + n_m + 1) del = d_p + d_m;
  else del = 2 * d_m + n_m + 1;;

  printf("%ld\n", del);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll ;

ll max(ll a , ll b)
{
  return (a > b) ? a: b;
}
ll min(ll a , ll b)
{
  return (a < b) ? a : b;
}
void memset(ll *arr , int n , ll value)
{
    for(int i= 0; i<n ; i++)
    {
        arr[i] = value;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     int n;
    cin>>n;
    int k;
    cin>>k;
    int *arr = new int[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    ll *dp = new ll[n];
    memset(dp , n ,1e9+5) ;
   /* for(int i= 0; i<k ; i++)
    {
        dp[i] = abs(arr[i] - arr[0]) ;
    }
    for(int i= k; i< n ; i++)
    {
        for(int j=i-1 ; j>=i-k ; j--)
        {
            dp[i] = min(dp[i] , dp[j] + abs(arr[i] - arr[j])) ;
        }
    }*/
    dp[0] = 0;
    for(int i=0 ;i<n ; ++i)
    {
        for(int j = i+1 ; j<=i+k ; ++j)
        {
            if(j < n )
            {
                dp[j] = min(dp[j] , dp[i] + abs(arr[i] - arr[j])) ;
            }
        }
    }
    cout<<dp[n-1] ;
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 a; cin >> a;
    i64 ans = a + a * a + a * a * a;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h> 
using namespace std; 
#define rep(i,k,n)  for (int i = k; i < n; ++i)
typedef long long ll;
const ll bound = 1e18;
int main(void) {
    int n;
    ll result = 1;
    cin >> n;
    bool zero = false;
    vector<ll> vec(n);
    rep(i,0,n) {
        scanf("%lld", &vec[i]);
        if (vec[i] == 0) zero = true;
    }
    if (zero) {
        printf("0");
        return 0;
    }
    rep(i,0,n) {
        if (result > bound / vec[i]) {
            result = -1;
            break;
        }
        result *= vec[i];
    }
    printf("%lld", result);
    return 0;
}


Measured memory_bytes: 4052
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        //String str = sc.next();
        int[] a = new int[N];
        int[] count = new int[9];
        int ans1 = 0;
        int ans2 = 0;
        
        for(int i=0; i<N; i++){
            a[i] = sc.nextInt();
            if(1 <= a[i] && a[i] <= 399){
                count[0] = 1;
            }else if(400 <= a[i] && a[i] <= 799){
                count[1] = 1;
            }else if(800 <= a[i] && a[i] <= 1199){
                count[2] = 1;
            }else if(1200 <= a[i] && a[i] <= 1599){
                count[3] = 1;
            }else if(1600 <= a[i] && a[i] <= 1999){
                count[4] = 1;
            }else if(2000 <= a[i] && a[i] <= 2399){
                count[5] = 1;
            }else if(2400 <= a[i] && a[i] <= 2799){
                count[6] = 1;
            }else if(2800 <= a[i] && a[i] <= 3199){
                count[7] = 1;
            }else{
                count[8]++;
            }
        }
        for(int i=0; i<8; i++){
            ans1 += count[i];
        }
        ans2 = ans1 + count[8];
        if(ans1 == 0){
            ans1 = 1;
        }
        System.out.println(ans1+" "+ans2);
    }
}

Measured memory_bytes: 38848
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main(){
    string st;
    cin>>st;
    long long co=0;
    long long sum=0;
    long long n=st.size();
    for(int tmp=0; tmp<(1<<n-1); tmp++){
        long long sp=0;
        
        rep(i,n-1){
            if(tmp & 1<<i){
                //cout<<atoi(st.substr(sp,i-sp+1).c_str())<<endl;
                sum+=atoll(st.substr(sp,i-sp+1).c_str());
                //cout<<sum<<endl;
                sp=i+1;
            }
            
        }   

        if(sp!=n){
            co++;
            //cout<<"t:"<<atoll(st.substr(sp).c_str())<<endl;
            sum+=atoll(st.substr(sp).c_str());
        }
    }
    //cout<<co<<endl;
    cout<<sum<<endl;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    ll N, K;
    cin >> N >> K;
    PRINT(min(N % K, K - N % K));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <tuple>
#include <utility>
#include <functional>
#include <sys/time.h>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(i, m, n) for(int i = (m); i < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

constexpr int BEAM_SIZE = 900;
constexpr int SZ = 26;
constexpr int D = 365;
array<int, SZ> C;
array<array<int, SZ>, D> S;

struct State {
	array<int, SZ> last = {};
	array<int, D> ans;
	int score = 0;

	void update_score(int d, int t) {
		score += S[d][t];
		rep(i, SZ) score -= C[i] * (d + 1 - last[i]);
	}

	int eval() const {
		return score;
	}

	State place(int d, int t) {
		State res = *this;
		res.ans[d] = t;
		res.last[t] = d + 1;
		res.update_score(d, t);
		return res;
	}

	array<int, D> answer() {
		return ans;
	}
};

array<int, D> solve() {
	State initial_state;
	using f = function<bool(State&, State&)>;
	priority_queue<State, vector<State>, f> cur([](State& a, State& b){return a.eval() > b.eval();});
	cur.push(initial_state);
	priority_queue<State, vector<State>, f> nxt([](State& a, State& b){return a.eval() > b.eval();});
	rep(d, D){
		while(!nxt.empty()) nxt.pop();
		while(!cur.empty()){
			State now = cur.top(); cur.pop();
			rep(t, SZ){
				if(nxt.size() < BEAM_SIZE || now.place(d, t).eval() > nxt.top().eval()) nxt.push(now.place(d, t));
				if(nxt.size() > BEAM_SIZE) nxt.pop();
			}
		}
		swap(cur, nxt);
	}

	State res;
	while(!cur.empty()){
		if(cur.size() == 1) res = cur.top();
		cur.pop();
	}
	cerr << res.eval() << endl;
	return res.answer();
}

int main(void){
	int tmp;
	cin >> tmp;
	rep(i, SZ) cin >> C[i];
	rep(i, D) rep(j, SZ) cin >> S[i][j];

	auto ans = solve();
	for (int i : ans) cout << i + 1 << endl;

	return 0;
}


Measured memory_bytes: 6844
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
#define ll long long
#define rep(i,n) for (i = 0; i < n; ++i) 
#define REP(i,k,n) for (i = k; i <= n; ++i) 
#define REPR(i,k,n) for (i = k; i >= n; --i)
using namespace std;
template<class T, class T1> int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }
template<class T, class T1> int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);
bool prime(ll x)
{
  if(x==1)
    return false;
  if(x==2||x==3||x==5)
    return true;
  for(ll i=2;i<=sqrt(x);i++)
  {
    if(x%i==0)
      return false;
  }
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   //freopen("error.txt", "w", stderr); 
   freopen("output.txt", "w", stdout); 
#endif 
   
 ll T = 1 ;
 //cin>>T;

 for(ll t=0;t<T;t++)
 {
  ll a , b , tm;
  cin>>a>>b>>tm;
  cout<< (tm/a)*b;
 }
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s, t;
	cin >> s;
	cin >> t;

	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def integer_factorization(n):
    prime_count = collections.Counter()
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n //= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1
    return prime_count

def main():
    N, P = LI()
    d = integer_factorization(P)
    ans = 1
    for k, v in d.items():
        if v // N >= 1:
            ans *= k ** (v // N)
    print(ans)

main()



Measured memory_bytes: 78192
#include <iostream>

using namespace std;

int main(){
  int N;
  while(cin >> N){
    int res = 0;
    for(int i=0;i<N;i++){
      int t; cin >> t;
      while(t%2 == 0){ res++; t/=2; }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int K; cin >> K;
    ll sum = 0;

    FOR(i,1,K+1){
        FOR(j,1,K+1){
            FOR(k,1,K+1){
                sum += gcd(gcd(i,j), k);
            }
        }
    }

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

int main(){
  int n,count=0,j=0;
  scanf("%d",&n);
  int data[n];
  for(int i=0;i<n;i++){
     for(j=0;j<2;j++){
      scanf("%d",&data[j]);
    }
    count+=data[j-1]-data[j-2]+1;
  }
  printf("%d",count);
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int a[maxn];
ll sum = 0;
int main()
{
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	ll sum = 0;
	for(int i=1;i<=n-k;i++)sum += a[i];
	cout << sum << endl;
}


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

#define Pi acos(-1.)
#define pb push_back
#define all(x) (x).begin(), x.end()
#define mp make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define FILE "474"
#define standart 1

using namespace std;

typedef long long ll;

const int INF = 1e9 + 322;
const ll LINF = 1e18 + 228;
const int MAXN  = 2e5 + 228;
const int MOD = 1e9 + 7;
const double eps = 1e-14;

int N, C;
int s[MAXN], t[MAXN], c[MAXN];
int cur[MAXN], ans[MAXN];

void solve() {
    cin >> N >> C;
    for(int i = 0; i < N; i++) {
        cin >> s[i] >> t[i] >> c[i];
    }
    for(int i = 1; i <= C; i++) {
        for(int j = 0; j < MAXN; j++) {
            cur[j] = 0;
        }
        for(int j = 0; j < N; j++) {
            if(c[j] == i) {
                cur[s[j]*2-1]++;
                cur[t[j]*2]--;
            }
        }
        for(int j = 1; j < MAXN; j++) {
            cur[j]+=cur[j-1];
        }
        for(int j = 0; j < MAXN; j++) {
            if(cur[j] > 0) {
                ans[j]++;
            }
        }
    }
    int Ans = 0;
    for(int j = 0; j < MAXN; j++) {
        Ans = max(Ans, ans[j]);
    }
    cout << Ans << endl;
}


int main()
{
    if(!standart) {
        freopen(FILE".in", "r", stdin);
        freopen(FILE".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int T = 1;
    while(T--)
        solve();

    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
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;}

const int MAX = 101000;      // 素数判定する最大の数
bool IsPrime[MAX];
vector<int> Era(int n = MAX) {
    vector<int> res;
    IsPrime[0] = false; IsPrime[1] = false;
    for (int i = 2; i < n; ++i) IsPrime[i] = true;
    for (int i = 2; i < n; ++i) {
        if (IsPrime[i]) {
            res.push_back(i);
            for (int j = i*2; j < n; j += i) IsPrime[j] = false;
        }
    }
    return res;
}

int main() {
    auto primes = Era();
    vector<ll> cnt(101000, 0);
    cnt[3] = 1;
    rep(i, 4, 101000) {
        if (i % 2 == 1 && IsPrime[i] && IsPrime[(i+1)/2]) cnt[i] = cnt[i-1] + 1;
        else cnt[i] = cnt[i-1];
    }

    ll q;
    cin >> q;
    rep(i, 0, q) {
        ll l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l-1] << endl;
    }
}

Measured memory_bytes: 1664
#include<stdio.h>
int main()
{
	int n,m,a[10000],i,x;
	scanf("%d %d",&n,&m);
	x=0;
	for(i=0;i<m;i++){
		scanf("%d",&a[i]);
		x+=a[i];
	}
	n=n-x;
	if(n<0) printf("-1\n");
	else printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define itrep(type, it, t) for(type::iterator it=t.begin(); it!=t.end(); it++)
using namespace std;

#define ll long long

int main(void) {

    ll X;
    cin >> X;

    ll ans = (X/500) * 1000;
    ans += ((X - 500*(X/500))/5)*5;
    cout << ans;
    
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] list = new String[n];
        for (int i = 0; i < n; i++) {
            list[i] = sc.next() +  (1100 - sc.nextInt()) + "_" + (i + 1);
        }
        Arrays.sort(list);
        for (String lis : list) {
            String[] li = lis.split("_");
            System.out.println(li[1]);
        }
    }
}


Measured memory_bytes: 20692
#include <iostream>

int main(void){
  int n, h, h_max = 0, count = 0;
  std::cin >> n;
  for(int i=0; i<n; i++){
    std::cin >> h;
    if(h >= h_max){
        h_max = h;
        count++;
    }
  }
  std::cout << count << std::endl;
}

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

int main()
{
    char a[5][6];
    for( int j = 0; j < 6; j++ )
        for( int i = 0; i < 5; i++ )
            a[i][j] = 'a' + i + j * 5;

    a[1][5] = '.';
    a[2][5] = '?';
    a[3][5] = '!';
    a[4][5] = ' ';

    string str;

    while( cin >> str )
    {
        if( str.size() % 2 != 0 )
            cout << "NA" << endl;
        else
        {
            string res = "";
            for( int i = 0; i < str.size() - 1; i += 2 )
            {
                if( 0 < str[i]-'0' && str[i] - '0' <= 6 && 0 < str[i+1]-'0' && str[i+1] - '0' <= 5 )
                    res += a[str[i+1]-'0'-1][str[i]-'0'-1];                                 //配列の添え字注意。列から行を見る。
                else
                {
                    res = "NA";
                    break;
                }
            }
            cout << res << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3024
#include <stdio.h>
#include <string.h>
int main(){
char u[1000];
int i,k;




scanf("%s",u);

k=strlen(u);


for(i=0;i<k;i++){

        if(u[i]=='A'){u[i]=u[i]+23;}
        else if(u[i]=='B')u[i]=u[i]+23;
        else if(u[i]=='C')u[i]=u[i]+23;
       else u[i]=u[i]-3;


    printf("%c",u[i]);
    if(i==k-1)printf("\n");


}





return 0;



}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define in insert
#define pi 3.14159265358979323846
#define rep(i,a,b) for(int i = a ; i < b ; i++)
#define repr(i,a,b) for(int i = b ; i > a ; i--)
  
long long fact(long long a, long long b){
    int r= max(a, b);
    int v= min(a, b);
    int l=1;
    // if(v==0)
    for(int i=r+1; i<=a+b; i++){
        l*=i;
    }
    for(int i=v; i>=2; i--){
        l/=i;
    }
    return l;
}

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

int powr(int a) { 
    int var=1;
    for(int i=0; i<a; i++){
        var*=2;
    }
    return var;
}

signed main(){   
    fast;
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i,0,n){
        cin >> a[i];
        // s.insert({{a[i],1}, a[i]});
    }
    int l = 1 , r = 10000000000;
    while(l+1<r){
        int mid=(l+r)/2, ct=0;
        rep(i,0,n){
            ct+=(a[i]-1)/mid;
        }
        if(ct<=k){
            r=mid;
        }
        else
            l=mid+1;
    }
    int ct=0;
    rep(i,0,n)
        ct += (a[i]-1)/l;
    if(ct<=k) cout << l;
    else cout << r;
}

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

int n,last[200010];
long long ans=0;

int main(){
	scanf("%d",&n);
	int bound=0;
//	memset(last,-1,sizeof(last));
	for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		for(int j=0;j<20;j++){
			if(x&(1<<j)){
				bound=max(bound,last[j]);
				last[j]=i+1;
			}
		}
		ans+=i-bound+1;
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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


class B {
	int n;
public:
	B()
	{
		cin >> n;
	}
	void solve()
	{
		int tmp{ n };
		int sum{ 0 };

		while (tmp)
		{
			sum += tmp % 10;
			tmp /= 10;
		}

		if (!(n % sum))
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+ 5;
const int M = 1e7 + 5;
const int INF=1e9+7;
const int mod=1e9+7;
const double eps=1e-9;
typedef long long ll;
typedef pair<int,int>pi;

vector <ll> solve(vector <ll> a){
    ll n = a.size();
    vector <ll> pref(n+2, 0);
    for(int i = 0; i < n; i++){
        int l = max(0LL,i-a[i]);
        int r = min(n-1LL, i+a[i]);
        pref[l]++;
        pref[r+1]--;
    }
    for(int i = 0; i < n; i++){
        if(i) pref[i] += pref[i-1];
        a[i] = pref[i];
    }
    return a;
}

int check(vector <ll> a){
    int n = a.size();
    for(int i = 0; i < n; i++){
        if(a[i] != n) return 0;
    }
    return 1;
}


int main() {
    int x, y;
    cin >> x >> y;
    int cond = 0;

     for(int i = 0; i <= x; i++){
         int i1 = x-i;
         if(2*i+4*i1 == y) cond = 1;
     }
     if(cond) cout << "Yes";
     else cout << "No";
}

Measured memory_bytes: 3620
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: usize = sc.read();
    let b: usize = sc.read();
    println!("{}", (a * 3 + b) / 2);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
from math import sqrt

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#公約数
A,B = map(int,input().split())
M = gcd(A,B)

if M == 1:
    print(1)
    exit()

res = []
x = M
y = 2
while y*y <= x:
    while x % y == 0:
        res.append(y)
        x //= y
    y += 1
if x > 1:
    res.append(x)

ans = set(res)
print(len(ans)+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int a, b;
    cin >> a >> b;
    cout << a * b - (a + b) + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = 0, b = 0;
        String op = null;
        while(true) {
            a = sc.nextInt();
            op = sc.next();
            b = sc.nextInt();
            switch (op) {
                case "+":
                    System.out.println(a + b);
                    break;
                case "-":
                    System.out.println(a - b);
                    break;
                case "*":
                    System.out.println(a * b);
                    break;
                case "/":
                    System.out.println(a / b);
                    break;
            }
            if(op.equals("?")) break;
        }
    }
}



Measured memory_bytes: 26232
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count4=0;
		int count2 =0;
		for(int i = 0; i<n; i++){
			long a = sc.nextLong();
			if(a%4==0){
				count4++;
			}else if(a%2==0){
				count2++;
			}
		}
		if(count2>1){
			n=n-count2+1;
		}
		if(count4>=n-count4-1){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

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

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

int main()
{
  int N;
  cin >> N;
  vector<long> T(N);
  for (int i = 0; i < N; i++)
    cin >> T[i];
  long ans = 1;
  for (int i = 0; i < N; i++)
  {
    ans = lcm(T[i], ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn gcd(x: i64, y: i64) -> i64 {

    if y == 0 {
        return x;
    }
    if x < 0 {
        return gcd(-x, y);
    }

    if y < 0 {
        return gcd(x, -y);
    }

    if x < y {
        return gcd(y, x);
    }

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



fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = read_vec();
    let mut v1: Vec<i64> = Vec::new();
    v1.push(0);
    let mut v2: Vec<i64> = Vec::new();
    let mut temp = a[0];
    let mut ans = 0;

    for i in 0..n-1 {
        temp = gcd(temp, a[i]);
        v1.push(temp);
    }

    temp = a[n-1];
    for i in (1..n).rev() {
        temp = gcd(temp, a[i]);
        v2.push(temp);
    }
    v2.reverse();
    v2.push(0);

    for i in 0..n {
        if gcd(v1[i], v2[i]) > ans {
            ans = gcd(v1[i], v2[i]);
        }
    }
    println!("{}", ans);
}


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

long long arr[503][503] , N , M; bool nprm[10003];

long long LCM(long long a , long long b){return (__int128)a * b / __gcd(a , b);}

int main(){
	int t = 0; bool flg = 0;
	for(int i = 0 ; i <= 502 ; ++i)
		for(int j = 0 ; j <= 502 ; ++j)
			arr[i][j] = 1;
	for(int i = 2 ; i <= 1e4 ; ++i)
		if(!nprm[i]){
			++t;
			for(int j = 1 ; j <= 501 ; ++j)
				if(2 * t - j > 0 && 2 * t - j <= 501)
					arr[j][2 * t - j] *= i;
			if(t == 501)
				if(!flg){flg = 1; for(int i = 1 ; i <= 501 ; ++i) reverse(arr[i] + 1 , arr[i] + 502); t = 0;}
				else break;
			for(int k = i ; k * i <= 1e4 ; ++k) nprm[i * k] = 1;
		}
	const int dir[4][2] = {0,1,1,0,0,-1,-1,0};
	for(int i = 1 ; i <= 501 ; ++i)
		for(int j = 1 ; j <= 501 ; ++j)
			if((i ^ j) & 1){
				for(int k = 0 ; k < 4 ; ++k)
					arr[i][j] = LCM(arr[i][j] , arr[i + dir[k][0]][j + dir[k][1]]);
              	++arr[i][j]; assert(arr[i][j] <= 1e15);
            }
	cin >> N;
	for(int i = 1 ; i <= N ; ++i) for(int j = 1 ; j <= N ; ++j) cout << arr[i][j] << " \n"[j == N];
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  long long a[M];
  long long cnt=0;
  for(int i=0; i<M; i++) {
    cin >> a[i];
    cnt+=a[i];
  }
  if(N-cnt>=0) {
    cout << N-cnt << endl;
    return 0;
  }
  else {
    cout << "-1" << endl;
    return 0;
  }
}


Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

#include <complex>
typedef complex<int> Point;

const int EPS = 0;

// 外積（クロス積）
double cross( const Point &a, const Point &b )
{
	return a.real() * b.imag() - a.imag() * b.real();
}

// cin >> Point
istream& operator >> ( istream &s, Point &a )
{
	double r, i;
	s >> r >> i;
	a = Point( r, i );
	return s;
}

// CCW 関数　a -> b -> c と進むとき、反時計回りなら -1, 直進なら 0, 時計回りなら 1
int ccw( const Point &a, const Point &b, const Point &c )
{
	if ( cross( ( b - a ), ( c - a ) ) < -EPS )
	{
		return -1;
	}
	else if ( EPS < cross( ( b - a ), ( c - a ) ) )
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

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

	for ( int n; cin >> n, n; )
	{
		VVI segss;
		REP( i, 0, n + 1 )
		{
			int m;
			cin >> m;

			vector<Point> ps( m );
			FOR( p, ps )
			{
				cin >> p;
			}

			VI segs;
			segs.PB( abs( ps[0] - ps[1] ) );
			REP( i, 0, m - 2 )
			{
				segs.PB( ccw( ps[ i + 2 ], ps[ i + 1 ], ps[i] ) );
				segs.PB( abs( ps[ i + 2 ] - ps[ i + 1 ] ) );
			}
			segss.PB( segs );
		}

		VI rev = segss[0];
		REP( i, 0, rev.size() )
		{
			if ( i % 2 )
			{
				rev[i] *= -1;
			}
		}
		reverse( ALL( rev ) );

		REP( i, 1, n + 1 )
		{
			if ( segss[0] == segss[i] || rev == segss[i] )
			{
				cout << i << endl;
			}
		}
		cout << "+++++" << endl;
	}
			

	return 0;
}

Measured memory_bytes: 1272
alf=list(map(int,input().split()))
if(alf[0]!=alf[1] and alf[1]!=alf[2] and alf[0]!=alf[2]):
    print("No")
elif(alf[0]==alf[1] and alf[2]==alf[1] and alf[0]==alf[2]):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
using namespace std;
 
int main(){
  int n, k, i, tmp, ans = 0;
  cin >> n >> k;
  int a[n] = {};
 
  for(i = 0; i < n; i++){
    cin >> tmp;
    a[tmp-1]++;
  }
 
  sort(a, a+n);
 
  for(i = 0; i < n-k; i++){
    ans += a[i];
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
package main
 
import "fmt"
 
func main(){
	var a,b int;
  	
    fmt.Scan(&a,&b);
  for i:=0;i<b;i++{
    var k int;
    fmt.Scan(&k);
  	a=a-k;
  }
  if(a<=0){
  	fmt.Println("Yes");
  }else{
    fmt.Println("No");
  }
  }


Measured memory_bytes: 5504
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
        int B = sc.nextInt();
        
        if((A + B) % 2 == 0) {
			System.out.print((A + B) / 2);
		} else {
			System.out.println((A + B + 1) / 2);
	    }
	}
}


Measured memory_bytes: 23764
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll L;
	cin >> L;
	if (L == 2) {
		cout << "2 2" << endl;
		cout << "1 2 0" << endl;
		cout << "1 2 1" << endl;
		return 0;
	}
	ll max_val = L-1;
	ll max_bit = 0;
	rep(i,0,32) {
		if (max_val & ((ll)1 << i)) {
			max_bit = i;
		}
	}
	struct Edge {
		ll from;
		ll to;
		ll cost;
	};
	vector<Edge> graph;
	ll N = max_bit + 1;
	rep(i,0,N-1) {
		graph.push_back({i, i+1, 0});
		graph.push_back({i, i+1, (ll)1 << (N-2-i)});
	}
	rrep(i,max_bit,0) {
		if ((max_val & ((ll)1 << i)) == 0) {
			continue;
		}
		ll v = max_val - ((((ll)1 << (i+1)) - 1) & max_val);
		graph.push_back({0, N-1-i, v});
	}
	graph.push_back({0, N-1, max_val});
	ll M = graph.size();
	cout << N << " " << M << endl;
	rep(i,0,M) {
		cout << graph[i].from + 1 << " " << graph[i].to + 1 << " " << graph[i].cost << endl;
	}
}



Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Unit = {
    val H, W = sc.nextInt
    val A = Array.fill[Array[Char]](H)(sc.next.toArray)
    for (i <- 0 until H) {
      for (j <- 0 until W) {
        print(if (A(i)(j) == '.') {
          var count = 0
          for (k <- -1 to 1) {
            for (l <- -1 to 1) {
              if (0 <= i + k && i + k < H && 0 <= j + l && j + l < W && A(i + k)(j + l) == '#') {
                count += 1
              }
            }
          }
          count
        } else ('#')
        )
      }
      println
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}


Measured memory_bytes: 27460
#include<stdio.h>

long combi(int,int);

int main(){
  long ans=0;
  int N,P,A,count_e=0,count_o=0;
  scanf("%d%d",&N,&P);
  for (int i = 0; i < N; i++)
  {
    scanf("%d",&A);
    if (A%2==0)
    {
      count_e++;
    }else
    {
      count_o++;
    }
  }

  if (P)
  {
    for (int i = 0; i <= N; i++){
      for (int j = 1; j<=i; j+=2){
          ans+=combi(count_o,j)*combi(count_e,i-j);
      }
    }
  }else{
    for (int i = 0; i <= N; i++){
      for (int j = 0; j <= i; j+=2)
      {
        ans+=combi(count_o,j)*combi(count_e,i-j);
      }
    }
  }

  printf("%ld",ans);
  
  return 0;
}

long combi(int n,int r){ 
  long p=1;

  for (int i=1;i<=r;i++){
    p=p*(n-i+1)/i;
  }
  return p;
}

Measured memory_bytes: 1716
int main(void){
  int N, tmp, flag = 1, count =0;
  scanf("%d", &N);
  int A[N];
  for(int i=0; i<N; i++){scanf("%d", &A[i]);}

  while(flag){
    flag=0;
    for(int j=N-1; j>0; j--){
      if(A[j] < A[j-1]){
        tmp = A[j-1];
        A[j-1] = A[j];
        A[j] = tmp;
        count++;
        flag =1;
      }
    }
  }
  
  for(int k=0; k<N; k++){
    printf("%d",A[k]);
    if(k<N-1) printf(" ");
  }

  printf("\n%d\n", count);
  
  return 0;
}


Measured memory_bytes: 2092
#include<iostream>
 
using namespace std;
 
int main()
{
	int a, sum=0, max=0;;
	cin>>a;
	int s[a];
	for(int i=0; i<a; i++)
	{
		cin>>s[i];
		if(i>0 && s[i]<=s[i-1]) sum++;
		else sum=0;
		if(sum>=max) max=sum;
	}
	cout<<max;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	var max, c int
	for i := 0; i < N; i++ {
		var d int
		fmt.Scan(&d)
		c += d
		if max < d {
			max = d
		}
	}
	if c - max > max {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

int main(){
    int cardNum;
    int gateNum;
    cin >> cardNum;
    cin >> gateNum;


    vector< pair <int,int> > vect;

    for(int i=0; i<gateNum; ++i){
        int left, right;
        cin >> left;
        cin >> right;
        vect.push_back( make_pair(left, right) );
    }

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

    int min = vect[gateNum-1].first;

    sort(vect.begin(), vect.end(), sortbysec);

    int max = vect[0].second;

    if(min>max){
        cout << 0 << endl;
        return 0;
    }

    if(cardNum < min){
        cout << 0 << endl;
    }else if(cardNum >= min && cardNum < max){
        cout << cardNum - min + 1 << endl;
    }else{
        cout << max-min+1 << endl;
    }
    //cout << min << endl;
    //cout << max << endl;
    
    return 0;
}


Measured memory_bytes: 1400
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using ll = long long;
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int ca = 0;
  int cb = 0;
  int cc = 0;
  int cd = 0;
  int n;
  cin >> n;
  vector<string> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec[i];
    if(vec[i] =="AC") {
      ca++;
    } if(vec[i] =="WA") {
      cb++;
    } if(vec[i] =="TLE") {
      cc++;
    } if(vec[i] =="RE") {
      cd++;
    }
  }
  cout << "AC x " << ca << "\n";
  cout << "WA x " << cb << "\n";
  cout << "TLE x " << cc << "\n";
  cout << "RE x " << cd;
  return 0;
}


Measured memory_bytes: 6364
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,x,s=0,l,r;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>l>>r;
        r=l*l+r*r;
        x=sqrt(r*1.0);
        if((x*x)<r)
        {
            x++;
        }
        if(x<=m)
        {
            s++;
        }
    }
    cout<<s<<"\n";
    return 0;
}



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


int main()
{
        ll n;
        cin>>n;
        if(n%2==0)
        {
            cout<<((n/2)*(n/2))<<endl;
        }
        else
        {
            cout<<((n/2)*(n/2+1))<<endl;
        }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x >= r && x <= W-r && y >= r && y <= H-r)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

int main() {
   int n;
   cin >> n;
   vector<string> s(n);
   rep(i, n) {
       cin >> s[i];
   }

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

    int count = 1;
   rep(i, n-1) {
       if (s[i] != s[i+1]) {
           count++;
       }
   }

   cout << count << endl;
}

Measured memory_bytes: 9600
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int h,w;
vector<string>field(h);
bool seen[100][100];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int cnt = 0;

int dfs(int y,int x,int &cnt){
    cnt++;
    seen[y][x] = true;
    rep(i,4){
        int ny = y+dy[i],nx = x+dx[i];
        if(ny<0 || ny>=h || nx<0 || nx>=w)continue;
        if(field[ny][nx] != '#')continue;
        if(seen[ny][nx])continue;
        cnt++;
        dfs(ny,nx,cnt);
    }
    return cnt;
}

int main(){
    string s;cin>>s;
    int cnt1 = 0,cnt2 = 0;
    int n = s.size();
    rep(i,n){
        if(s[i] == '0')cnt1++;
        if(s[i] == '1')cnt2++;
    }
    cout<<n-abs(cnt1-cnt2)<<endl;
}



Measured memory_bytes: 512