akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
    return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
    assert(__gcd(a, m) == 1);
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
    if (y == 0)
        return 1LL;
    else if (y == 1)
        return x;
    else
    {
        ll ans = modPow(x, y / 2, m) % m;
        if (y & 1)
        {
            return (((ans * ans) % m) * x) % m;
        }
        else
        {
            return (ans * ans) % m;
        }
    }
}

int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    VII pre1(n+1,0),pre2(n+1,0);
    for(int i=1;i<=n;++i)
    {
        cin>>pre1[i];
        pre1[i]=pre1[i-1]+pre1[i];
    }

    for(int i=1;i<=n;++i)
    {
        cin>>pre2[i];
        pre2[i]=pre2[i-1]+pre2[i];
    }

    int mx=INT_MIN;
    for(int i=1;i<=n;++i)
    {
        int a1=pre1[i];
        int a2=pre2[n]-pre2[i-1];
        mx=max(mx,a1+a2);
    }
    cout<<mx;
    return 0;
}

Measured memory_bytes: 256
N,i,M;double X[30],Y[30],Z[30],cx,cy,cz,d,m;
#define Q(x)(x)*(x)
double D(i){return sqrt(Q(X[i]-cx)+Q(Y[i]-cy)+Q(Z[i]-cz));}
int L(){for(m=i=0;i<N;i++)if(D(i)>m)m=D(i),M=i;return M;}
main(t){for(;scanf("%d",&N),N;printf("%f\n",D(L()))){
	for(i=0;i<N;i++)scanf("%lf%lf%lf",X+i,Y+i,Z+i);
	for(cx=cy=cz=d=0.5;d>1e-8;d/=2)for(t=0;t<100;t++)i=L(),cx+=(X[i]-cx)*d,cy+=(Y[i]-cy)*d,cz+=(Z[i]-cz)*d;
}exit(0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[100020];
signed main(){
	cin>>n;
	bool p=0;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=2;i<=n;i++){
		if(a[i]-a[i-1]<-1){
			p=1;
			break;
		}
	}
	for(int i=3;i<=n;i++){
			if(a[i]-a[i-2]<-1){
				p=1;
				break;
		}
	}
	for(int i=4;i<=n;i++){
			if(a[i]-a[i-3]<-1){
				p=1;
				break;
		}
	}
	for(int i=5;i<=n;i++){
			if(a[i]-a[i-4]<-1){
				p=1;
				break;
		}
	}
	for(int i=6;i<=100;i++){
		for(int j=i;j<=n;j++){
			if(a[j]-a[j-i+1]<-1){
				p=1;
				break;
			}
		}
	}
	if(p==1){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a,ll b) {
	return a * b / gcd(a, b);
}

int main(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll x = b / c;
	ll y = b / d;
	ll z = (a - 1) / c;
	ll w = (a - 1) / d;
	//tはnとmのかぶりの個数を表す
	ll t = lcm(c, d);
	ll k = b / t;
	ll s = (a - 1) / t;

	ll ans = (b - x - y + k)  - ((a - 1) - z - w + s);

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

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int d, n;

  std::cin >> d >> n;

  if (d == 0) {
    d = 1;
  } else if (d == 1) {
    d = 100;
  } else {
    d = 100 * 100;
  }

  if (n == 100) {
    std::cout << (n+1)*d << std::endl;
  } else {
    std::cout << n*d << std::endl;
  }

  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define reps(i,a,n) for(int i = (a); i < (n); ++i)
using namespace std;

using ll = long long;
using pi = pair<int, ll>;

ll x[2003];
ll y[2003];
ll z[2003];
vector<pi> d[2003];
bool u[2003];

vector<ll> v;

void dfs(int i, int pre){
    for(auto&p:d[i]){
        if(p.first == pre) continue;
        if(u[p.first]) continue;
        v.push_back(p.second);
        u[p.first] = true;
        return dfs(p.first, i);
    }
}

int main(){
    ll n,k,s;
    while(cin >> n >> k >> s){
        if(n == 0) return 0;
        rep(i, n){
            cin >> x[i] >> y[i] >> z[i];
        }
        if(k == 1){
            cout << s * s * 6 << endl;
            continue;
        }

        const int k1 = k - 1;

        rep(i, n) d[i].clear();
        rep(i, n) reps(j, i+1, n){
            ll X = abs(x[i]-x[j]);
            ll Y = abs(y[i]-y[j]);
            ll Z = abs(z[i]-z[j]);
            if(X <= s && Y <= s && Z <= s){
                X = s-X;
                Y = s-Y;
                Z = s-Z;
                ll v = 2*(X*Y + Y*Z + Z*X);
                d[i].push_back(pi{j,v});
                d[j].push_back(pi{i,v});

                // cout << "#" << i << " " << j << " : " << X << " " << Y << " " << Z << " : " << v << endl;
            }
        }

        rep(i,n) u[i] = false;
        ll ret = 0;
        rep(i,n){
            if(u[i]) continue;
            if(d[i].size() != 1) continue;
            v.clear();
            u[i] = true;
            dfs(i, -1);
            // cout << "$"; for(auto&q:v) cout << " " << q; cout << endl;

            if(v.size() +1 < k) continue;
            ll l = 0;
            rep(i, k1) l += v[i];
            ret = max(ret, l);
            reps(i, k1, v.size()) {
                l -= v[i-k1];
                l += v[i];
                ret = max(ret, l);
            }
        }
        rep(i,n){ // ring
            if(u[i]) continue;
            v.clear();
            dfs(i, -1);
            // cout << "$"; for(auto&q:v) cout << " " << q; cout << endl;
            if(v.size() < k) continue;
            if(v.size() == k){
                ll l = 0;
                rep(i, k) l += v[i];
                ret = max(ret, l);
            }
            int ss = v.size();
            rep(i, ss) v.push_back(v[i]);

            ll l = 0;
            rep(i, k1) l += v[i];
            ret = max(ret, l);
            reps(i, k1, v.size()) {
                l -= v[i-k1];
                l += v[i];
                ret = max(ret, l);
            }
        }
        // cerr << "ret : " << ret << endl;
        if(ret == 0){
            cout << -1 << endl;
        }else{
            cout << s * s * 6 * k - ret << endl;
        }
    }
}


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

using namespace std;

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

	while (T--){
		int H, W;
		char m[64][64];

		scanf("%d %d", &H, &W);

		for (int i = 1; i <= H; i++){
			scanf("%s", &m[i][1]);
		}

		for (int t = 0; t < 7; t++){
			int ct[27][64][64];

			memset(ct, 0, sizeof(ct));

			for (int ch = 26; ch >= 0; ch--){
				int top, left, down, right;
				top = left = down = right = -1;
				char alpha = (ch == 26 ? '?' : 'A' + ch);

				for (int i = 1; i <= H; i++){
					for (int j = 1; j <= W; j++){
						ct[ch][i][j] = (alpha == m[i][j]) + ct[ch][i - 1][j] + ct[ch][i][j - 1] - ct[ch][i - 1][j - 1];

						if (alpha == m[i][j]){
							if (top   == -1 ||   top > i) top = i;
							if (left  == -1 ||  left > j) left = j;
							if (down  == -1 ||  down < i) down = i;
							if (right == -1 || right < j) right = j;
						}
					}
				}

				if (top == -1 || ch == 26) continue;
				int cnt = ct[ch][down][right] - ct[ch][down][left - 1] - ct[ch][top - 1][right] + ct[ch][top - 1][left - 1]
						+ ct[26][down][right] - ct[26][down][left - 1] - ct[26][top - 1][right] + ct[26][top - 1][left - 1];

				if (cnt == (down - top + 1) * (right - left + 1)){
					for (int i = top; i <= down; i++){
						for (int j = left; j <= right; j++){
							m[i][j] = '?';
						}
					}
					memset(ct[26], 0, sizeof(ct[26]));
				}
			}
		}

		bool safe = true;
		for (int i = 1; i <= H; i++){
			for (int j = 1; j <= W; j++){
				safe &= !isalpha(m[i][j]);
			}
		}

		printf("%s\n", safe ? "SAFE" : "SUSPICIOUS");
	}

	return (0);
}

Measured memory_bytes: 1616
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second

const int MAX=100;

int main(void)
{
  int n,m,i,j,k;
  double g[MAX][MAX],dp[MAX+1][MAX],res;//mñÚ,níÞ
  for(;;){
    scanf("%d%d",&n,&m); if(!n)break;
    memset(dp,0,sizeof(dp));
    rep(i,n)dp[0][i]=1.0;
    rep(i,n)rep(j,n)scanf("%lf",g[i]+j);
    rep(i,m)rep(j,n)rep(k,n){
      dp[i+1][k]=max(dp[i+1][k],dp[i][j]*g[j][k]);
    }
    res=0;
    rep(i,n)res=max(res,dp[m-1][i]);
    printf("%.2f\n",res);
  }
  return 0;
}
 

Measured memory_bytes: 0
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


n = I()
s = LI()

s.sort()
print(s[0], s[-1], sum(s))



Measured memory_bytes: 6864
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  int n,p[11];
  cin >> n;
  int sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> p[i];
    sum += p[i];
  }
  
  sort(p,p+n);
  
  cout << sum - p[n-1]/2 << endl;
}

Measured memory_bytes: 3644
#include  <stdio.h>

int main(void)
{
	int a[5];
	int time;
	int i;

	for (i = 0; i <= 4; i++) {
		scanf("%d", &a[i]);
	}

	if (a[0] <= 0) {
		time = a[2] * (0 - a[0]) + a[3] + a[4] * a[1];
	}
	else {
		time = a[4] * (a[1] - a[0]);
	}

	printf("%d\n", time);

	return 0;
}


Measured memory_bytes: 1948
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main(){
    int a;
    cin >> a;
    if (a == 25) cout << "Christmas" << endl;
    else if (a == 24) cout << "Christmas Eve" << endl;
    else if (a == 23) cout << "Christmas Eve Eve" << endl;
    else if (a == 22) cout << "Christmas Eve Eve Eve" << endl;
    

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int right_c = 0;
    int left_c = 0;
    String new_S = S;
    String old = "";
    for(int i = 0;i < N;i++){
      if(S.charAt(i)=='('){
        left_c++;
      }else if(S.charAt(i)==')'){
        if(left_c==0){
          right_c++;
        }else{
          left_c--;
        }
      }
    }
    for(int i = 0;i < right_c;i++){
      new_S = "(" + new_S;
    }
    for(int i = 0;i < left_c;i++){
      new_S = new_S + ")";
    }
    System.out.println(new_S);
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.LinkedHashSet;
import java.util.Set;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;
    for(int i=105;i<=n;i++){
      if(i%2==1){
        if(check(i)){
          count++;
        }
      }
    }
    System.out.println(count);
  }   
  static boolean check(int n){
    int count=0;
      for(int i=1;i<=n;i++){
        if(n%i == 0){
          count++;
        }
      }
    if(count==8){
      return true;
    }else{
      return false;
    }
  }
}

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

int main()
{
	int n,k;
	cin >> n >> k;
	int h[100010];
	for (int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	h[0] = h[1];
	int dp[100010];
	dp[0] = 0;
	dp[1] = 0;
	for (int i = 2; i <= n; i++)
	{
		int x = 1 << 30;
		for (int j = max(1, i - k); j < i; j++)
		{
			x = min(x, dp[j] + max(h[j] - h[i], h[i] - h[j]));
		}
		dp[i] = x;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
def merge(A, left, mid, right):
#    n1 = mid - left
#    n2 = right - mid
    
#    L = [0 for i in range(n1+1)]
#    R = [0 for i in range(n2+1)]

#    for i in range(n1):
#        L[i] = A[left + i]
#        
#    for i in range(n2):
#        R[i] = A[mid + i]
    
#    L[n1]=1000000001
#    R[n2]=1000000001

    L = A[left:mid] + [1000000001]
    R = A[mid:right] + [1000000001]

    cnt1 = 0
    cnt2 = 0
    
    for k in range(left, right):
        if L[cnt1] <= R[cnt2]:
            A[k] = L[cnt1]
            cnt1 += 1
        else:
            A[k] = R[cnt2]
            cnt2 +=  1
    
    global cnt
    cnt += cnt1 + cnt2
    
    
def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right)//2
        
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
        

n = int(input().rstrip())
A = list(map(int,input().split(" ")))
cnt = 0
mergeSort(A, 0 , len(A))
print(" ".join(list(map(str,A))))
print(str(cnt))

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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

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

	auto isOk = [&]() {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < i; ++j) {
				if (a[i][j] != a[j][i]) {
					return false;
				}
			}
		}
		return true;
	};

	int ans = 0;
	for (int _ = 0; _ < n; ++_) {
		rotate(a.begin(), a.begin() + 1, a.end());
		if (isOk()) {
			ans += n;
		}
	}

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

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

const long long BFSMAX = 101010; // Set
vllvll bfsGraph(BFSMAX);
vll bfsdist(BFSMAX);
vector<bool> seen(BFSMAX);
map<pll, ll> colors;
ll diff = 0;

template<class T>
void bfs(T start)
{
    fill(bfsdist.begin(), bfsdist.end(), inf);
    bfsdist[start] = 0;
    fill(seen.begin(), seen.end(), false);

    queue<T> q;
    q.push(start);

    vll prevc(BFSMAX);
    while (! q.empty()) {
    auto now = q.front(); q.pop();
        ll c = 0;
        for (auto adj : bfsGraph[now]) {
            if (bfsdist[adj] == inf) {
                bfsdist[adj] = bfsdist[now] + 1;
                ++c;
                if (c == prevc[now]) ++c;
                colors[pll{now, adj}] = c;
                
                q.push(adj);
                prevc[adj] = c;
            }
        }
    }
}

// Prepare for `bfsGraph`
int main()
{
        ll N;
        cin >> N;
        vll e1(N), e2(N);
        rep(i, 0, N-1) {
                ll a, b;
                cin >> a >> b;
                bfsGraph[a].push_back(b);
                bfsGraph[b].push_back(a);
                e1[i] = a;
                e2[i] = b;
        }

        bfs(1);

        vll ans;
        rep(i, 0, N-1) {
                ans.push_back(max(colors[pll{e1[i], e2[i]}], colors[pll{e2[i], e1[i]}]));
        }
        cout << *max_element(all(ans)) << endl;
        rep(i, 0, N-1) {
                cout << ans[i] << endl;
        }
}


Measured memory_bytes: 24740
#include<bits/stdc++.h>
using namespace std;
double eps = 1e-9;
using Point = complex<double>;
struct Circle{ Point p; double r; };
double dist(Point p, Point q){ return abs(p-q); }
double area2(Point p, Point q){ return (conj(p)*q).imag(); }
bool in(const Circle& c, Point p){ return dist(c.p, p) < c.r + eps; }
Circle INVAL = Circle{Point(0, 0), -1};
Circle mCC(Point a, Point b, Point c){
    b -= a; c -= a;
    double d = 2*(conj(b)*c).imag(); if(abs(d)<eps) return INVAL;
    Point ans = (c*norm(b) - b*norm(c)) * Point(0, -1) / d;
    return Circle{a + ans, abs(ans)};
}
Circle solve(vector<Point> p) {
    mt19937 gen(0x94949); shuffle(p.begin(), p.end(), gen);
    Circle c = INVAL;
    for(int i=0; i<p.size(); ++i) if(c.r<0 ||!in(c, p[i])){
        c = Circle{p[i], 0};
        for(int j=0; j<=i; ++j) if(!in(c, p[j])){
            Circle ans{(p[i]+p[j])*0.5, dist(p[i], p[j])*0.5};
            if(c.r == 0) { c = ans; continue; }
            Circle l, r; l = r = INVAL;
            Point pq = p[j]-p[i];
            for(int k=0; k<=j; ++k) if(!in(ans, p[k])) {
                double a2 = area2(pq, p[k]-p[i]);
                Circle c = mCC(p[i], p[j], p[k]);
                if(c.r<0) continue;
                else if(a2 > 0 && (l.r<0||area2(pq, c.p-p[i]) > area2(pq, l.p-p[i]))) l = c;
                else if(a2 < 0 && (r.r<0||area2(pq, c.p-p[i]) < area2(pq, r.p-p[i]))) r = c;
            }
            if(l.r<0&&r.r<0) c = ans;
            else if(l.r<0) c = r;
            else if(r.r<0) c = l;
            else c = l.r<=r.r?l:r;
        }
    }
    return c;
}
int N; 
int main()
{
    cin >> N;
    vector<Point> V;
    for(int i=0; i<N; ++i)
    {
        int x, y; cin >> x >> y;
        V.emplace_back((double)x, (double)y);
    }
    printf("%.12lf\n", solve(V).r);
}

Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	

int max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int a, b;
	cin >> a >> b;
	int sum = 1;
	int cnnnt = 0;
	while (sum < b) {
		sum += a-1;
		cnnnt++;
	}
	cout << cnnnt << endl;
}

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

struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
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>;
#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
#define MOD 1000000007



int main() {
    int N; cin >> N;
    double ans = 0;
    rep(i, N) {
        double x; string u;
        cin >> x >> u;
        if (u == "JPY") ans += x;
        else ans += x * 380000.0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {
    
    vector< int > rel(1001);
    rel[1000] = 'm', rel[100] = 'c', rel[10] = 'x', rel[1] = 'i';
    rel['m'] = 1000, rel['c'] = 100, rel['x'] = 10, rel['i'] = 1;
    int n; cin >> n;
    while(n--) {
        string a, b;
        cin >> a >> b;
        int as = 0, bs = 0, sum = 0;
        for(int i = 0; i < a.size(); i++) {
            if(isdigit(a[i])) {
                as += rel[a[i + 1]] * (a[i] - '0');
                i++;
            } else {
                as += rel[a[i]];
            }
        }
        for(int i = 0; i < b.size(); i++) {
            if(isdigit(b[i])) {
                bs += rel[b[i + 1]] * (b[i] - '0');
                i++;
            } else {
                bs += rel[b[i]];
            }
        }
        string ans = "";
        sum = as + bs;
        for(int i = 1000; i >= 1; i /= 10) {
            if(sum / i % 10 > 0) {
                if(sum / i % 10 > 1) cout << sum / i % 10;
                cout << (char)rel[i] ;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1220
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        PriorityQueue<Integer> queue = new PriorityQueue<>(Collections.reverseOrder());
        
        int num = 0;
        for (int i = 0; i < n; i++) {
            num = sc.nextInt();
            queue.add(num);
        }
        
        while (m-- > 0) {
            num = queue.poll();
            num /= 2;
            queue.add(num);
        }
        
        long sum = 0;
        for (Integer ele : queue) {
            sum += ele;
        }
        
        System.out.println(sum);
    }
}


Measured memory_bytes: 62084
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	long long ans = 0;
	for(int i = 0; i < n; ++i) {
		long long t = 0;
		for(int j = i; j < n; ++j) {
			t = t * 10 + s[j] - '0';
			long long tmp = t;
			cerr << "i = " << i << ' ' << "j = " << j << ' ' << "tmp = " << tmp << '\n';
			for(int k = 0; k < i - 1; ++k) {
				tmp *= 2;
			}
			for(int k = j + 2; k < n; ++k) {
				tmp *= 2;
			}
			cerr << "tmp = " << tmp << '\n';
			ans += tmp;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
l,r = gets.split.map(&:to_i)
min = 2019
(l...r).each do |i|
    (i + 1..r).each do |j|
      mod = (i*j) % 2019
      if mod == 0
        p 0
        exit
      elsif mod < min
        min = mod
      end
    end
end
puts min


Measured memory_bytes: 1788
def gcd(a,b):
    if a%b == 0:
        return b
    else:
        return gcd(b,a%b)

n,M = map(int,input().split())
a = list(map(int,input().split()))

a = sorted(list(set(a)))
b = [a[i]//2 for i in range(len(a))]

owa = 0
saiko = b[0]

for i in range(1,len(a)):
    t1 = b[i]
    koe = gcd(saiko,t1)
    saiko = (saiko*t1)//koe
    if (saiko//b[i])%2 == 0:
        break

for i in range(len(a)):
    check = saiko//(b[i])
    if check%2 == 0:
        owa = 1
        break

if owa == 1:
    print(0)
else:
    if (M//saiko)%2 == 0:
        print((M//saiko)//2 )
    else:
        print(((M//saiko)+1)//2)



Measured memory_bytes: 66540
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<(*i)<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 998244353;//1000000007;
constexpr ld EPS = 1e-11;


ll solve(ll n, vll &v, ll m){
    ll need=0;
    rep(i,n){
        ll t=ceil(v[i]/(double)m) - 1;
        need+=t;
    }
    return need;
}

int main() {
    
    
    ll n,k;
    cin>>n>>k;
    vll v(n);
    rep(i,n)cin>>v[i];
    // vector vの中のn以下の数で最大のものを返す
    ll ng = 0; //これがx以下 
    ll ok = 2e9; //x以上 
    // 問題によってokとngを入れ替える
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng)/2;
        if(solve(n, v, mid) <= k) ok = mid;
        else ng = mid;
        // cout<<ng<<" "<<mid<<" "<<ok<<endl;
    }
    fin(ok);
}


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

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

using namespace std;

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

  int ans = 1;
  while(ans <= n) {
    ans *= 2;
  }

  std::cout << ans / 2 << std::endl;
  return 0;
}


Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskB {
		public void solve(int testNumber, Scanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = in.nextIntArray(n);
			Arrays.sort(a);
			int alice = 0, bob = 0;
			for (int i = 0; i < n; i++) {
				if (i % 2 == 0) {
					alice += a[n - i - 1];
				} else {
					bob += a[n - i - 1];
				}
			}
			out.println(alice - bob);
		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

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

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

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}

	}
}



Measured memory_bytes: 21460
#include <stdio.h>
#define N 10000

int main(){
	int i, j;
	int n, q;
	int count=0;
	int s[N];
	int t[N];
	scanf("%d", &n);
	for( i=0; i<n; i++ ){
		scanf("%d", &s[i]);
	}
	scanf("%d", &q);
	for( i=0; i<q; i++ ){
		scanf("%d", &t[i]);
	}
	for( i=0; i<q; i++ ){
		for( j=0; j<n; j++ ){
			if( s[j]==t[i] ){
				count++;
				break;
			}
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 644
#Coding:Utf-8

N=int(input())
s=[list(input()) for i in range(N)]
total=0
dic={}
for l in range(N):
    s[l].sort()
    if dic.get(str(s[l]))==None:
        dic[str(s[l])]=0
    else:
        dic[str(s[l])]+=1
        total+=int(dic[str(s[l])])
print(total)


Measured memory_bytes: 43244
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
int p[20000];
int a[20000], b[20000];

int main(){
  cin >> n;
  rep(i, n) cin >> p[i], p[i]--;
  rep(i, n) a[i] = b[n - i - 1] = (i + 1) * 20000;
  rep(i, n) a[p[i]] += i, b[p[i]] += i;
  rep(i, n) cout << a[i] << "\n "[i + 1 < n];
  rep(i, n) cout << b[i] << "\n "[i + 1 < n];
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;

int main(){
	int n, t, a, h;
	cin >> n >> t >> a;
	int tmp = 0;
	int cc = 999999;
	for(int i = 1; i <= n; i++){
		cin >> h;
		int d = (t * 1000 - h * 6) - a * 1000;
		if(cc > abs(d)) cc = abs(d), tmp = i;
	}
	cout << tmp << endl;

    return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  int tile[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> tile[i][j];
    }
  }

  int dp[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (tile[i][j] == 1) dp[i][j] = 0;
      else dp[i][j] = 1;
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (dp[i][j] == 0) continue;
      if (i == 0 && j == 0) continue;
      if (i == 0) dp[i][j] = 1;
      else if (j == 0) dp[i][j] = 1;
      else dp[i][j]
	     = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
    }
  }

  int maxi = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      maxi = max(maxi, dp[i][j]);
    }
  }

  cout << maxi * maxi << endl;
  
  return 0;
}

Measured memory_bytes: 18344
#include <iostream>
using namespace std;
int main(){
   int a,b;
   cin >> a >> b;
   if(a>b){
      cout << "a > b" << endl;
   }else if(a<b){
      cout << "a < b" << endl;
   }else{
      cout << "a == b" << endl;
   }
   return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define pq(T) priority_queue<T>
#define rpq(T) priority_queue<T, vector<T>, greater<T> >
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;



int main() {
  io();
  
  int n; string s;
  cin >> n >> s;
  
  int count = 0;
  fori(i, n-2) {
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      ++count;
    }
  }
  cout << count;
  
  return 0;
}

Measured memory_bytes: 256
'use strict';
function main(input) {
  const arr = input.trim().split('\n');
  const a = Number(arr[0]);
  const str = arr[1];
  const alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ';
  let ans = '';

  for (let i = 0; i < str.length; i ++) {
    ans += alp[alp.indexOf(str[i]) + a];
  }
  
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7756
from math import factorial
from collections import Counter


def combinations_count(n, r):
    if n >= r:
        return factorial(n) // (factorial(n - r) * factorial(r))
    else:
        return 0

c = Counter()
n = int(input())
A = list(map(int, input().split()))
for i in A:
    c[i] += 1
ans = 0
for k, v in c.items():
    ans += combinations_count(v, 2)

for i in A:
    print(ans-c[i]+1)


Measured memory_bytes: 33932
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>
 
using namespace std;
 
#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#ifdef __BORLANDC__
	typedef __int64 ll;
#else
	typedef long long ll;
#endif


const int N = 10;
int n;

typedef pair<int,int> pii;

map<pii,int> memo;

int saiki(int depth, int used, int lest){
	pii key = pii(used,lest);
	map<pii,int>::iterator it = memo.find(key);
	if(it!=memo.end())return it->second;
	
	if(lest<0)return 0;
	if(depth==n){
		if(lest==0)return 1;
		return 0;
	}
	
	
	int maxim = 0;
	int cpd = n-1;
	for(int i=N-1;i>=0;i--){
		if(cpd==depth-1)break;
		if((used&(1<<i))==0){
			maxim += i*(cpd+1);
			cpd--;
		}
	}
	if(maxim<lest)return 0;
	
	
	int ret = 0;
	rep(i,N){
		if((used&(1<<i))==0){
			ret += saiki(depth+1, used|(1<<i), lest-(depth+1)*i);
		}
	}
	return memo[key]=ret;
}

class Q{
	public:
	int i,n,s;
	Q(int i,int n,int s):i(i),n(n),s(s){}
	bool operator<(const Q& a)const{
		if(n!=a.n)return n<a.n;
		if(i!=a.i)return i<a.i;
		return s<a.s;
	}
};
int main(){
	vector<Q> in;
	int s,cnt=0;
	while(cin>>n>>s){
		if(n==0)break;
		in.push_back(Q(cnt,n,s));
		cnt++;
	}
	sort(in.begin(),in.end());
	
	vector<int> ans(in.size());
	rep(i,in.size()){
		if(i!=0 && in[i].n!=in[i-1].n){
			memo.clear();
		}
		
		n = in[i].n;
		ans[in[i].i]=saiki(0,0,in[i].s);
	}
	
	rep(i,ans.size()){
		printf("%d\n",ans[i]);
	}
}

Measured memory_bytes: 4136
export class Main {
  static main(input): string {
    const [a, b, c, d, e, k]: number[] = input.split("\n").map(s => Number(s.split(" ")[0]));
    const l: number[] = [a, b, c, d, e];
    for (let i = 0; i < 4; i++) {
      for (let j = i + 1; j < 5; j++) {
        if (l[j] - l[i] > k) {
          return ":(";
        }
      }
    }
    return "Yay!";
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String args[]){
        
        String ans;
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();

	if (x ==  3 || x == 5 || x == 7) {
	    ans = "YES";
	} else {
	    ans = "NO";
	}
        System.out.println(ans);
    }
}


Measured memory_bytes: 22356
#include <stdio.h>
#include <string.h>
int main(void){
    char x[200];
    int m, h[200], i, j, tmp;  
    
    while(1){
        int xn=0, sum=0;
        scanf("%s\n", x);
        scanf("%d", &m);
        for(i=0; i<m; i++){
            scanf("%d", &h[i]);
        }
        
        xn = strlen(x);
        
        if(strcmp(x, "-") == 0) break;
        
        for(i=0; i<m; i++){
            sum = sum + h[i];
        }
        
        for(i=0; i<sum; i++){
            tmp = x[0];
            for(j=0; j<xn; j++){
                x[j] = x[j+1];
            }
            x[xn-1] = tmp;
        }
        
        for(i=0; i<xn; i++){
            printf("%c", x[i]);
            if(i == xn-1){
                printf("\n");
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    REP(i,a){
        REP(j,b){
            int p=i+1;
            int q=j+1;
            if(q/10<2||q%10<2){
                continue;
            }
            if(p==(q%10)*(q/10)){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int maxl=1e5+5;
char s[maxl],t[maxl];
int S[maxl],T[maxl];
int main(){
	scanf("%s",s+1);scanf("%s",t+1);
	int q,a,b,c,d;scanf("%d",&q);
	for(int i=1;s[i];i++)S[i]=S[i-1]+s[i]-'A'+1;  
    for(int i=1;t[i];i++)T[i]=T[i-1]+t[i]-'A'+1;  
    while(q--)
        scanf("%d%d%d%d",&a,&b,&c,&d),
		puts(((S[b]-S[a-1])%3==(T[d]-T[c-1])%3)?"YES":"NO");
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
int main()
{
	int N,i,num=1;
	scanf("%d",&N);
	char S[N];
	for(i=0;i<N;i++)
	{
		scanf(" %c",&S[i]); 
	}
	for(i=0;i<N-1;i++)
	{
		if(S[i]!=S[i+1]) num++;
	}
	printf("%d",num);
}

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

using namespace std;

int main() {
  int64_t n, k;
  cin >> n >> k;
  int64_t value = 1;
  for(int i = 0; i < n; ++i){
    value = min(value * 2, value + k);
  }
  cout << value << endl;
}


Measured memory_bytes: 256
A = [ [] for i in range (3)]
for i in range(3) :
    A[i] = input().split()

fl = False 

B = [[False for i in range (3)] for i in range(3)]

N = int(input())
for b in range (N) :
    tmp = input()
    for i in range (3) :
        for j in range (3) :
            if int(tmp) == int(A[i][j]) :
                B[i][j] = True

if B[0][0] and B[1][1] and B[2][2] :
    fl = True
elif B[0][2] and B[1][1] and B[2][0] :
    fl = True
elif B[0][0] and B[0][1] and B[0][2] :
    fl = True
elif B[1][0] and B[1][1] and B[1][2] :
    fl = True
elif B[2][0] and B[2][1] and B[2][2] :
    fl = True
elif B[0][0] and B[1][0] and B[2][0] :
    fl = True
elif B[0][1] and B[1][1] and B[2][1] :
    fl = True
elif B[0][2] and B[1][2] and B[2][2] :
    fl = True

print ('Yes' if fl else 'No')

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int  main()
{
 int n,i;
  double a,sum=0;
  cin>>n;
  for(i=0;i<n;i++){
  cin>>a;

  sum+=(1/a);
  }
  cout.setf(ios::fixed);
  cout.precision(5);
  cout<<1/sum<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>
#include <set>
#include <map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define _USE_MATH_DEFINES

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

const ll INF = 999999999;
const ll atcoder = 1e9 + 7;
const int dx[4] = { 1 , 0 , -1 ,0 };
const int dy[4] = { 0 , 1 , 0 , -1 };

int main() {

	string s;
	cin >> s;

	if (s[0] == '9' || s[1] == '9')cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> snuke(n, 0);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            a--;
            snuke[a]=1;
        }
    }
    int ans = 0;
    rep(i,n) {
        if(snuke[i]!=1){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
N, M = gets.split.map(&:to_i)
EDGES = Hash.new{|h, k| h[k] = {} } 
M.times{|i|
  l, r, d = gets.split.map(&:to_i) 
  EDGES[l][r] = [d, i]
  EDGES[r][l] = [-d, i]
}

VISITED = Array.new(M)
POSS = Array.new(N+1)

def dfs(start)
  todo = [start]
  while (node1 = todo.pop)
    EDGES[node1].each do |node2, (dist, i)|
      #p [{node1 => node2}, dist, i]
      next if VISITED[i]
      pos2 = POSS[node1] + dist
      #p pos2: pos2
      if POSS[node2] && POSS[node2] != pos2
        puts "No"
        exit
      end
      POSS[node2] = pos2
      VISITED[i] = true
      todo << node2
    end
  end
end

start = 1
while (start = (start..N).find{|i| POSS[i].nil?})
  POSS[start] = 0
  dfs(start)
end

puts "Yes"


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

using namespace std;
typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<int,int> pii;
const int maxN = 1010;
const int maxC = 1e6 + 10;
const int INF = 1e9; 
int n;
int a[maxN];
vector<int> v;
vector<int> w;
int flag = 0;
ll cnt = 0;

queue<pii> Q;
int main()
{
	scanf("%d",&n);
   	for(int i=1;i<=n;i++)
   	{
   		scanf("%d",&a[i]);	
	}
	Q.push(pii(1,n));
	while(!Q.empty())
	{
		pii tmp = Q.front();
		Q.pop();
		int L = tmp.first;
		int R = tmp.second;
		int mv = INF;
		v.clear();
		v.push_back(L-1);
		flag = 0;
		for(int i=L;i<=R;i++)
		{
			if(a[i] == 0)
			{
				v.push_back(i);
				flag = 1; 
			}
			mv = min(mv,a[i]);
		}
		if(!flag)
		{
			for(int i=L;i<=R;i++)
			{
				a[i] -= mv;
				if(a[i] == 0)
				{
					v.push_back(i);
				}
			}
		}
		cnt += mv;
		v.push_back(R+1);
		for(int i=0;i<v.size()-1;i++)
		{
			int tx = v[i]+1;
			int ty = v[i+1] - 1;
			if(tx > ty) continue;
			Q.push(pii(tx,ty));
		}
	}
	cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N = int(input())
city_num = {}
score = []

for i in range(N):
    s, p = input().split()
    if s not in city_num.keys():
        city_num[s] = [i]
    else:
        city_num[s].append(i)
    score.append(int(p))
    
score_rank = np.argsort(score)[::-1]  
city_num = sorted(city_num.items())

for city, num in city_num:
    order = [s for s in score_rank if s in num]
    [print(o + 1) for o in order]

Measured memory_bytes: 13120