akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll N,D;
    cin>>N>>D;
    ll ans=0;
    for(int i=0;i<N;i++){
        ll X,Y;
        cin>>X>>Y;
        if(X*X+Y*Y<=D*D)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int h,w,m;
	cin>>h>>w>>m;

	vector<int> r(h+1), c(w+1);
	vector<bool> r2(w+1,0);

	vector<pair<int,int>> ps;

	for(int i=1; i<=m; i++)
	{
		int hi,wi;
		cin>>hi>>wi;

		ps.push_back({hi,wi});

		r[hi]++;
		c[wi]++;
	}

	// cout << len(grid) << " " << len(grid[0]) << endl;

	int maxr=0;
	for(int i=1; i<=h; i++)
	{
		maxr=max(maxr,r[i]);
	}
	int maxc=0;
	for(int i=1; i<=w; i++)
	{
		maxc=max(maxc,c[i]);
	}

	vector<bool> rr(h+1),cr(w+1);

	int grs=0;
	int gcs=0;

	for(int i=1; i<=h; i++)
	{
		if(r[i]==maxr)
		{
			rr[i]=1;
			grs++;
		}
	}

	for(int i=1; i<=w; i++)
	{
		if(c[i]==maxc)
		{
			cr[i]=1;
			gcs++;
		}
	}

	ll things = ll(grs)*ll(gcs);

	for(auto p:ps)
	{
		if(rr[p.ff]&&cr[p.ss]) things--;
	}

	cout << maxr+maxc - int(things==0) << endl;
}

Measured memory_bytes: 9796
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007LL

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll k;cin >> k;
	set<ll> s;
	ll ans = 1;
	ll nokori = 7;
	while(true){
		while(nokori < k){
			nokori = nokori * 10 + 7;
			ans++;
		}
		nokori %= k;
		if(nokori == 0)break;
		if(s.find(nokori) != s.end()){
			cout << -1 << endl;
			return 0;
		}
		s.insert(nokori);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 45700
N=list(map(int,input().split()))
x=[]
for i in range(1,(N[0]+1)):
    x.append(i)
even_x=0  
odd_x=0  
for j in range(1,(x[-1]+1)):
    if j/2==int(j/2):
        even_x+=1
    else:
        odd_x+=1
output=odd_x/(odd_x+even_x)
print(output)

Measured memory_bytes: 3064
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
void main()
{
    auto n = lread();
    auto ans = new long[](10 ^^ 5);
    foreach (i; 1 .. 101)
    {
        foreach (j; 1 .. 101)
        {
            foreach (k; 1 .. 101)
            {
                long tmp;
                tmp = i ^^ 2 + j ^^ 2 + k ^^ 2 + i * j + j * k + i * k;
                if (tmp <= 10 ^^ 4)
                {
                    ans[tmp - 1] += 1;
                }

            }
        }
    }
    // writeln(ans);
    foreach (i; 0 .. n)
    {
        writeln(ans[i]);
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 4272
package main

import (
	"fmt"
	"math"
	"strconv"
)

func isInteger(f float64) bool {
	return f == float64(int(f))
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	n, _ := strconv.Atoi(strconv.Itoa(a) + strconv.Itoa(b))
	if isInteger(math.Sqrt(float64(n))) {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{


    int a[3][3], n;
    for(int i=0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            cin >> a[i][j];
    bool ch[3][3];
    mset(ch, false);
    cin >> n;
    for(int i = 0; i < n; i++)
    {

        int x;
        cin >> x;
        for(int i = 0; i < 3; i++)
        {

            for(int j = 0; j < 3; j++)
            {

                if(a[i][j] == x)
                    ch[i][j] = true;
            }
        }
    }
    bool tf = 0;
    for(int i = 0; i < 3; i++)
    {

        if(ch[i][0] == 1 && ch[i][1]==1&&ch[i][2] == 1) tf=1;
    }
    for(int i = 0; i < 3; i++)
    {

        if(ch[0][i] == 1 && ch[1][i]==1&&ch[2][i] == 1) tf=1;
    }
    if(ch[1][1]==1&&ch[2][2]==1 && ch[0][0]==1) tf=1;
    if(ch[2][0]==1&&ch[1][1]==1&&ch[0][2]==1) tf=1;
    if(tf) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vp vector<pi>
#define mp map<ll,ll>
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
int32_t main(){
    fast;
    
     ll n;
     cin>>n;
     
     vi v[n];
     ll a,b,c;
     
     for(ll i=0;i<n;i++)
     {
         cin>>a>>b>>c;
         v[i].pb(a);
         v[i].pb(b);
         v[i].pb(c);
     }
     
     vector<vector<ll>> dp(n, vector<ll> (3,0));
     
     dp[0][0]=v[0][0];
     dp[0][1]=v[0][1];
     dp[0][2]=v[0][2];
     
     for(ll i=1;i<n;i++)
     {
         dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i][0];
         dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i][1];
         dp[i][2]=max(dp[i-1][0],dp[i-1][1])+v[i][2];
         
     }
     
     cout<<*max_element(dp[n-1].begin(),dp[n-1].end());
     
    
    return 0;
    
}

Measured memory_bytes: 12800
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a,sum=0;
        HashMap<Integer,Integer> map = new HashMap<>();
        for(int i=0;i<n;i++){
            a = sc.nextInt();
            if(map.containsKey(a)){
                map.put(a,map.get(a)+1);
            }else{
                map.put(a,1);
            }
        }
        
        for(Map.Entry<Integer,Integer> entry : map.entrySet()){
            sum += entry.getValue()%2;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 62280
from enum import Enum
import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

A,B,DEGREE = map(int,input().split())

rad = math.radians(DEGREE)

S = A*B*math.sin(rad)/2.0
C = math.sqrt(A*A+B*B-2*A*B*math.cos(rad))
h = 2*S/A

print("%.10f %.10f %.10f"%(S,A+B+C,h))


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

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

    string t;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] == 'C' && s[i - 1] == 'B') {
            t.push_back('D');
            i++;
        } else {
            t.push_back(s[i - 1]);
        }
    }

    long long res = 0, cnt = 0;
    for (int i = 0; i < t.size(); i++) {
        if (t[i] == 'B' || t[i] == 'C') {
            cnt = 0;
        } else if (t[i] == 'A') {
            cnt++;
        } else {
            res += cnt;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 776
#include <stdio.h>

int read(int *a)
{
    int h,w;
    scanf("%d %d", &h, &w);
    if(h == 0 && w == 0)
        return 0;
    a[0] = h;   a[1] = w;
    return 1;
}

void printRect(int *a)
{
    int i, j;
    for(i=0;i<a[0];i++) {
        for(j=0;j<a[1];j++)
            putchar('#');
        putchar('\n');
    }
}

int main(void)
{
    int i, idx = 0;
    int data[100][2];

    while(read(data[idx++]) != 0);

    for(i=0;i<idx-1;i++) {
        printRect(data[i]);
        putchar('\n');
    }

    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,a,b,c,d;
    t = 1;
    while(t--) {
     cin >> a >> b >> c >> d;
     if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
      cout << "Yes" << endl;
     else
      cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*

Author : @karngyan
Team : BlundersPride
Date : 02-03-2019
Time : 00:02:04

*/


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 1e5+10;

ll connected;
ll root[N], sz[N];
ll n , m;

void init()
{
	for(ll i=1;i<=n;i++)
	{
		root[i]=i;
		sz[i]=1;
	}
	connected=n;
}

ll rt(ll k)
{
	while(k!=root[k])
	{
		root[k]=root[root[k]];
		k=root[k];
	}
	return k;
}

void merge(ll u, ll v)
{
	ll rt1=rt(u);
	ll rt2=rt(v);

	if(rt1==rt2)
		return;

	connected--;

	if(sz[rt1]>sz[rt2])
		swap(rt1, rt2);

	sz[rt2]+=sz[rt1];
	sz[rt1]=0;
	root[rt1]=root[rt2];
}


vll ans;
vector< pll > q;
signed main()
{
	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	cin >> n >> m;
	init();

	rep(i,0,m)
	{
		ll u , v;
		cin >> u >> v;
		q.pb({u,v});
	}

	reverse(all(q));
	rep(i,0,m)
	{
		ll u = q[i].ff , v = q[i].ss;
		ll x = rt(u), y = rt(v);
		if(x == y)
		{
			ans.pb(0);
			continue;
		}
		ll a = sz[x] ;
		ll b = sz[y] ;
		ll tmp = a*b;
		merge(u,v);
		ans.pb(tmp);
	}

	rrep(i,m-2,-1)
	{
		ans[i] += ans[i+1];
	}
	rrep(i , m-1 , -1)
	{
		cout<<ans[i]<<endl;
	}

	







////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}



Measured memory_bytes: 6256
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, k;
  cin >> n >> m >> k;
  for(int x = 0; x <= n; x++) {
    for(int y = 0; y <= m; y++) {
      int temp = m*x + n*y - 2*x*y;
      if(temp == k) {
        // cerr << x << ' ' << y << endl;
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main(){
  ll n,m;
  cin>>n>>m;
  
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  
  int cnt=0;
  ll x=A[0];
  while(x>0 && x%2==0){
    if(x%2==0) cnt++;
    x/=2;
  }
  
  int a=1;
  rep(i,cnt) a*=2;
  
  bool b=true;
  for(int i=1;i<n;i++){
    if(A[i]%a!=0 || (A[i]/a)%2==0) b=false;
  }
  if(b==false){
    cout<<0<<endl;
    return 0;
  }
  
  vector<ll> B(n);
  rep(i,n) B[i]=A[i]/a;
  
  ll y=1;
  rep(i,n) y=y*B[i]/gcd(y,B[i]);
  y=y*a/2;
  cout<<(m+y)/(2*y)<<endl;

  return 0;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
const int inf = 1001001001;
int A[12][12];
int main() {
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> C(N);
  rep(i,N){
    cin >> C[i];
    rep(j,M) cin >> A[i][j];
    }

    int ans = inf;

    rep(i,1<<N){
      int cost = 0;
      vector<int> skill(M);
      rep(j,N){
        if(i>>j&1){
          cost += C[j];
          rep(k,M) skill[k] += A[j][k];
          }
        }
      bool OK = 1;
      rep(l,M) if(skill[l] < X) OK = 0;
      if(OK) ans = min(ans, cost);
    }

    if(ans == inf){
      cout << -1 << endl;
    }
    else{
      cout << ans << endl;
    }


}


Measured memory_bytes: 3596
n=int(input())
*h,=map(int,input().split())
h=h[::-1]
for i in range(n-1):
    if h[i]>=h[i+1]:
        continue
    else:
        h[i+1] -= 1
        if h[i] >= h[i+1]:
            continue
        else:
            print("No")
            exit(0)
print("Yes")



Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    rep(i, n){
        ll aa;
        cin >> aa;
        a[i+1] += a[i] + aa;
    }
    rep(i, m){
        ll bb;
        cin >> bb;
        b[i+1] += b[i] + bb;
    }
    ll ans = 0;
    rep(i, n+1){
        ll cnt = i;
        if (a[i] > k) continue;
        cnt += upper_bound(b.begin(), b.end(), k - a[i]) - b.begin() - 1;
        ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6400
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define er erase
#define fd find
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i;
ll a[nmax],b[nmax],nr;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n;i++)cin>>b[i];
	for(i=1;i<=n;i++)if(a[i]<b[i])nr+=(b[i]-a[i]+1)/2,a[i]+=((b[i]-a[i]+1)/2)*2;
	for(i=1;i<=n;i++)
	{
		if(b[i]<a[i] && a[i]-b[i]<=nr)nr-=(a[i]-b[i]),b[i]=a[i];
		else if(b[i]<a[i] && a[i]-b[i]>nr)rc("No");
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    int N,A[100];
    cin >> N;
    for(int i = 0;i < N;i++)cin >> A[i];
    sort(A,A+N);
    cout << A[N-1] - A[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair <int,int> pii;
typedef vector <pii> vpii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;

#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back




int main() {
	cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    
    int i,j,k,n,s=0;
    cin>>n>>k;
    vi a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    rep(i,k)s+=a[i];
    cout<<s<<endl;
    
    
    
    
   
   
    
    
   
   
   
   
   
   
	return 0;
}


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

int main()
{
    string s; cin >> s;
    int resp = 0;
    for(int i = 0; i < s.size()/2; i++) {
        if (s[i] != s[s.size()-1-i]) resp++;
    }
    cout << resp;
    return 0;
}

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

int main(){
    int a = 0, b = 0;
    int N = 0, M = 0;
    string s;
   	cin >> a;
  	if(a == 1){
      cout << "Hello World" << endl;
    }
  	else {
 	  int A,B;
      cin >> A;
      cin >> B;
      cout << A+B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 505

#define mod 998244353

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

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

ll bexp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		b >>= 1;
	}
	return res % mod;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	map<ll, ll> mi;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		mi[a[i]]++;
	}
	// cout << mi.size() << "\n";
	int f = 0;
	if(mi.find(0) != mi.end() && mi[0] == n)
	{
		cout << "Yes\n";
		return 0;
	}

	if(n % 3 != 0)
	{
		cout << "No\n";
		return 0;
	}
	vector<ll> al;
	if(mi.size() == 2)
	{
		ll k1 = mi.begin()->ff, l1 = mi.begin()->ss,
		k2 = mi.rbegin()->ff, l2 = mi.rbegin()->ss;
		
		int k = n / 3;
		// for(auto e : mi)
		// {
		// 	if(e.ss == k)
		// 		al.pb(e.ff);
		// 	else
		// 		al.pb(e.ff), al.pb(e.ff);
		// }
		if(l1 == k)
			al.pb(k1), al.pb(k2), al.pb(k2);
		else
			al.pb(k1), al.pb(k1), al.pb(k2);
		// for(auto e : mi)
		// {
		// 	for (int i = 0; i < e.ss/(n/3); ++i)
		// 	{
		// 		al.pb(e.ff);
		// 	}
		// }
		if(al.size() == 3 && (al[0] ^ al[1] ^ al[2]) == 0)
		{
			f = 1;
		}
	}
	else if(mi.size() == 3)
	{
		ll b[3] = {}, i = 0;
		for(auto e : mi)
		{
			b[i++] = e.ff; 
		}

		if(((b[0] ^ b[1]) == b[2]) && (mi[b[0]] == mi[b[1]]) && (mi[b[0]] == mi[b[2]]))
			f = 1;
	}

	if(f)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 5760
keta_count=1
N=int(input())
i=N
while i >=10:
     i=i//10
     keta_count+=1
      
if keta_count==1: 
    count=N
elif keta_count%2==0: 
    x=keta_count/2 
    count=0
    while x > 0:
        count+=9*100**(x-1)
        x-=1
else: 
    x=(keta_count-1)/2 
    count=0
    while x > 0:
        count+=9*100**(x-1)
        x-=1
    count+= N+1-10**(keta_count - 1)

print(str(round(count)))




Measured memory_bytes: 3064
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = 1;
        while (x*2<=n) {
            x *= 2;
        }
        System.out.println(x);
        sc.close();
    }
}

Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m; cin>>n>>m;
    vector <bool> data(89,false);
    vector <int> nums(n,0);
    for(int i=0;i<n;i++){
        nums[i]+=1+i;
       // cout<<nums[i]<<endl;
    }
    for(int i=0;i<m;i++){
        int a,b; cin>>a>>b;
        data[a*10+b]=true;
        data[a+10*b]=true;
    }
    int count=0;
    do{
        
        if(nums[0]==1){
            bool ok=true;
        for(int i=0;i<n-1;i++){
            if(data[nums[i]*10+nums[i+1]]==false) ok=false;
        }
        if(ok) count++;
        }
    }while(next_permutation(nums.begin(),nums.end()));
    cout<<count<<endl;
}

Measured memory_bytes: 256
def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """

    # 10C7 = 10C3
    r = min(r, n-r)

    # Calculate the numerator.
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

N, K = map(int, input().split())
if N==K:
    print(1)
    for i in range(K-1):
        print(0)
else:
    R=N-K
    print(nCr(R+1,1))
    for i in range(2,K+1):
        if R+1>=i:
            C=nCr(R+1,i)
            C *= nCr(K-1,i-1)
            print(C%1000000007)
        else:
            print(0)



Measured memory_bytes: 3316
(function(input) {
  'use strict';
  const INPUT = input.split("\n")
  for(let i = 0; i<INPUT.length; i=i+2){
    if(!INPUT[i] || !INPUT[i+1]) continue
    if (INPUT[i] === 2) {
      console.log('0')
      continue
    }
    const length = INPUT[i]
    const line = INPUT[i+1].split(" ")
    let Max = 0
    let MaxNumFirst = ''
    let SecmaxNumFirst = ''
    let countHashFirst = {}
    for(let j=0; j< length; j=j+2){
      countHashFirst[line[j]]
      ? countHashFirst[line[j]]++
      : countHashFirst[line[j]]=1
      if(countHashFirst[line[j]] >= Max){
        Max = countHashFirst[line[j]]
        if (MaxNumFirst != line[j]) SecmaxNumFirst = MaxNumFirst
        MaxNumFirst = line[j]
      }
    }

    Max = 0
    let MaxNumSecond = ''
    let SecmaxNumSecond = ''
    let countHashSecond = {}
    for(let j=1; j< length; j=j+2){
      countHashSecond[line[j]]
      ? countHashSecond[line[j]]++
      : countHashSecond[line[j]]=1
      if(countHashSecond[line[j]] >= Max){
        Max = countHashSecond[line[j]]
        if (MaxNumSecond != line[j])SecmaxNumSecond = MaxNumSecond
        MaxNumSecond = line[j]
      }
    }

    if(MaxNumFirst==MaxNumSecond) {
      let resA = 0
      let resB = 0
      for(let j=0; j< length; j=j+2){
        if(SecmaxNumFirst != line[j]) resA++
        if(MaxNumSecond != line[j+1]) resA++
      }
      for(let j=0; j< length; j=j+2){
        if(SecmaxNumSecond != line[j+1]) resB++
        if(MaxNumFirst != line[j] ) resB++
      }
      console.log(resA > resB ? resB : resA)
    } else {
      let res = 0
      for(let j=0; j< length; j=j+2){
        if(MaxNumFirst != line[j]) res++
        if(MaxNumSecond != line[j+1]) res++
      }
      console.log(res)
    }
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

using namespace std;

int n, m;
int d[1000];
int c[1000];

int memo[1000][1000];

int rec(int day, int now)
{
	if (now == n) return 0;

	if (memo[day][now] >= 0) return memo[day][now];

	int res;

	if (n - now < m - day) {
		res = min(rec(day + 1, now + 1) + d[now] * c[day], rec(day + 1, now));
	} else {
		res = rec(day + 1, now + 1) + d[now] * c[day];
	}

	return memo[day][now] = res;
}

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

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

	for (int i = 0; i < m; ++i) cin >> c[i];

	memset(memo, -1, sizeof(memo));

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

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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}

int main() { _
  int s, w; cin >> s >> w;
  if (w >= s) cout << "unsafe";
  else cout << "safe";
  return 0;
}

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

int main(void) {
  int N;
  bool flag = false;
  cin >> N;
  
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      int total = i * 4 + j * 7;
      if (total == N) {
        flag = true;
      }
    }
  }
  
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
        
 
  
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n, m;
    cin >> n >> m;
    int number[100200];
    bool checker[100200];
    for(int i = 1; i <= n; i++){
        number[i] = 1;
        checker[i] = false;
    }
    checker[1] = true;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        number[x]--;
        number[y]++;
        if(checker[x]){
            checker[y] = true;
        }
        if(number[x] == 0){
            checker[x] = false;
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(checker[i]){
            ans++;
        }
    }
    cout << ans<< endl;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {
    
    string s; cin >> s;
    int n = s.size();

    int res0 = 0;
    for (int i = 0; i < n; i++) {
        if(i % 2 == 0) {
            if(s[i] != '0') {
                res0 += 1;
            } 
        } else {
            if(s[i] != '1') {
                res0 += 1;
            }
        } 
    }

    int res1 = 0;
    for (int i = 0; i < n; i++) {
        if(i % 2 == 0) {
            if(s[i] != '1') {
                res1 += 1;
            } 
        } else {
            if(s[i] != '0') {
                res1 += 1;
            }
        } 
    }
    
    cout << min(res0, res1) << endl;
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void merge(int a[], int b[], int p, int n);
void msort(int a[], int b[], int p, int n);

int main(){
	//initialization
	int N, K;
	int *h;
	int *work;
	int difference = 1000000000;

	scanf("%d", &N);
	scanf("%d", &K);
	h = (int*)malloc(sizeof(int)*N);

	for (int i = 0; i < N; i++){
		scanf("%d", h+i);
	}

	work = (int*)malloc(sizeof(int)*N);
	memset(work, 0, N);
    
    //sorting array
	msort(h, work, 0, N);
    
    //calculating the minimum difference
	for (int i = 0; i <= N-K; i++){
		if (h[i+K-1]-h[i] < difference){
			difference = h[i+K-1] - h[i];
		}  
	}
    
    printf("%d\n", difference);
}

void merge(int a[], int b[], int p, int n){
	int i, j, k, h;
	h = n/2;
	i = p;
	j = p+h;
    
    for (k = p; k < p+n; k++){
    	if (j == p+n || i < p+h && a[i] <= a[j]){
    		b[k] = a[i++];
    	}else{
    		b[k] = a[j++];
    	}
    }

    for (k = p; k < p+n; k++){
    	a[k] = b[k];
    }
}

void msort(int a[], int b[], int p, int n){
	int h;

	if (n > 1){
		h = n/2;
		msort(a, b, p, h);
		msort(a, b, p+h, n-h);
		merge(a, b, p, n);
	}
	
}

Measured memory_bytes: 896
A,B = map(int,input().split())
count = 0
i = A
while(True):
  s = i % 10
  t = i // 10000 % 10
  u = i // 10 % 10
  v = i // 1000 % 10
  if (s==t and u==v):
    count += 1
  if B==i:
    break
  i += 1
print(count)

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

using namespace std;

typedef long long LL;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"


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

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}


int main(){
    LL N,i=1;
    cin>>N;
    for(;i*(i+1)/2<N;i++);
    LL num=i*(i+1)/2-N;
    FOR(j,1,i+1){
        if(j!=num){
            cout<<j<<endl;
        }
    }
    return 0;
}


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

bool is_prime(int64_t n)
{
  if (n < 2)
    return false;
  if (n == 2)
    return true;
  if (n % 2 == 0)
    return 0;
  for (int i = 3; i <= (int)sqrt(n); i += 2)
  {
    if (n % i == 0)
      return false;
  }
  return true;
}

int main()
{
  int64_t n, ans = 10e12, j, tmp;
  cin >> n;
  if (is_prime(n))
  {
    cout << n - 1 << endl;
    return 0;
  }
  
  for (int i = 1; i <= (int)sqrt(n); i++) {
    if (n % i == 0) j = n / i;
    tmp = i + j - 2;
    if (ans > tmp) ans = tmp;
  }
  cout << ans << endl;
}

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


using namespace std;
int main()
{
	int A, B, C, X;
	int cnt = 0;
	cin >> A >> B >> C >> X;
	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			for (int c = 0; c <= C; c++) {
				int sum = 500 * a + 100 * b + 50 * c;
				if (sum == X) cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		//String text = scan.next();
		int n = scan.nextInt();
		int kazu[][] = new int[n*2][4];
		for(int i = 0 ;i < n*2 ; i++){
			kazu[i][0] = i+1;
		}
		int m = scan.nextInt();
		int k;
		int bunki[][] = new int[2][n/2-1];
		for(int i = 0 ; i < m ; i++){
			k = scan.nextInt();
			if(k == 0){
				for(int j = 0 ; j < n ; j++){
					kazu[j][2] = kazu[j][0];
					kazu[j][3] = kazu[n+j][0];
				}
				for(int j = 0; j < n*2 ; j+=2){
					kazu[j][1] = kazu[j/2][2];
					kazu[j+1][1] = kazu[j/2][3];
				}
				for(int j = 0 ; j < n*2 ; j+=2){
					kazu[j][0] = kazu[j][1];
					kazu[j+1][0] = kazu[j+1][1];
				}
			}else{
				for(int j = 0 ; j < n*2-k ; j++){
					kazu[j][1] = kazu[k+j][0];
				}
				for(int j = 0 ; j < k ; j++){
					kazu[2*n-k+j][1] = kazu[j][0];
				}
				for(int j = 0 ; j < n*2 ; j+=2){
					kazu[j][0] = kazu[j][1];
					kazu[j+1][0] = kazu[j+1][1];
				}
			}
		}
		for(int i = 0 ; i < n*2 ; i++){
			System.out.println(kazu[i][0]);
		}
	}
}

Measured memory_bytes: 30820
dim = [0, 0, 0, 0]

for i in range(3):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    dim[a] += 1
    dim[b] += 1

dim.sort()
if dim == [1, 1, 2, 2]:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

ll factorial[201000];
ll invfactorial[201000];
 
ll extGCD(ll a, ll b, ll &x, ll &y){
	if (b == 0){
		x = 1;
		y = 0;
		return a;
	}
 
	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
 
ll nCrM(ll n, ll r){
	ll ret = factorial[n];
	ret *= invfactorial[n - r];
	ret %= MOD;
	ret *= invfactorial[r];
	ret %= MOD;
	return ret;
}

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


    factorial[0] = 1;
 
	for (int i = 1; i < 201000; i++){
		factorial[i] = (factorial[i - 1] * i) % MOD;
	}
 
	
 
	for (int i = 0; i < 201000; i++){
		ll x, y;
		ll g = extGCD(factorial[i], MOD, x, y);
		while (x < 0) x += MOD;
		x %= MOD;
		invfactorial[i] = x;
	}


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

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

    ll ma = 0;

    for(ll i = 0; i < n; i++){
        if(i + 1 < k) continue;

        ma += a[i] * nCrM(i, k - 1);
        //cout << "I" << i << endl;
        //cout << "ncr" << nCrM(i, k - 1) << endl;
        ma %= MOD;
        
    }

    //cout << ma << endl;

    ll mi = 0;

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

    for(ll i = 0; i < n; i++){
        if(i + 1 < k) continue;

        mi += a[i] * nCrM(i, k - 1);
        //cout << "I" << i << endl;
        //cout << "ncr" << nCrM(i, k - 1) << endl;
        mi %= MOD;
        
    }

    cout << (ma - mi) % MOD  << endl;

}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
const int maxn=512345;
int n,nxt[maxn],pre[maxn];
char s[maxn];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for (int i=2;i<=n;++i) {
        int j=nxt[i-1];
        while (j&&s[i]!=s[j+1])
            j=nxt[j];
        nxt[i]=j+(s[i]==s[j+1]);
    }
    reverse(s+1,s+1+n);
    for (int i=2;i<=n;++i) {
        int j=pre[i-1];
        while (j&&s[i]!=s[j+1])
            j=pre[j];
        pre[i]=j+(s[i]==s[j+1]);
    }
    if (!nxt[n]||n%(n-nxt[n])) return 0*puts("1\n1");
    int res=1;
    for (int i=2;i<n;++i)
        if ((!nxt[i]||i%(i-nxt[i]))&&(!pre[n-i]||(n-i)%(n-i-pre[n-i]))) ++res;
    printf("%d\n%d\n",n/(n-nxt[n])==n?n:2,res);
    return 0;
}


Measured memory_bytes: 8176
li = list(map(int,input().split()))
num = li[0]
money = li[1]

answer = ""

for i in range(num + 1):
  for j in range(num + 1 - i):
    if i*10000 + j*5000 + 1000*(num - (i + j)) == money:
      a = num - (i + j)
      answer = "{} {} {}".format(i, j, a)

if answer == "":
  answer = "-1 -1 -1"

print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
void solve()
{
	ll n;
	cin>>n;
	ll a[n+1];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	
	map<ll,ll>m;
	for(ll i=0;i<n;i++)
	{
		if(m[a[i]]==0)
		m[a[i]]++;
		else
		{
			cout<<"NO";
			return ;
		}
	}
	cout<<"YES";
}
int main()
{
	solve();
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

bool isprime(int x) {
    if (x <= 1) return 0;
    bool ret = 1;
    for (int d = 2; d * d <= x; d++) {
        ret &= (x % d != 0);
    }
    return ret;
}
int main() {
    vector<int> v(100100);
    rep(i, 100099) {
        v[i + 1] = v[i];
        if ((i + 1) % 2 == 1 && isprime(i + 1) && isprime((i + 2) / 2))
            v[i + 1]++;
    }

    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << v[r] - v[l - 1] << endl;
    }
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
coins = list(map(int, input().split()))
coins = sorted(coins, reverse=False)
dp = [[float('inf')] * (n + 1) for _ in range(m)]

for j in range(n+1):
    dp[0][j] = j

for i in range(m-1):
    for j in range(n+1):
        if j - coins[i+1] >= 0:
            dp[i+1][j] = min(dp[i][j],
                             dp[i][j - coins[i+1]] + 1,
                             dp[i+1][j - coins[i+1]] + 1)
        else:
            dp[i+1][j] = dp[i][j]

print(dp[m-1][n])



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

int n, u, v, tdis[100010], adis[100010];
std::vector<int> links[100010], used(1e5, 0);

void dfs(int s, int depth, int dis[]){
        used[s] = 1;
        dis[s] = depth;
        for(int a: links[s]){
                if(!used[a]) dfs(a, depth+1, dis);
        }
        return;
}



int main(){
        scanf("%d %d %d", &n, &u, &v);
        u--; v--;

        for(int i=0; i<n-1; i++){
                int a, b;
                scanf("%d %d", &a, &b);
                links[a-1].push_back(b-1);
                links[b-1].push_back(a-1);
        }


        dfs(u, 0, tdis);
        std::fill(used.begin(), used.end(), 0);
        dfs(v, 0, adis);

        int ans = 0;
        for(int i=0; i<n; i++){
                if(tdis[i]<adis[i]) ans = std::max(ans, adis[i]-1);
        }
        printf("%d\n", ans);
        return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int64_t> a(n);

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  sort(begin(a), end(a));

  int64_t ans(0);
  for (int i = 0; i < n; i++) {
    int64_t t = a[i] - a[n / 2];
    ans += t < 0 ? -t : t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>

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;
    }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}




const int INF = INT_MAX;
struct SegmentTree {
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[2*i+1] + node[2*i+2];
    }



    void add(int x, int val) {
        x += (n-1);
        node[x] += val;
        while(x>0) {
            x = (x-1)/2;
            node[x] = node[2*x+1]+node[2*x+2];
        }
    }
    int getsum(int a,int b,int k = 0, int l = 0,int r = -1) {
        if(r<0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];
        int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};
int main() {
    int n,q;
    cin >> n >> q;
    vector<int>a(n,0);
    SegmentTree seg(a);
    rep(i,q) {
        int c,x,y;
        cin >> c >> x >> y;
        if(c==0) seg.add(x-1,y);
        else cout << seg.getsum(x-1,y) << endl;
    }
}




Measured memory_bytes: 4664
import java.util.*
fun readint()=readLine()!!.toInt()
fun readll()=readLine()!!.toLong()
fun readstring()=readLine()!!
fun readlint()=(readLine()!!.split(" ").map{it.toInt()}).toIntArray()
fun readlll()=(readLine()!!.split(" ").map{it.toLong()}).toLongArray()
fun min(a:Int, b:Int):Int {
    if (a < b) {
        return a;
    }
    else  {
        return b;
    }
}
fun solve() {
    val n = readint();
    var v = readlint().sorted();
    var ans = v[0];
    for (i in 1 until n - 1) {
        if (min(v[i], v[n - 1] - v[i]) > min(ans, v[n - 1] - ans)) {
            ans = v[i];
        }
    }
    println("${v[n-1]} $ans");
}
fun main(args: Array<String>) {
    val t = 1;
    repeat(t) {
        solve();
    }
} 

Measured memory_bytes: 56436
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;

void adder(string&ans,int freq,char x){
    string temp(freq,x);
    ans = ans + temp;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x=0;
    int n;
    cin>>n;
    string s;
    cin>>s;
    vi v;
    v.pb(0);
    for(int i =0;i <s.length();i++){
        if(s[i]=='I'){
            x++;
            v.pb(x);
        }
        else{
            x--;
            v.pb(x);
        }
    }
    cout<<*max_element(all(v))<<endl;










    }




















Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
 
#define f(a,n) for(ll i=a;i<n;i++)
#define fe(a,n) for(ll i=a;i<=n;i++)
#define ain(arr,n) for(ll i1=0;i1<n;i1++ ) cin>>arr[i1]
#define aout(arr,n) for(ll i1=0;i1<n;i1++ ) cout<<arr[i1]
#define ll long long int
#define endl "\n"
#define space " "
#define TLE_na_ho ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MAX_SIZE 400
 
int main() 
{
    TLE_na_ho;
    string s;
    cin>>s;
    int l=3;
    int ans=0;
    f(0,l)
    {
    	if(s[i]=='R')
    		ans++;
    }

    if(s[1]=='S' && ans>1)
    cout<<ans-1;
else
	cout<<ans;

}

Measured memory_bytes: 3588
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int k = scan.nextInt();
		
		Queue<Long> queue = new LinkedList<>();
		for(long i = 1; i <= 9; i++)
			queue.add(i);
		
		for(int i = 0; i < k-1; i++) {
			long x = queue.remove();
			long rear = x%10;
			if(rear != 0) queue.add(10*x + rear-1);
			queue.add(10*x + rear);
			if(rear != 9) queue.add(10*x + rear+1);
		}
		System.out.println(queue.remove());
	}
}


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


int main() {
    int n, k;
    cin >> n >> k;
    int p[n];
    int sum[n+1];
    for(int i=0; i<n; i++)cin >> p[i];
    sum[0] = 0;
    for(int i=0; i<n; i++)sum[i+1] = sum[i]+p[i];
    int max = 0;
    for(int i=0; i<=n-k; i++){
        int val = sum[k+i] - sum[i];
        if (max < val) max = val;
    }
    double ans = ((max + k) / 2.0);
    printf("%.16f", ans);
}


Measured memory_bytes: 1792
def gcd(a,b):
	return a if b==0 else gcd(b,a%b)
	
while 1:
	a1,m1,a2,m2,a3,m3=map(int,raw_input().split())
	if a1==0:break
	x=y=z=1
	x=a1*x%m1
	y=a2*y%m2
	z=a3*z%m3
	cx=cy=cz=1
	while x!=1:
		x=a1*x%m1
		cx+=1
	while y!=1:
		y=a2*y%m2
		cy+=1
	while z!=1:
		z=a3*z%m3
		cz+=1
	lcd=cx*cy/gcd(cx,cy)
	lcd=lcd*cz/gcd(lcd,cz)
	print lcd

Measured memory_bytes: 4232
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    long A;
    double B;

    AtCoder(FastScanner sc) {
        A = sc.nextLong();
        B = sc.nextDouble();
    }

    void solve(PrintWriter out) {
        long b = Math.round(B * 100);
        out.println(A * b / 100);
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 32956