akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String args[]) throws InterruptedException {
		    Scanner sc = new Scanner(System.in);	
			
			int n = sc.nextInt();
			if (n == 3) {
				System.out.println("YES");
			}else if (n == 5) {
				System.out.println("YES");
			}else if (n == 7){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}

		    sc.close(); }

	public static boolean isEven(int n ) {
		if (n % 2 == 0) {
			return true;
		}else{
			return false;
		}
	}
}

Measured memory_bytes: 21844
a, b = map(int, input().split())
if a >= b:
    print(0)
else:
    c = list(map(int, input().split()))
    c.sort()
    d = []
    for i in range(1, b):
        d.append([abs(c[i] - c[i-1]), i])
    d = sorted(d, key=lambda x: x[0], reverse=True)
    e = []
    for i in range(a-1):
        e.append(d[i])
    e.sort()
    f = []
    for i in range(len(e)):
        f.append(c[e[i][1]])
        f.append(c[e[i][1]-1])
    f.append(c[0])
    f.append(c[len(c)-1])
    f.sort()
    g = 0
    for i in range(1, len(f), 2):
        g += f[i] - f[i-1]
    print(g)


Measured memory_bytes: 22568
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  int V[N], C[N];
  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }

  vector<int> benefit;
  for(int i=0;i<N;i++){
    benefit.push_back(V[i]-C[i]);
  }

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

  int ans = 0;
  int i = N-1;
  while(benefit[i]>0){
    ans += benefit[i];
    i--;
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;
#define SZ 666666
#define S 80
int fst[SZ],M=0,nxt[SZ],vb[SZ];
void ad_de(int a,int b)
{
	++M; nxt[M]=fst[a]; fst[a]=M; vb[M]=b;
}
void adde(int a,int b)
{ad_de(a,b);ad_de(b,a);}
bool f[100555][S];
int n,tmp[S];
void dfs(int x,int fa=0)
{
	for(int e=fst[x];e;e=nxt[e])
	{
		int b=vb[e]; if(b==fa) continue;
		dfs(b,x);
	}
	for(int i=0;i<S;++i) tmp[i]=0;
	for(int e=fst[x];e;e=nxt[e])
	{
		int b=vb[e]; if(b==fa) continue;
		for(int j=0;j<S;++j) tmp[j]+=f[b][j];
	}
	++tmp[0]; int r=-1;
	for(int j=0;j<S;++j)
		if(tmp[j]>=2)
			++tmp[j+1], r=j;
	for(int j=0;j<=r;++j) tmp[j]=0;
	for(int j=0;j<S;++j)
		f[x][j]=tmp[j];
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		adde(a,b);
	}
	dfs(1);
	for(int i=S-1;i>=0;--i)
	{
		if(f[1][i])
		{
			printf("%d\n",i);
			return 0;
		}
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++) cin >> h[i];
    vector<int> dp(n,0);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}

int digit(int n){
    int sum = 0;
    while(n != 0){
        sum += n % 10;
         n = n / 10;
    }
    return sum;
}

int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n, a ,b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i = 1; i <= n ; ++i){
        if(digit(i) >= a && digit(i) <= b){
            ans +=i;
        }
    }
    cout << ans;
}

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

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 << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

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


int main(){
	
	string str;
	cin >> str;
	int ans = 0;
	char pre = str[0];
	REP(i, str.size()){
		if(pre != str[i]){
			pre = str[i];
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a, b, c;
        a = scan.nextInt();
        b = scan.nextInt();
        c = scan.nextInt();
        int count = 0;
        for(int divisor = a; divisor <= b; divisor++){
            if(c % divisor == 0){ count++; }
        }
        System.out.println(count);
    }
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int h[] = new int[n];
		for(int i = 0 ; i < n ; i++) {
			h[i] = sc.nextInt();
		}
		long dp[] = new long[n];
		Arrays.fill(dp, Integer.MAX_VALUE);

		for(int i = 0 ; i < n ; i++) {
			if(i == 0)
				dp[i] = 0;
			for(int j = k ; j > 0 ; j--) {
              if(i + j >= n)
                continue;
				dp[i + j] = Math.min(dp[i] + Math.abs(h[i + j] - h[i]), dp[i + j]);
			}
		}
		System.out.println(dp[n - 1]);

	}


}



Measured memory_bytes: 59684
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll power(ll x, ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2,m)%m; 
    p = (p * p)%m; 
  
    return (y%2 == 0)? p : (x * p)%m ; 
} 

ll modInverse(ll a, ll m) 
{ 
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
    return power(a, m-2,m); 
} 
  
// To compute x^y under modulo m 
int n,m;
vector<int> a[100001];
int dp[100001];
int comp[100001]={0};

int dfs(int i)
{
    if(a[i].size()==0)
    {
        return 1;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    int maxi = INT_MIN;
    for(int j=0;j<a[i].size();j++)
    {
        maxi = max(maxi,1+dfs(a[i][j]));
    }
    return dp[i] = maxi;
}
int main()
{
   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        a[u].pb(v);
        comp[v] = 1;
    }
    mset(dp,-1);
    for(int i=1;i<=n;i++)
    {
        if(comp[i]==0)
        {
            dfs(i);
        }
    }int ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans = max(ans,dp[i]);
    }
    ans--;
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 11264
#include<iostream>
#include<vector>
using namespace std;
int t[] ={0,1,2,3,5,7,8,9};
vector<int> u;
int main(){
  int n;
  while(cin>>n&&n){
    u.clear();
    while(n>0){
      u.push_back(t[n%8]);
      n/=8;
    }
    for(int i=u.size()-1;i>=0;i--)cout<<u[i];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef long long ll;

const int MAX_SIZE = 10000;

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

class Situation{
public:
    int hp;
    int x,y;
    int cost;
    Situation(int cost_,int hp_,int x_,int y_){
        cost=cost_;
        hp=hp_;
        x=x_;
        y=y_;
	}
	Situation();

	bool operator<(const Situation &s)const{
        return s.cost < this->cost;
	}
};

int V;
const int MAX_V = 10;
int d[MAX_V][MAX_V][MAX_V];
const int INF = 100000000;

int h,w;
int field[10][10];
void dijkstra(int sy,int sx){
	priority_queue<Situation> que;
    for(int i = 0; i < 10; i++)
        for(int j = 0; j < 10; j++)
            for(int k = 0; k < 10; k++)
                d[i][j][k]=INF;
    d[sy][sx][6] = 0;
    que.push(Situation(0,6,sx,sy));
	while(!que.empty()){
		Situation p = que.top();
		que.pop();
        int x=p.x;
        int y=p.y;
        int hp=p.hp;
        int cost=p.cost;
		if(d[y][x][hp] < cost)
			continue;
        if(hp==1||field[y][x]==3)
            continue;
		for(int i = 0; i < 4; i++){
            int ny=y+dy[i];
            int nx=x+dx[i];
            if(ny>=0&&nx>=0&&ny<h&&nx<w&&field[ny][nx]!=0){
                int nhp=hp-1;
                if(field[ny][nx]==4)
                    nhp=6;
                if(d[ny][nx][nhp] > d[y][x][hp] + 1){
                    d[ny][nx][nhp] = d[y][x][hp]+1;
                    que.push(Situation(d[ny][nx][nhp],nhp,nx,ny));
                }
			}
		}
	}
}
int main(){

    while(cin>>w>>h&&!(w==0&&h==0)){
        int sy,sx;
        int gy,gx;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin>>field[i][j];
                if(field[i][j]==2){
                    sy=i;sx=j;
                    field[i][j]=1;
                }
                else if(field[i][j]==3){
                    gy=i;gx=j;
                    field[i][j]=1;
                }
            }
        }
        dijkstra(sy,sx);
        int minCost=INF;
        for(int i = 1; i < 7; i++)
            minCost=min(minCost,d[gy][gx][i]);
        if(minCost==INF)
            cout<<-1<<endl;
        else
            cout<<minCost<<endl;
    }

    return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		String[] ss = S.split("", 0);
		int count = 0;
		for (int i = 0; i < ss.length / 2; i++){
			if(!ss[i].equals(ss[ss.length -1 - i])){
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22996
#include <algorithm>
#include <iostream>

using namespace std;

const int INF = 10000;
int n, ma, mb, ans;
int dp[500][500];

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

int main() {
  for (int i = 0; i < 500; i++) {
    for (int j = 0; j < 500; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  
  cin >> n >> ma >> mb;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 400; i >= 0; i--) {
      for (int j = 400; j >= 0; j--) {
        dp[i+a][j+b] = min(dp[i+a][j+b], dp[i][j] + c);
      }
    }
  }
  
  ans = INF;
  for (int i = 1; i <= 400; i++) {
    for (int j = 1; j <= 400; j++) {
      if (i * mb == j * ma) {
          ans = min(ans, dp[i][j]);
      }
    }
  }
  if (ans == INF) ans = -1;
  
  cout << ans << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int k,n;
    cin >> k >> n;
    
    int a[n];
    f(i,n) cin >> a[i];
    
    int res = 0;
    
    f(i,n-1) res=max(res,a[i+1]-a[i]);
    
    res=max(res,k+a[0]-a[n-1]); 
    
    cout << k - res;
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<bool> water(30, false);
  water[0] = true;
  for(int i = 1; i <= F/100; i++){
    if(i >= A && water[i-A] == true) water[i] = true;
    if(i >= B && water[i-B] == true) water[i] = true;
  }
  vector<bool> sugar(3000, false);
  sugar[0] = true;
  vector<int> able_sugar = {0};
  for(int i = 1; i <= 3000; i++){
    if(i >= C && sugar[i-C] == true) sugar[i] = true;
    if(i >= D && sugar[i-D] == true) sugar[i] = true;
    if(sugar[i]) able_sugar.push_back(i);
  }
  pair<int, int> ans;
  ans = {100*A, 0};
  for(int i = 1; i <= F/100; i++){
    if(!water[i]) continue;
    auto l = upper_bound(able_sugar.begin(), able_sugar.end(), min(i*E, F-i*100));
    int s = able_sugar[l - able_sugar.begin() - 1];
    int w = s + 100*i;
    if(ans.second * w < s * ans.first) ans = {w, s};
  }
  cout << ans.first << " " << ans.second << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, r;
  cin >> n >> r;
  if(n >= 10) {
    cout << r << '\n';
  } else {
    cout << r + 100 * (10 - n) << '\n'; 
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll x = N/100;
    ll y = N%100;
    if(y <= x*5) return 1;
    else return 0; 
}

int main(){
    ll N; cin >> N;
    pr(solve(N));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	double now;
	int n;
	scanf("%d",&n);
	string type;
	double ans=0;
	while(n--){
		scanf("%lf",&now);
		cin>>type;
		if(type=="JPY"){
			ans+=now;
		}
		else ans+=now*380000.0;
	}
	printf("%lf",ans);
	return 0;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
	int q;
	cin>>q;
	while(q--)
	{
		ll x, y;
		cin>>x>>y;
		ll mul = x*y;
		ll z = sqrt(mul);
		if(x > y) swap(x, y);
		if((x == y) || (x+1 == y)) cout<<(2*x-2)<<endl;
		else
		{
			if(z*z == mul) cout<<(2*z-3)<<endl;
			else if(z*(z+1) >= mul) cout<<(2*z-2)<<endl;
			else cout<<(2*z-1)<<endl;
		}
	}
}


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

using namespace std;

int main() {
    int H, W, N;
    cin >> H >> W >> N;

    vector<int> a;
    for (int i = 1; i <= N; i++) {
        int ai;
        cin >> ai;
        for (int j = 0; j < ai; j++) {
            a.push_back(i);
        }
    }

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            if (h % 2 == 0) {
                cout << a[W * h + w];
            } else {
                cout << a[W * (h + 1) - 1 - w];
            }
            if (w < W - 1) {
                cout << " ";
            } else {
                cout << endl;
            }
        }
    }

    return 0;
};


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    pair<string,int> a[n];
    string s,x;
    int t,itr = 0,countup = 0;
    
    for(int i = 0; i < n; i++) {
        cin >> s >> t;
        a[i] = make_pair(s,t);
    }
    cin >> x;
    for(int i = 0; i < n; i++) {
        if(a[i].first == x) {
            itr = i;
        }
    }
    
    for(int i = itr + 1; i < n; i++) {
        countup = countup + a[i].second;
    }
    cout << countup;
    return 0;
}

Measured memory_bytes: 384
require 'prime'
require 'set'
a, b = gets.split.map(&:to_i)

mods_a = Set.new
mods_b = Set.new

2.upto( Math.sqrt(a) ) do |i|
  if a % i == 0
    mods_a.add(i)
    a = a / i while a % i == 0
  end
end
if a.prime?
  mods_a.add(a) 
end

2.upto( Math.sqrt(b) ) do |i|
  if b % i == 0
    mods_b.add(i)
    b = b / i while b % i == 0
  end
end
if b.prime?
  mods_b.add(b)
end

puts (mods_a & mods_b).size + 1

Measured memory_bytes: 2172
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,a,b;
    cin >> a >> b;
    if(a>=b){
        for(i=0;i<a;i++){
            cout << b;
        }
    }
    else{
        for(i=0;i<b;i++){
            cout << a;
        }
    }
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int n;
	
	cin >> n;

	int a[n];
	float sum = 0;
	rep(i, n)
	{
		int tmp;
		cin >> tmp;
		sum += (1.0 / tmp); 
	}

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


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

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out,false);
        int k = scanner.nextInt(), x = scanner.nextInt();
        int min = Math.max(-1000000, x - k + 1);
        int max = Math.min(1000000, x + k - 1);
        for(int i = min; i <= max; i++) {
            if (i > min) out.print(" ");
            out.print(i);
        }
        out.println();
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[1000000];
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0;
  string s;
  cin >>a>>b>>c>>d;
  cout <<max(a*b,c*d)<<'\n';
  return (0);
}


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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long

void solve()
{
    int n, capacity;
    cin >> n >> capacity;
    int weights[n], values[n];

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

    ll dp[n+1][capacity+1];

    for(int i =0; i <= n; i++)
    {
        for(int w = 0; w <= capacity; w++)
        {
            if(w==0 || i == 0)
                dp[i][w] = 0;
            else if( weights[i-1] <= w)
            {
                //if(i == 3 && w == 3)
                //    cout << "\n> " << dp[i-1][w] << " " << dp[i-1][w-weights[i-1]] << " " << values[i-1];
                dp[i][w] = max( dp[i-1][w], dp[i-1][w-weights[i-1]] + values[i-1]);
            }
            else
                dp[i][w] = dp[i-1][w];
            
        }
    }

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

int main()
{
    fastio;
    solve();
}

Measured memory_bytes: 79104
s = input()
d1 = False
d2 = False
d3 = False
if s[0] == 'A':
    d1 = True
cnt = 0
for i in range(2, len(s)-1):
    if s[i] == 'C':
        cnt += 1
if cnt == 1:
    d2 = True
cnt2 = 0
for j in range(len(s)):
    if s[j].islower():
        cnt2 += 1
if cnt2 == len(s) - 2:
    d3 = True
print('AC' if d1 and d2 and d3 else 'WA')


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include <iomanip>

#define rep0(i,N) for(int i=0;i<N;i++)
#define rep1(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005

using namespace std;

int main(){
	lint n,t,a[SIZE],mina[SIZE]={},maxa[SIZE]={},minnum=1,now=0,rest=0,ans=1;
	cin>>n>>t;
	cin>>a[0];
	mina[0]=a[0];maxa[0]=a[0];
	rep1(i,1,n){
		cin>>a[i];
		if(mina[i-1]>a[i])
			mina[i]=a[i];
		else mina[i]=mina[i-1];
		if(maxa[i-1]<a[i]) maxa[i]=a[i];
		else maxa[i]=maxa[i-1];
		rest=a[i]-mina[i];
		if(now==rest){
			ans++;
		}
		else if(now<rest){
			now=rest;
			ans=1;
		}
	}
	cout<<ans;


return 0;
}

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

using namespace std;

// dp[i+1][j] := i番目までの品物を見たとき, 重さの総和がj以下となるように選んだときの価値の総和の最大値
long long dp[102][100005] = { 0 };

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

  vector<int> w(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= lim_w; j++) {
      if (j >= w[i]) {
        dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
      } else {
        dp[i+1][j] = dp[i][j];
      }
    }
  }

  cout << dp[n][lim_w] << endl;

  return 0;
}


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

int main(){
  string s,r;
  int l,n;
  n=0;
  while(cin>>s){
    l=s.size();
    r=s.substr(l/2+l%2,l/2);
    reverse(r.begin(),r.end());
    if(s.substr(0,l/2)==r) n++;
  }
  cout<<n<<endl;
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD 1000000007ll

using namespace std;
int main(int argc, char const *argv[])
{
	int a,b;
	cin>>a>>b;
	if (a%2==1 && b%2==1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
    return 0;
}


Measured memory_bytes: 764
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int ans[500][500];
int main() {
    int K;
    cin >> K;

    if (K == 1) {
        cout << 1 << endl << 1 << endl;
        return 0;
    }

    int i,j;
    int n = (K+3)/4;
    n *= 2;
    cout << n << endl;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) ans[i][j] = (i+j) % n;
    }
    for (i = 0; i < K-n; i++) {
        for (j = 0; j < n; j++) {
            if (j & 1) ans[j][(i-j+n) % n] += n;
        }
    }
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) cout << ans[i][j]+1 << " ";
        cout << endl;
    }

    return 0;
}



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

void pi(int a) {cout << a << endl;}
void pii(int a, int b) {cout << a << " " << b << endl;}
void piii(int a, int b, int c) {cout << a << " " << b << " " << c << endl;}

int N, P;
int A[50];
int c0=0, c1=0;
ll r=0;

ll combi(int n, int k)
{
  ll res = 1;
  if ( k > n - k )
    k = n - k;
  for (int i = 0; i < k; ++i)
  {
    res *= (n - i);
    res /= (i + 1);
  }
  
  return res;
}



int main()
{
  cin >> N >> P;
  F0R(i, N) cin >> A[i];
  F0R(i, N) A[i] %= 2;
  
  F0R(i, N) {
    if(A[i]) c1++;
    else c0++;
  }

  for(int i = P; i <= c1; i+=2) {
    r += combi(c1, i);
  }
  
  r *= pow(2, c0);
  cout << r;
  
	return 0;
}

Measured memory_bytes: 256
H, W = gets.split.map &:to_i
S = (1..H).map { gets.scan(/./) }

def g(h, w)
  [[-1, 0], [1, 0], [0, -1], [0, 1]].each do |dh, dw|
    hh = h + dh
    ww = w + dw
    if 0<=hh and hh<H and 0<=ww and ww<W and S[hh][ww]=='#'
      return true
    end
  end
  false
end

def f
  for h in 0...H
    for w in 0...W
      if S[h][w]=='#'
        unless g(h, w)
          return false
        end
      end
    end
  end

  true
end

puts f ? 'Yes' : 'No'


Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int d;
  cin >> d;
  ll k[26];
  ll c[26];
  rep(i,26)cin >> c[i];
  rep(i,26)k[i]=0;
  ll ans=0;
  ll s[d][26];
  rep(i,d)rep(j,26)cin >> s[i][j];
  ll  anss[d];
  rep(i,d){
    ll tmp=ans;
    ll p=0;
    rep(o,26){
      ll w=tmp;
      w+=s[i][o];
      rep(j,26){
        if(j==o)continue;
        w-=(i+1-k[j])*c[j];
      }
      if(ans<w){
        ans=w;
        p=o;
      }
    }
    anss[i]=p+1;
    k[p]=i+1;
  }
  rep(i,d)cout << anss[i] << endl;
}


Measured memory_bytes: 3716
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
vector<vector<bool>> seat;

int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()) {
		int a = s[i] - '0';
		ans += a
			;
		ans = ans % 9;
	}
	if (ans%9 == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 3368
using System;
using System.Linq;

namespace _0006
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();

            foreach (char eachVal in input.ToCharArray().Reverse())
            {
                Console.Write(eachVal);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5472
from collections import Counter

H, W = map(int, input().split())
a = ''
for _ in range(H):
    a += input()

a_count = list(Counter(a).values())

H_odd = H % 2
W_odd = W % 2
ans = 'Yes'
if H_odd and W_odd:
    free_space = 1
    sym_space = H + W - 2
    for count in a_count:
        if count % 4 == 2:
            sym_space -= 2
        elif count % 4 == 1:
            free_space -= 1
        elif count % 4 == 3:
            sym_space -= 2
            free_space -= 1
        if sym_space < 0 or free_space < 0:
            ans = 'No'
            break
elif H_odd and not W_odd:
    sym_space = W
    for count in a_count:
        if count % 4 == 2:
            sym_space -= 2
        if count % 2 == 1:
            ans = 'No'
            break
        if sym_space < 0:
            ans = 'No'
            break
elif not H_odd and W_odd:
    sym_space = H
    for count in a_count:
        if count % 4 == 2:
            sym_space -= 2
        if count % 2 == 1:
            ans = 'No'
            break
        if sym_space < 0:
            ans = 'No'
            break
else:
    for count in a_count:
        if count % 4 != 0:
            ans = 'No'
            break

print(ans)


Measured memory_bytes: 38640
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  char c[a+2][b+2];
  for(int i=0; i<a+2; i++){
    for(int j=0; j<b+2; j++){
      c[i][j]='.';
    }
  }
  for(int i=1; i<=a; i++){
    char s[b+1];
    scanf("%s",s);
    for(int j=0; j<b; j++){
      c[i][j+1]=s[j];
    }
  }
  int e=1;
  for(int i=1; i<=a; i++){
    for(int j=1; j<=b; j++){
      if(c[i][j]=='#'){
        if(c[i-1][j]=='.'&&c[i][j-1]=='.'&&c[i+1][j]=='.'&&c[i][j+1]=='.'){
          e=0;break;
        }
      }
    }
  }
  printf(e?"Yes":"No");
  return 0;}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
int main(void){
	long long a, r;
  	long double b;
	scanf("%lld", &a);
  	scanf("%Lf", &b);
    
	b *= 100;
  	b = round(b);
	r = a*b/100;
  	printf("%lld\n", r);
	return 0;
 
}

Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int x; cin >> x;
    if (x < 600) cout << 8 << endl;
    else if (x < 800)cout << 7 << endl;
    else if (x < 1000)cout << 6 << endl;
    else if (x < 1200)cout << 5 << endl;
    else if (x < 1400)cout << 4 << endl;
    else if (x < 1600)cout << 3 << endl;
    else if (x < 1800)cout << 2 << endl;
    else if (x < 2000)cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
   int n,k;
   cin >> n >> k;
   cout << n-(k-1) << endl;
   return 0;
}

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

int main(){
    int N; cin >> N;
    string S; cin >> S;
    if(N % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    string ans = "";
    for (int i = 0; i < S.size()/2; i++)
    {
        ans += S.at(i);
    }
    string ANS = ans + ans;
    if(S == ANS) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int k,t;
	cin >> k >> t;
	int a[t];
	rep(i,t) cin >> a[i];
	int imax = 0;
	rep(i,t) imax = max(imax,a[i]);
	int ans = 0;
	rep(i,t) ans = max(ans,a[i]-(k-a[i])-1);
	cout << ans << endl;
}

Measured memory_bytes: 256
s=input()
a=0
b=0
c=0
d=0
for i in range(len(s)):
    if i%2==0 and s[i]=="0":
        a+=1
    elif i%2==1 and s[i]=="1":
        b+=1
    if i%2==0 and s[i]=="1":
        c+=1
    elif i%2==1 and s[i]=="0":
        d+=1
I=max(a+b,c+d)
ans=len(s)-I
print(ans)

Measured memory_bytes: 3188
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     setbits(x)  __builtin_popcountll(x)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    string s;
    cin>>s;
    if(s[0]==s[1] and s[1]==s[2] and s[0]==s[2]) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const ll INF1 = ll(1e15);
const int MAX = 200002;

int N;
ll a[MAX],b[MAX];

int main()
{
    cin>>N;
    for(int i = 1;i <= N;i++){
         cin>>a[i];
         b[i] = a[i];
    }
    sort(b+1,b+1+N);
    int t = N/2;
    for(int i = 1;i <= N;i++){
        if(a[i]<=b[t]){
            cout<<b[t+1]<<endl;
        }else{
            cout<<b[t]<<endl;
        }
    }


    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int A, B, T;
  cin >> A >> B >> T;
  int ret = T/A*B;
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
def bubbleSort(A, N):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 1
                count += 1
    return count


n = int(input())
a = [int(i) for i in input().split()]
count = bubbleSort(a, n)
print(" ".join(map(str, a)))
print(count)



Measured memory_bytes: 5600
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    ans = 0
    for i in range(1,N+1):
        if i % 5 != 0 and i % 3 != 0:
            ans += i
    print(ans)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 77408
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        W: usize,
        WV: [(usize,usize); N],
    }
    // 重さでテーブル更新は厳しいので、価値を用いる
    let mut dp = vec![vec![999999999999;100001];N+1];
    dp[0][0] = 0;
    for i in 0..N{
        let (w,v) = WV[i];
        for j in 0..100001{
            // i個目を選ぶ場合
            if j>=v{
                dp[i+1][j] = min(dp[i+1][j], dp[i][j-v]+w);
            }
            // i個目を選ばない場合
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    let mut ans = 0;
    for i in 0..100001{
        if dp[N][i] <= W{
            ans = i;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 106748
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll x;cin>>x;
	ll q = x/100;
	ll r = x%100;

	if(5*q>=r){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
































	
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int count = 0;
    char s[3];
    scanf("%s",s);
    if(s[0] == '1'){
        count++;
    }
    if(s[1] == '1'){
        count++;
    }
    if(s[2] == '1'){
        count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 128
s=str(input())
d=True

for i in range(len(s)):
  if i%2==0:
    if s[i]!="R" and s[i]!="U" and s[i]!="D":
      d=False
  else:
    if s[i]!="L" and s[i]!="U" and s[i]!="D":
      d=False
if d:
  print("Yes")
else:
  print("No")

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

int a[100][100];
int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };
int w, h;

void dfs(int x, int y) {
	int c = a[x][y];
	a[x][y] = -1;
	rep(i, 4) {
		int nx = x + dx[i], ny = y + dy[i];
		if (0 <= nx&&nx < w && 0 <= ny&&ny < h&&a[nx][ny] == c)dfs(nx, ny);
	}
}
int main() {
	while (cin >> w >> h, w) {
		memset(a, 0, sizeof(a));
		int xs, ys, xg, yg, n;
		cin >> xs >> ys >> xg >> yg >> n;
		xs--; ys--; xg--; yg--;
		rep(i, n) {
			int c, d, x, y; scanf("%d%d%d%d", &c, &d, &x, &y);
			x--; y--;
			rep(j, 2)rep(k, 4) {
				if (d)a[x + j][y + k] = c;
				else a[x + k][y + j] = c;
			}
		}
		dfs(xs, ys);
		puts(a[xg][yg] == -1 ? "OK" : "NG");
	}
}

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

int main() {
    int k;
    cin >> k;
    queue<ll> que;
    for (int i = 1; i < 10; i++) que.push(i);
    for (int i = 0; i < k - 1; i++) {
        ll s = que.front();
        que.pop();
        for (int j = -1; j <= 1; j++) {
            ll add = (s % 10) + j;
            if (0 <= add && add <= 9) que.push(s * 10 + add);
        }
    }
    cout << que.front() << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String a = in.next();
        String b = in.next();
        String c = in.next();
        int i = a.length();
        int j = b.length();
        int k = c.length();
        int i1=-1;int i2=-1;int i3 =-1;
        int next = 0;
        while (true){
            if (next==0){
                i1++;
                if(i1==i){
                    System.out.println("A");
                    break;
                }
                else {
                    if (a.charAt(i1)=='a'){
                        next=0;
                    }
                    else if (a.charAt(i1)=='b'){
                        next=1;
                    }
                    else {
                        next=2;
                    }
                }
            }
            else if (next==1){
                i2++;
                if(i2==j){
                    System.out.println("B");
                    break;
                }
                else {
                    if (b.charAt(i2)=='a'){
                        next=0;
                    }
                    else if (b.charAt(i2)=='b'){
                        next=1;
                    }
                    else {
                        next=2;
                    }
                }
            }
            else {
                i3++;
                if(i3==k){
                    System.out.println("C");
                    break;
                }
                else {
                    if (c.charAt(i3)=='a'){
                        next=0;
                    }
                    else if (c.charAt(i3)=='b'){
                        next=1;
                    }
                    else {
                        next=2;
                    }
                }
            }
            
        }
    }
}


Measured memory_bytes: 23764