akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<algorithm>
using namespace std;
int main()
{
  int edge[12];
  for(int i=0; i<12; i++)cin>>edge[i];
  
  sort(edge,edge+12);
  
  if(edge[0]==edge[3] && edge[4]==edge[7] && edge[8]==edge[11])cout<<"yes"<<endl;
  else cout<<"no"<<endl;
  
  return 0;
}


Measured memory_bytes: 3148
A,B,C=map(int,input().split())
ans=0

L=[A,B,C]
L=sorted(L)
ans+=L[2]-L[1] #この操作によってL[0]の値はL[0]+ans
if (L[2]-L[0]-ans)%2==0:
    ans+=(L[2]-L[0]-ans)//2
else:
    ans+=(L[2]-L[0]-ans)//2
    ans+=2
print(ans)

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

int main() {
    string s; cin >> s;
    int n = s.size() - 1;
    long ans = 0;

    for(int bit=0; bit<(1<<n); bit++){
        long tmp = 0;
        for(int i=0; i<n; i++){
            tmp += s[i] - '0';
            if(bit & (1 << i)){
                ans += tmp;
                tmp = 0;
            }
            tmp *= 10;
        }
        tmp += s[n] - '0';//tmp += s.back() - '0';
        ans += tmp;
    }
    cout << ans << endl;
}

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

static const int N = 1000;

int lcs(string X,string Y){
    int C[N+1][N+1];
    int m = X.size();
    int n = Y.size();
    int maxl = 0;
    
    X = ' ' + X;
    Y = ' ' + Y;
    for(int i=0; i<=m; i++) C[i][0] = 0;
    for(int j=1; j<=n; j++) C[0][j] = 0;
    
    for(int i=1; i<=m; i++){
        for(int j=1; j<=n; j++){
         if(X[i]==Y[j]){
            C[i][j] = C[i-1][j-1] + 1;
         }   else {
             C[i][j] = max(C[i-1][j],C[i][j-1]);
         }
         maxl = max(maxl,C[i][j]);
        }
    }
    return maxl;
}

int main(){
    string s1,s2;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s1 >>s2;
        cout << lcs(s1,s2) << endl;
    }
    return 0;
}




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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int Gcd[201][201];
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    ll ans = 0;
    FOR(i, 1, 200)
        FOR(j, 1, 200)
            Gcd[i][j] = __gcd(i, j);
    cin >> n;
    FOR(i, 1, n)
        FOR(j, 1, n)
            FOR(k, 1, n)
            {
                ans += Gcd[i][Gcd[j][k]];
            }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3804
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m = map(int,readline().split())
chk = []
for i in range(m):
  l,r,c = map(int,readline().split())
  chk.append((l-1,r-1,c))
  
chk.sort()
class SegmentTree:
    def __init__(self, n, ele, segfun):
        self.ide_ele = ele
        self.segfun = segfun
        self.n = n
        self.N0 = 1 << n.bit_length()
        self.data = [self.ide_ele] * (self.N0 * 2)

    def update(self, l, r, val):
        l += self.N0
        r += self.N0
        while l < r:
            if l & 1:
                self.data[l] = self.segfun(self.data[l], val)
                l += 1
            if r & 1:
                self.data[r - 1] = self.segfun(self.data[r - 1], val)
                r -= 1
            l //= 2
            r //= 2

    def query(self, i):
        i += len(self.data) // 2
        ret = self.data[i]
        while i > 0:
            i //= 2
            ret = self.segfun(ret, self.data[i])
        return ret

S = SegmentTree(n,10**14,lambda a,b: min(a,b))
S.update(0,1,0)
for l,r,c in chk:
  a = S.query(l)
  S.update(l,r+1,a+c)
  
ans = S.query(n-1)
if ans == 10**14:
  print(-1)
else:
  print(ans)

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

int main(){
	
	int b,r,g,c,s,t;
	
	while(1){
		cin >> b >> r >> g >> c >> s >> t;
		if(b==0 && r==0 && g==0 && c==0 && s==0 && t==0) break;
		
		int coin=100;
		
		//7ª»ëÁ½
		coin += -3*b + 15*b + b*5*13;
		t -= b + b*5;
		
		//BARª»ëÁ½
		coin += -3*r + 15*r + r*3*13;
		t -= r + r*3;
		
		//ÌÞÄÞ³»°Ý
		coin += -3*g + g*7;
		t -= g;
		
		//ÁªØ°ÎÞ°²
		coin += -3*c + c*2;
		t -= c;
		
		//X^[ij
		coin -= 3*s;
		t -= 2*s;
		
		//óC
		coin -= 3*t;
		
		cout << coin << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

#define CIN_FILE "input.txt"
#define COUT_FILE "output.txt"

#define Pig (OO)

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

const int MAX_Types=40;
const int MAX_a=10;
const int MAX_b=10;
int n,ma,mb;
int a[MAX_Types+10],b[MAX_Types+10],c[MAX_Types+10];
const int MAX_tot_a=MAX_Types*MAX_a;
const int MAX_tot_b=MAX_Types*MAX_b;
int dp[MAX_Types+10][MAX_tot_a+10][MAX_tot_b+10];
const int INF=1000000007;

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n>>ma>>mb;
	
	for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
	
	for(int i=0;i<=MAX_Types;i++)for(int j=0;j<=MAX_tot_a;j++)for(int k=0;k<=MAX_tot_b;k++)dp[i][j][k]=INF;
	
	dp[0][0][0]=0;
	
	for(int i=0;i<n;i++)for(int tot_a=0;tot_a<=MAX_tot_a;tot_a++)for(int tot_b=0;tot_b<=MAX_tot_b;tot_b++)if(dp[i][tot_a][tot_b]!=INF)
	{
		dp[i+1][tot_a][tot_b]=min(dp[i][tot_a][tot_b],dp[i+1][tot_a][tot_b]);
		dp[i+1][tot_a+a[i]][tot_b+b[i]]=min(dp[i+1][tot_a+a[i]][tot_b+b[i]],dp[i][tot_a][tot_b]+c[i]);
	}
	
	int ans=INF;
	
	for(int i=1;i<=MAX_tot_a;i++)for(int j=1;j<=MAX_tot_b;j++)ans=(i*mb==j*ma ? min(ans,dp[n][i][j]) : ans);
	
	cout<<(ans==INF ? -1 : ans);
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 28928
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    ll a; cin>>a;
    vec<ll> m(a+1);
    for(int q=0; q<=a; q++) cin>>m[q];
    vec<ll> n(a);
    for(int q=0; q<a; q++) cin>>n[q];
    ll o =0 ;
    for(int q=0; q<a; q++){
        ll x = min(n[q], m[q]);
        o+=x;
        m[q]-=x;
        n[q]-=x;
        x = min(n[q], m[q+1]);
        o+=x;
        m[q+1]-=x;
        n[q]-=x;
    }
    cout<<o;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b
#define what_is(x) cerr << #x << " is " << x << endl;

using namespace std;

void write();
template <typename T, typename... Args>
void write(T x, Args... args);
template <typename T>
void print_all(vector<T>& a);

void solve() {
    string s;
    cin >> s;
    cout << (s == "AAA" || s == "BBB" ? "No\n" : "Yes\n");
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

void write() { cout << "\n"; }
template <typename T, typename... Args>
void write(T x, Args... args) {
    cout << x << ' ';
    write(args...);
}
template <typename T>
void print_all(vector<T>& a) {
    for (int i = 0; i < a.size(); ++i) cout << a[i] << " \n"[i == a.size() - 1];
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "YES" : "NO" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                set<int> s;
                s.insert(a[i]);
                s.insert(a[j]);
                s.insert(a[k]);
                if(s.size() == 3){
                    if(a[i] + a[j] > a[k] && a[j] + a[k] > a[i] && a[i] + a[k] > a[j] )
                        ans++;
                }
            }
        }
    }
    cout << ans;
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int cnt = 0, ans = 0;
    for (int i = min(a, b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) {
            cnt++;
            if (cnt == k)
                ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
from collections import Counter
def resolve():
    N = ir()
    A = lr()
    sA = [A[i]-i-1 for i in range(N)]
    c = Counter(sA)
    # print(c, sA)
    ans = 0
    for i in range(N):  
        c[sA[i]] -= 1
        c.setdefault(-(A[i]+i+1), 0)
        ans += c[-(A[i]+i+1)]
    print(ans)
resolve()

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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

ll n,a,b;
vector<ll> h;

bool calc(ll m){
  ll c = 0;
  rep(i,n){
    if(h[i] - b * m > 0)
      c += (h[i] - b * m + a - b - 1) / (a - b);
    }
  if(c <= m) return true;
  else return false;
}

int main(){
  cin >> n >> a >> b;
  h.resize(n); rep(i,n) cin >> h[i];

  ll l = 0, r = 1e9 / b, m;

  while(l + 1 < r){
    m = (l + r) / 2;
    if(calc(m)) r = m;
    else l = m;
  }

  while(1){
    if(calc(r)){
      cout << r << endl;
      break;
    }
    r++;
  }
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	int a,b;
	cin >> a >> b;
	if(a <= 8 && b <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
import math
n=int(input())
a = list(map(int,input().split()))
a.sort()
lr=[0]*n
rl=[0]*n

for i in range(n):
  if i==0:
    g=a[0]
    lr[0]=g
  else:
    g=math.gcd(a[i],g)
    lr[i]=g
    
for i in range(n-1,0,-1):
  if n-1==i:
    g=a[n-1]
    rl[n-1]=g
  else:
    g=math.gcd(a[i],g)
    rl[i]=g  
hantei=0
ans=0
#print(lr)
#print(rl)
for i in range(n):
  if i==0:
    hantei=rl[1]
  elif i==n-1:
    hantei=lr[n-2]
  else:
    hantei=math.gcd(lr[i-1],rl[i+1])
  if ans<=hantei:
    ans=hantei
    
print(ans)

Measured memory_bytes: 21100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	double a, b, h, m, pi = acos(-1);
	cin >> a >> b >> h >> m;

	double hrad = (60 * h + m) * pi / 360;
	double mrad = m * pi / 30;

	double d1 = pow((a * cos(hrad) - b * cos(mrad)), 2);
	double d2 = pow((a * sin(hrad) - b * sin(mrad)), 2);
	
	cout << fixed << setprecision(12);
	cout << pow(d1 + d2, 0.5) << endl;

}

Measured memory_bytes: 4292
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

h,w = inm()
s = []
for i in range(h):
    s.append(input())

u = [ ([-1] * w) for i in range(h) ]
d = [ ([ h] * w) for i in range(h) ]
l = [ ([-1] * w) for i in range(h) ]
r = [ ([ w] * w) for i in range(h) ]
for i in range(h):
    ll = -1
    for j in range(w):
        if s[i][j] == '.':
            l[i][j] = ll
        else:
            ll = j
    rr = w
    for j in range(w-1,-1,-1):
        if s[i][j] == '.':
            r[i][j] = rr
        else:
            rr = j

for j in range(w):
    uu = -1
    for i in range(h):
        if s[i][j] == '.':
            u[i][j] = uu
        else:
            uu = i
    dd = h
    for i in range(h-1,-1,-1):
        if s[i][j] == '.':
            d[i][j] = dd
        else:
            dd = i


mx = -1
for i in range(h):
    for j in range(w):
        if s[i][j]=='#':
            continue
        x = d[i][j] - u[i][j] + r[i][j] - l[i][j] - 3
        mx = max(mx,x)

print(mx)


Measured memory_bytes: 179460
#include <bits/stdc++.h>
// A - Frog 1

using namespace std;

int h[100005];
int dp[100005];

int main() {
    int N,i;

    scanf("%d",&N);

    memset(dp,0x3f,sizeof(dp));
    dp[0] = 0;
    for (i = 0;i < N;i++) {
        scanf("%d",&h[i]);
        if (i > 0)
            dp[i] = min(dp[i],dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1)
            dp[i] = min(dp[i],dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    printf("%d\n",dp[N - 1]);

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

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


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
ll n,m,k,ans=0,fact[N];
ll ksm(ll x,ll y)
{
	if(y==0)
	{
		return 1;
	}
	else if(y==1)
	{
		return x;
	}
	ll ret=ksm(x,y>>1);
	ret=(ret*ret)%mod;
	if(y%2)
	{
		return (ret*x)%mod;
	}
	return ret;
}
ll getc(ll x,ll y)//C(x,y)
{
	return (fact[x]*((ksm(fact[y],mod-2)*ksm(fact[x-y],mod-2))%mod))%mod;
}
int main(){
	ll i;
	cin>>n>>m>>k;
	fact[0]=1;
	for(i=1;i<N;i++)
	{
		fact[i]=(fact[i-1]*i)%mod;
	}
	for(i=0;i<=k;i++)
	{
		ans=(ans+(getc(n-1,i)*((m*ksm(m-1,n-i-1))%mod))%mod)%mod;
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5196
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let [a,b,c]=nrin(3)
  out(b>=c?'delicious':a+b-c>=0?'safe':'dangerous')
}
main()


Measured memory_bytes: 9420
let f a=Array.iteri(fun i n->Printf.printf(if i=0 then "%d" else " %d")n)a;print_newline()
let g a n=f a;let rec h j v=if j<0 || a.(j)<=v then a.(j+1)<-v else (a.(j+1)<-a.(j);h(j-1)v)in let rec z i=if i<n then (h(i-1) a.(i);f a;z(i+1))in z 1
let () =let n=read_int()in let a=Array.of_list(List.map int_of_string(Str.split(Str.regexp " ")(read_line())))in g a n

Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int f[100005][2];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie();
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	long long t = 0, s = 0;
	for(int i = 1; i <= n; ++i)
		if (i&1) {
			if (s+a[i] <= 0) {
				t += 1-(s+a[i]);
				s = 1;
			} else s = s + a[i];
		} else {
			if (s+a[i] >= 0) {
				t += s+a[i]+1;
				s = -1;
			} else s = s+a[i];
		}
	long long ans = t;
	s = 0, t = 0;
	for(int i = 1; i <= n; ++i)
		if (!(i&1)) {
			if (s+a[i] <= 0) {
				t += 1-(s+a[i]);
				s = 1;
			} else s = s + a[i];
		} else {
			if (s+a[i] >= 0) {
				t += s+a[i]+1;
				s = -1;
			} else s = s+a[i];
		}
	ans = min(ans, t);
	cout << ans << endl;
}


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

//Compiler version g++ 6.3.0

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,n; cin>>x>>n;
    int a[n];
    unordered_set<int> s;
    for(int i = 0; i < n; i++){
      cin>>a[i];
      s.insert(a[i]);
    }
    int ans = x;
    if(s.find(x)==s.end()){
      cout << x << "\n";
    } else {
      int i = x - 1, j = x + 1;
      while(s.find(i)!=s.end()){
        i--;
      }
      while(s.find(j)!=s.end()){
        j++;
      }
      if(abs(i-x) <= abs(j-x)) cout << i << "\n";
      else cout << j << "\n";
    }
    return 0;
}

Measured memory_bytes: 3640
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
#line 2 "main.cpp"
int main(){
	int x;
	std::cin>>x;
	if(x>=30)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3632
#include <cctype>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <istream>
#include <iterator>
#include <list>
#include <map>
#include <ostream>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#define ll long long
#define PI 3.1415926
using namespace std;
const int maxn=4e4+10;
int main() {
	int n;
	cin>>n;
	int m;
	cin>>m;
	while (m--) {
		int num;
		cin>>num;
		n-=num;
	}
	if (n<0) cout<<-1;
	else cout<<n;
	return 0;
}

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

int main()
{
    int n, q, t, x, d;
    
    cin >> n;

    int c[n], box[n];
    for( int i = 0; i < n; i++ )
    {
        cin >> c[i];
        box[i] = 0;
    }

    cin >> q;

    bool judge = true;
    int res = 0;
    for( int i = 0; i < q; i++ )
    {
        cin >> t >> x >> d;
        //収穫
        if( t == 1 && judge )
        {
            box[x-1] += d;
            if( box[x-1] > c[x-1] )
            {
                res = x;
                judge = false;
            }
        }
        else if( t == 2 && judge )
        {
            box[x-1] -= d;
            if( box[x-1] < 0 )
            {
                res = x;
                judge = false;
            }
        }
        else;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3108
s = input()
K = int(input())

words = []

for i in range(len(s)):
    words.append(s[i:])

words.sort()

ans = set()

for word in words:
    for i in range(len(word)):
        ans.add(word[:i+1])
    if len(ans) >= 5:break
lst = list(ans)
lst.sort()

print(lst[K-1])

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
//constexpr int INF = 1001001001;
constexpr ll INF = 1001001001001001001ll;
constexpr double EPS = 1e-10;
using number = long long;

//くりあがりを考慮して0bitから考える・・・のではなく最上位bitから初めて二分短していく

int main() {
    int N; cin >> N;
    vector<int> a(N), b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];

    int res = 0;
    for (int digit = 29; digit >= 0; --digit) {
        int bekihigh = 1 << (digit + 1), bekilow = 1 << digit;
        rep(i,N) a[i] %= bekihigh, b[i] %= bekihigh;
        sort(all(b));

        ll num = 0;
        rep(i,N) {
            int add = 0;
            if (bekilow - a[i] >= 0) {
                add += lower_bound(all(b), bekihigh - a[i])
                       - lower_bound(all(b), bekilow - a[i]);

            }
            else {
                add += lower_bound(all(b), bekihigh - a[i]) - b.begin();
                add += lower_bound(all(b), bekihigh)
                       - lower_bound(all(b), bekihigh + bekilow - a[i]);
            }
            num += add;
        }
        if (num & 1) res += bekilow;
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc082/tasks/abc082_a
"use strict"
function Main(input) {
  const total = input.split(' ').map(Number).reduce((acc, cur) => acc + cur, 0);
  const ave = Math.ceil(total / 2);
  console.log(ave);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21576
i = list(map(int, input().split()))
#n = sorted(i)
#print('{} {} {}'.format(n[0], n[1], n[2]))
n = [0] * 3
if i[0] > i[1]:
    n[1] = i[0]
    n[0] = i[1]
else:
    n[0] = i[0]
    n[1] = i[1]

if n[1] > i[2]:
    n[2] = n[1]
    n[1] = i[2]
else:
    n[1] = n[1]
    n[2] = i[2]

if n[0] > n[1]:
    t = n[0]
    n[0] = n[1]
    n[1] = t

print('{} {} {}'.format(n[0], n[1], n[2]))



Measured memory_bytes: 5600
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <math.h>

using namespace std;


int main() {
	long N, *a;
	cin >> N;
	a = new long[N];

	long M = 0;
	bool *odd = new bool[N];
	bool *bt1 = new bool[N];

	for (int i = 0; i < N; i++) {
		cin >> a[i];
		M += a[i] / 2;
		odd[i] = (a[i] % 2 == 1);
		bt1[i] = (a[i] > 1);
	}
	bool flag = false;
	for (int i = 0; i < N; i++) {
		if (odd[i]) {
			if (flag) {
				M++;
				flag = false;
			}
			else {
				flag = true;
			}
		}
		else if (flag) {
			if (bt1[i] == false) {
				flag = false;
			}
		}
	}

	cout << M;

	return 0;
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
/*unsigned long*/ int a[1001] = {};

int soinsuubunkai(int in);

void kaijo(int in) {
	int i;
	for (; in > 1; in--) {
		soinsuubunkai(in);
	}
}

int soinsuubunkai(int in) {
	int i, ans = 1;
	while (in > 1) {
		//printf("%d\n", in);
		for (i = 2; i <= 1000; i++) {
			if (in%i == 0) {
				in /= i;
				a[i]++;
				break;
			}
		}
	}
	return ans;
}

int main() {
	int in;
	unsigned long long int ans = 1;
	scanf("%d", &in);
	kaijo(in);
	for (int i = 2; i <= 1000; i++) {
		if (a[i] > 0) {
			ans *= (a[i] + 1);
			ans = ans % 1000000007;
		}
	}
	std::cout << ans;
	return 0;
}

Measured memory_bytes: 256
n = input()
s = list(input())
res = 0
for i in range(1, len(s)):
    tmp = 0
    x = s[:i]
    y = s[i:]
    mita = []
    for k in x:
        if k in y and k not in mita:
            tmp += 1
        mita.append(k)
    res = max([res, tmp])
print(res)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(A);
    scanInt(B);
    scanInt(C);
    if (A <= C && C <= B){
        puts("Yes");
    }else{
        puts("No");
    }
}


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

int main() {
    int n, y;
    while (cin >> n, n) {
        cin >> y;
        int b, r, t, res;
        double mx = 0;
        for (int i=0; i<n; ++i) {
            cin >> b >> r >> t;
            if (t == 1) {
                double interest = 10000.0 * (1 + y * r / 100.0);
                if (mx < interest) {
                    mx = interest;
                    res = b;
                }
            } else {
                double interest = 10000.0 * pow(1 + r / 100.0, y);
                if (mx < interest) {
                    mx = interest;
                    res = b;
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
   int n;
   cin>>n;
   int a[202];
   rep(i,0,n)cin>>a[i];
   
   bool can=true;
   int cnt = 0;
   while(can){
       rep(i,0,n){
           if(a[i]%2==0)a[i]/=2;
           else can=false;
       }
       if(can) cnt++;
   }
   cout<<cnt<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define SET(A,VAL) memset(A, VAL, sizeof(A))
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
const int MAX = 1e6+8;
const int sz = 1e5+5;
void f_io(){
    IOS;

}
int32_t main(){
    f_io();
    int t = 1;
    //cin>>t;
    while(t--){
        int a,b,c,d; cin>>a>>b>>c>>d;
        cout<<max(a*b,c*d)<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	char s[500005];

	scanf("%s", s);
	int len = strlen(s);

	vector<pair<int,bool>> items;

	for(int i = 0; i < len; i++) {
		bool up = s[i] == '<';
		if(items.empty() || items.back().second != up) {
			items.push_back({0, up});
		}
		items.back().first += 1;
	}

	i64 ans = 0;
	i64 prev = 0;

	for(auto& x : items) {

		i64 l = x.first;
		bool up = x.second;

		ans += l * (l + 1) / 2;

		if(!up) {
			ans -= min(prev, l);
		}

		prev = l;
	}

	printf("%lld\n", ans);

	return 0;
}

/* waffle */


Measured memory_bytes: 2932
#include <vector>
#include <cstdint>
#include <bits/stdc++.h>

using namespace std;

struct Doubling{
  vector<vector<int>>table;
  int log;
  int sz;
  //sz:要素数 lim:最大の数
  Doubling(int sz,int64_t lim):sz(sz),log(64-__builtin_clzll(lim)){
    table.resize(sz,vector<int>(log,-1));
  }
  void set_next(int now,int next){
    table[now][0]=next;
  }
  void build(){
    for(int j=0;j<log-1;j++){
      for(int i=0;i<sz;i++){
        if(table[i][j]==-1)table[i][j+1]=-1;
        else table[i][j+1]=table[table[i][j]][j]; //iの2^j先の2^j先->iの2^(j+1)先
      }
    }
  }
};

struct DLCA{
  int r;
  vector<int>par;
  vector<int>dep;
  vector<vector<int>>g;
  Doubling*d;
  DLCA(vector<vector<int>>g,int r):g(g),r(r){
    int N=g.size();
    par.resize(N,0);
    dep.resize(N,0);
    d=new Doubling(N,N);
    dfs(r,-1,0);
    for(int i=0;i<N;i++)d->set_next(i,par[i]);
    d->build();
  }
  void dfs(int x,int p,int val){
    par[x]=p;
    dep[x]=val;
    for(auto it:g[x]){
      if(it!=p)dfs(it,x,val+1);
    }
  }
  int query(int x,int y){
    if(dep[x]<dep[y])swap(x,y);
    for(int i=d->log-1;i>=0;i--){
      if(((dep[x]-dep[y])>>i)&1)x=d->table[x][i];
    }
    if(x==y)return x;
    for(int i=d->log-1;i>=0;i--){
      if(d->table[x][i]!=d->table[y][i]){
        x=d->table[x][i];
        y=d->table[y][i];
      }
    }
    return d->table[x][0];
  }
};

#include <bits/stdc++.h>

int main(){
  int n;
  cin>>n;
  vector<vector<int>>g(n);
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int c;
      cin>>c;
      g[i].push_back(c);
    }
  }
  int q;
  cin>>q;
  vector<int>u(q),v(q);
  for(int i=0;i<q;i++)cin>>u[i]>>v[i];
  DLCA d(g,0);
  for(int i=0;i<q;i++)cout<<d.query(u[i],v[i])<<endl;
}

/*
struct DLCA{
  int LOG;
  vector<int>dep;
  vector<vector<int>>g;
  vector<vector<int>>table;

  DLCA(vector<vector<int>>&g):g(g),dep(g.size()),LOG(32-__builtin_clz(g.size())){
    table.assign(LOG,vector<int>(g.size(),-1));
  }

  //全ての葉の親をtable[0]に記録
  void dfs(int idx,int par,int d){
    //idxの一つ上の親
    table[0][idx]=par;
    //根からの距離
    dep[idx]=d;
    for(auto to:g[idx]){
      if(to!=par)dfs(to,idx,d+1);
    }
  }

  void build(){
    dfs(0,-1,0);
    //LOG=floor(log(g.size()));
    //ダブリング
    for(int k=0;k+1<LOG;k++){
      for(int i=0;i<table[k].size();i++){
        if(table[k][i]==-1)table[k+1][i]=-1;
        else table[k+1][i]=table[k][table[k][i]];
      }
    }
  }

  int query(int u,int v){
    //深さを揃える
    if(dep[u]>dep[v])swap(u,v);
    for(int i=LOG-1;i>=0;i--){
      if(((dep[v]-dep[u])>>i)&1)v=table[i][v];
    }
    if(u==v)return u;
    //同じになるまでちょっとずつ近づく
    for(int i=LOG-1;i>=0;i--){
      if(table[i][u]!=table[i][v]){
        u=table[i][u];
        v=table[i][v];
      }
    }
    return table[0][u];
  }

};
*/



Measured memory_bytes: 34036
#include<stdio.h>

#define	LIM		(100000+1)
#define MIN(NUM,NUM2)	((((long)NUM)<((long)NUM2))?(NUM):(NUM2))
#define	ABS(NUM)		(((NUM)>0)?(NUM):(-1*(NUM)))

int main(void)
{
  long n, a[LIM]={}, ans=0;
  int i;
  long min = 0x7FFFFFFF;
  int under_zero = 0;
  
  scanf("%ld", &n);

  for(i=0; i<n; i++){
	scanf("%ld", &a[i]);
    ans += ABS(a[i]);
    min = MIN(min, ABS(a[i]));
    if(a[i]<0)under_zero++;
  }
  
  if(under_zero&(int)0x01)
    ans -= min<<= 1;
    
  printf("%ld\n", ans);
  
  return 0;
}


Measured memory_bytes: 896
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int n = sc.nextInt();
            int a=0;
            int b[]=new int[n+1];
            if(n < 2){
                System.out.println("0");
            }else{
            	for(int i=2;i<=n;i++){
            		if (b[i]==0){
            		  for(int j=i*2; j<=n; j = j+i){
            			  b[j]=1;
            		   }
            		  }        
                  	}
                   for(int i=2; i<=n; i++){
                     if(b[i]==0)a++;
                  
                   }
                   System.out.println(a);
            }
         }
			
    }
}

Measured memory_bytes: 54180
#include <bits/stdc++.h>
using namespace std;
#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 repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define loop(i,a,B) for (int i = a; i B; i++)
#define loopR(i,a,B) for (int i = a; i B; i--)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", my_dmp(#__VA_ARGS__, __VA_ARGS__)
void my_dmp(const char*) { cerr << endl; }
template <class T, class... U> void my_dmp(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; my_dmp(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
using ld = long double;
#define int ll
#define double ld
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
template <class T, class = typename T::iterator, class = typename enable_if<!is_same<T, string>::value>::type>
ostream& operator<<(ostream& os, T const& v) { os << "{"; for (auto const& x : v) os << " " << x; return os << " }"; }
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S>& p) { return is >> p.first >> p.second; }
struct my_Init { my_Init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } my_init;

template <class T, size_t d, class = typename enable_if<(d == 0)>::type> constexpr auto make_v(T const& x = {}) { return x; }
template <class T, size_t d, class... U, class = typename enable_if<(d > 0)>::type> constexpr auto make_v(size_t n, U... x) { auto val = make_v<T,d-1>(x...); return vector<decltype(val)>(n, move(val)); }
template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> constexpr bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> constexpr bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> constexpr auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
const ll INF = (1LL<<62)-1; // ~ 4.6e18
////////////////////////////////

int32_t main() {
    int n,k; cin >> n >> k;
    vector<int> a(n); cin >> a;

    vector<int> dp(k+1);
    rep (i,k+1) {
        rep (j,n) {
            if (i-a[j] >= 0 && dp[i-a[j]] == 0) dp[i] = 1;
        }
    }
    cout << (dp[k] ? "First" : "Second") << endl;
}


Measured memory_bytes: 1024
n = int(input())
m = len(list(str(n)))
ans = 0
count = 0
c = 1
for i in range(m-1):
    if i == 0:
        count += 1
    else:
        count += c
        c *= 10
#print(count)
k = n//(10**(m-1))
a = n%10
ans += (count+c)*(count+c)*(k-1)
#print(ans)
ans += (count)*(count)*(9-k)
#print(ans)
count += (n-k*(10**(m-1)))//10+1
if a < k:
    count -= 1
ans += (count)*(count)
#print(ans)
c = 1
count = 0
for i in range(1,m-1):
    count += c
    c *= 10
#print(count,c)
if k < 9:
    ans += count*count*(9-k)*(8-k)
if k > 1:
    ans += (count+c)*(count+c)*(k-1)*(k-2)
ans += (count+c)*(count)*(k-1)*(9-k)*2
for i in range(1,a+1):
    if i < k:
        ans += (count+c)*(count+1+(n-k*(10**(m-1)))//10)*2
    elif i > k:
        ans += count*(count+1+(n-k*(10**(m-1)))//10)*2
for i in range(a+1,10):
    if i < k:
        ans += (count+c)*(count+(n-k*(10**(m-1)))//10)*2
    elif i > k:
        ans += count*(count+(n-k*(10**(m-1)))//10)*2
print(ans)

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

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

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) {
    return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";
}

template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

template <typename A>
string to_string(A x[], signed n) {
    string result = "{";
    for (signed i=0; i<n; ++i) {
        if (i!=0) result += ", ";
        result += to_string(x[i]); 
    }
    return result + "}";
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    int a[n], b[n+1] = {};
    REP(i, n) {
        cin >> a[i];
        b[i+1] = b[i] + a[i];
    }
    map<int,int> occ;
    int result = 0;
    REP(i, n+1) {
        result += occ[b[i]]++;
    }
    cout << result;
}

Measured memory_bytes: 15872
// AOJ DSL_1 A Set - Disjoint Set: Union Find Tree
// 2017.10.31 bal4u@uu

#include <stdio.h>

#define MAX 10002
/* UNION-FIND library */
int p[MAX], rank[MAX];
void make_set(int x) { p[x] = x, rank[x] = 0; }
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

int main()
{
	int n, q, i;
	int cmd, x, y;

	scanf("%d%d", &n, &q);
	for (i = 1; i <= n; i++) make_set(i);
	for (i = 0; i < q; i++) {
		scanf("%d%d%d", &cmd, &x, &y);
		if (cmd == 0) union_set(x, y);
		else printf("%d\n", find_set(x) == find_set(y));
	}
	return 0;
}

Measured memory_bytes: 1916
import Foundation

let abc = readLine()!.split(separator: " ").compactMap { Int($0) }
let a = abc[0]
let b = abc[1]
let c = abc[2]
var bb:Int
var cc:Int
let k = Int(readLine()!)!
var tf = true
for i in 0...k{
  bb = b
  cc = c
  cc *= Int(pow(Double(2),Double(i)))
  bb *= Int(pow(Double(2),Double((k-i))))
  if cc>bb && bb>a{
    tf = false
    print("Yes")
    break
  }
}
if tf{
  print("No")
}

Measured memory_bytes: 13704
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 1000 == 0) {
			System.out.println(0);
		} else {
			System.out.println(1000 - n % 1000);
		}
	}
}


Measured memory_bytes: 35652
import collections

h, w = map(int, input().split())
s = []
count = 0
s.append("#" * (w + 2))
for i in range(h):
    temp = input()
    count += temp.count(".")
    s.append("#" + temp + "#")
s.append("#" * (w + 2))
dis = [[float("inf") for i in range(w + 2)] for i in range(h + 2)]
dis[1][1] = 0
p = collections.deque([[1, 1]])
d = [[-1, 0], [1, 0], [0, -1], [0, 1]]
while p:
    temp = p.popleft()
    x, y = temp[0], temp[1]
    for i in d:
        dx, dy = i[0], i[1]
        if s[y + dy][x + dx] == "#":
            continue
        else:
            if dis[y][x] + 1 < dis[y + dy][x + dx]:
                dis[y + dy][x + dx] = dis[y][x] + 1
                p.append([x + dx, y + dy])
if dis[h][w] == float("inf"):
    print(-1)
else:
    print(count - dis[h][w] - 1)

Measured memory_bytes: 9432
import itertools
n=int(input())
a=list(map(int, input().split())) 

b=itertools.accumulate(a)
b=list(b)
x=float('inf')
for i in range(n):
    x=min(abs(b[i]-(b[-1]-b[i])),x)

print(x)    


    
    
    
    

Measured memory_bytes: 25768
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int test[213456], ng[213456];
int ok[213456][2];
int keta(int x) {
	int res = 0;
	while(x >= 1) {
		x /= 10; res++;
	}return res;
}
signed main() {
	int n, m, a, sum = 0, ans = 0; string s; cin >> s;
	for (int h = 0; h < s.size(); h++) {
		if (s[h] == 'A' || s[h] == 'C' || s[h] == 'G' || s[h] == 'T') { sum++; }
		else { ans = max(ans, sum); sum = 0; }
	}
	ans = max(ans, sum);
	cout << ans << endl;
	cin >> n;
	return 0;
}

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

using namespace std;

long long sad(vector<long long> a, long long b) {
	long long ret = 0;
	for (size_t i = 0; i < a.size(); i++) {
		ret += abs((long long)(a[i] - b));
	}
	return ret;
}

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

	vector<long long> a(n);
	for (auto& e : a) cin >> e;

	for (size_t i = 0; i < a.size(); i++) {
		a[i] -= (i + 1);
	}

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

	long long b = a[n / 2];
	cout << sad(a, b) << endl;
	return 0;
}



Measured memory_bytes: 3328