akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
using namespace std;

int main(){
	int n,m[100];
	cin >> n;
	for(int i=0;i<n;++i) cin >> m[i];
	sort(m, m+n);
	double ans = m[0];
	for(int i=1;i<n;++i){
		ans = (ans + m[i]) / 2.0;
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
n=int(input())
s=list(map(float,input().split()))
a=np.zeros(n+1,dtype="float")
a[0]=1
for i in range(n):
    k=s[i]
    p=a*(1-k)
    p[1:]+=a[:-1]*k
    a=p
print(sum(a[n//2+1:]))

Measured memory_bytes: 21128
#include <iostream>

using namespace std;

int main(){
	long long int ans = 0, max;
	long long int n, tmp;
	cin >> n;
	cin >> max;
	for (int i = 1; i < n; i++){
		cin >> tmp;
		if (tmp < max)
			ans += 	max - tmp;
		else
			max = tmp;
	}
	cout << ans << '\n';
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int c;
  if (s[0] == '1') ++c;
  if (s[1] == '1') ++c;
  if (s[2] == '1') ++c;
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set> 
#include<stack>
using namespace std;

map<int,int> mp;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++)
{   int temp;
    cin>>temp;
	if(mp.find(temp)==mp.end())
    mp[temp]=1;
    else if(mp[temp]==0)
    mp[temp]=1;
    else if(mp[temp]==1)
    mp[temp]=0; 
}
int count=0;
for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
{
	if(it->second==1)
	count++; 
}
cout<<count;
return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>
#include<queue>
#include<cmath>

using namespace std;

typedef long long int64;

int main(void){
    int64 a[5];
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
    for (int64 i = 0; i < 5; i++)
    {
        if(a[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    
    
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int r1 = (s[0] - '0') * 10 + s[1] - '0';
    int r2 = (s[2] - '0') * 10 + s[3] - '0';
    if (1 <= r1 && r1 <= 12) {
        if (1 <= r2 && r2 <= 12) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if (1 <= r2 && r2 <= 12) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;

set<int> squaresum;

void init() {
    int n = 1;
    VI v;
    while (n * n <= 40000) {
        v.emplace_back(n * n);
        ++n;
    }
    for (int i = 0; i < v.size(); i++) {
        squaresum.insert(v[i]);
        for (int j = i; j < v.size(); j++) {
            squaresum.insert(v[i] + v[j]);
        }
    }
}

void solve(int n) {
    for (int i = 0; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        a = abs(a);
        b = abs(b);
        if (a > b) swap(a, b);
        bool isNotPrime = false;
        const int sqa = a * a;
        const int sqb = b * b;
        const int sqab = sqa + sqb;
        for (int i = 2; i * i <= sqab; i++) {
            if (sqab % i == 0) {
                if (sqa != i || sqb != sqab / i ) {
                    isNotPrime |= !!(squaresum.count(i) && squaresum.count(sqab / i));
                    if (squaresum.count(i) && squaresum.count(sqab / i)) {
                        //cout<<a<<" "<<b<<" "<<i<<" "<<sqab/i<<endl;
                    }
                }
            }
        }
        printf("%c\n", (!isNotPrime ? 'P' : 'C'));
    }
    exit(0);
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    init();
    while (cin >> n, n) {
        solve(n);
    }
}

Measured memory_bytes: 3876
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

//同じコードでそんなにばらつくんですか

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 130000, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}

bool NG[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), M = getint();
	int H[100001];
	rep1(i, N) H[i] = getint();
	rep(i, M) {
		int a = getint(), b = getint();
		if (H[a] >= H[b]) NG[b] = 1;
		if (H[a] <= H[b]) NG[a] = 1;
	}
	int kotae = N;
	rep1(i, N) kotae -= NG[i];

	printf("%d", kotae);

	Would you please return 0;
}

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

Measured memory_bytes: 584
n,k=map(int,input().strip().split())
c=n
l=list(map(int,input().strip().split()))
ans=0
if n==k:
    print(1)
else:
    while True:
        if n<=0 or n==1:
            break 
        else:
            n=n-(k-1)
            ans+=1
    print(ans)
    

Measured memory_bytes: 14008
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
N_List = []
for i in range(N):
    N_List.append(int(input()))

print(lcm_list(N_List))


Measured memory_bytes: 9572
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 1'000'000'007;

int main() {
    int M, D, cnt = 0;
    cin >> M >> D;
    for(int i = 1; i <= M; i++) {
        for(int j = 10; j <= D; j++) {
            int d1 = j % 10, d10 = (j / 10) % 10;
            if(d1 >= 2 && d10 >= 2 && d1 * d10 == i) {
                cnt++;
            }
        }
    }
    cout << cnt;
} 

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N, M;
	std::cin >> N >> M;
	std::vector<int> vec(N);
	int sum = 0;
	for (auto& v : vec)
	{
		std::cin >> v;
		sum += v;
	}
	int count = 0;
	for (auto&& v : vec)
	{
		if (sum <= 4 * M * v)
		{
			++count;
		}
	}
	std::cout << (M <= count ? "Yes" : "No") << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long R, long long G){
    cout << G * 2 - R << endl;
}

int main(){

    long long R;
    scanf("%lld",&R);
    long long G;
    scanf("%lld",&G);
    solve(R, G);
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[18]:


N = int(input())
a = list(map(int, input().split()))


# In[19]:


count = [0]*N
for i in range(N):
    while a[i]%2 == 0:
        a[i] = a[i] / 2
        count[i] += 1
print(sum(count))


# In[ ]:






Measured memory_bytes: 10160
#include<iostream>
using namespace std;
int main(){
    int a;
    int b;
    int c;
    int c2 = 1;
    int c3;
    int count = 0;
    
    cin >> a >> b >> c;
    
    while(c2 <= c){
        c3 = c % c2;
        if(c3 == 0){
            if((a <= c2) && (c2 <= b)){
                count ++;
            }
        }
        c2 ++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> a) {
  int L[3] = {};
  REP(i, N) {
    if (a[i] % 2 == 0) {
      if (a[i] % 4 == 0)
        L[2]++;
      else
        L[1]++;
    } else
      L[0]++;
  }

  bool ans = 0;
  if (L[1]) {
    ans = L[0] <= L[2];
  } else {
    ans = L[0] - 1 <= L[2];
  }

  cout << ((ans) ? "Yes" : "No") << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> a(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> a[i];
  }
  solve(N, a);
  return 0;
}


Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
struct color { double l, a, b; };
vector<color> list;
bool used[20];
int n, m;
double dfs(int pos, int rest, double d) {
	if (rest == 0)return d;
	if (pos == n)return 0;
	double md = 0;
	for (int i = pos; i <= n - rest; i++) {
		double dist = d;
		used[i] = 1;
		for (int j = 0; j < pos; j++) {
			if (used[j])dist += (list[j].l - list[i].l)*(list[j].l - list[i].l) + (list[j].a - list[i].a)*(list[j].a - list[i].a) + (list[j].b - list[i].b)*(list[j].b - list[i].b);
		}
		md = max(dfs(i + 1, rest - 1, dist), md);
		used[i] = 0;
	}
	return md;
}
int main() {
	cin >> n >> m;
	list.resize(n);
	for (auto &a : list)cin >> a.l >> a.a >> a.b;
	int sc = 0;
	cout << fixed<<setprecision(20)<<dfs(0, m, 0) << endl;
	return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
using namespace std;
using ll = long long;
int main () {
  int n;
  cin >> n;
  vector<ll> cnt(5);
  rep(i,0,n) {
    string s;
    cin >> s;
    if (s[0] == 'M') cnt[0]++;
    if (s[0] == 'A') cnt[1]++;
    if (s[0] == 'R') cnt[2]++;
    if (s[0] == 'C') cnt[3]++;
    if (s[0] == 'H') cnt[4]++;
  }
  ll ans = 0;
  rep(i,0,3) rep(j,i+1,4) rep(k,j+1,5) {
    ans += cnt[i] * cnt[j] * cnt[k];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

#define CK(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long  LLINF = 1e15;

using namespace std;

int N;
string S;

int ind;
int parse(){
  int ret = 0;
  if(S[ind] == '['){
    vector<int> v;
    ind++;
    while(S[ind]!=']') v.push_back(parse());
    ind++;
    sort(v.begin(),v.end());
    REP(i,0,v.size()/2+1) ret += v[i];
  }else if(isdigit(S[ind])){
    while(isdigit(S[ind])){
      ret = 10*ret + (int)(S[ind] - '0');
      ind++;
    }
    ret = ret/2 + 1;
  }
  return ret;
}

int main(){
  cin>>N;
  REP(i,0,N){
    cin>>S;
    ind=0;
    cout<<parse()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3148
#include<stdio.h>
int main(void){
    int w,h,n,x,y,nowx,nowy,ans=0,i,dx,dy;
    scanf("%d %d %d",&w,&h,&n);
    scanf("%d %d",&nowx,&nowy);
    for(i=0;i<n-1;i++){
        scanf("%d %d",&x,&y);
        dx=x-nowx;
        dy=y-nowy;
        if(dx*dy>=0){
            if(dx<0)dx=dx*-1;
            if(dy<0)dy=dy*-1;
            if(dx>dy){
                ans+=dx;
            }else{
                ans+=dy;
            }
        }else{
            if(dx<0)dx=dx*-1;
            if(dy<0)dy=dy*-1;
            ans+=dx+dy;
        }
        nowx=x;
        nowy=y;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 596
def main():
    a, b = map(int, input().split())
    num_neg = 0
    if a <= 0 and b >= 0:
        print('Zero')
        return
    elif a > 0:
        print('Positive')
        return
    else:
        num_neg = b - a
        if num_neg % 2 == 1:
            print('Positive')
            return
        else:
            print('Negative')
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61900
import java.io.*
import java.util.*

// max(a0, a1) <= b0
// max(a1, a2) <= b1
// a[0] = b[0], a[1] = min(b[0], b[1]), ...
fun solve(N: Int, B: IntArray){
    var ans = B[0] + B[N-2]
    for (i in 1 until N-1){
        ans += Math.min(B[i-1], B[i])
    }
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val B = IntArray((N-1))
    for (i in 0 until (N-1)) {
        B[i] = sc.next().toInt()
    }
    solve(N, B)
}



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

template <typename T, typename U> class SegmentTree {
private:
  using F = function<T(T, T)>;
  using G = function<T(T, U)>;
  using H = function<U(U, U)>;
  int n, height;
  vector<T> node; vector<U> lazy;
  T t; U u; F f; G g; H h;
public:
  SegmentTree(F f, G g, H h, T t, U u) : f(f), g(g), h(h), t(t), u(u) {}
  void init(int in) {
    n = 1; height = 0;
    while (n < in) n <<= 1, height++;
    node.assign(2 * n, t); lazy.assign(2 * n, u);
  }
  void build(const vector<T> &v) {
    int sz = v.size();
    init(sz);
    for (int i = 0; i < sz; i++) node.at(n + i) = v.at(i);
    for (int i = n - 1; i; i--) {
      node.at(i) = f(node.at((i << 1) | 0), node.at((i << 1) | 1));
    }
  }
  inline T reflect(int k) {
    return (lazy.at(k) == u) ? node.at(k) : g(node.at(k), lazy.at(k));
  }
  inline void eval(int k) {
    if (lazy.at(k) == u) return;
    lazy.at((k << 1) | 0) = h(lazy.at((k << 1) | 0), lazy.at(k));
    lazy.at((k << 1) | 1) = h(lazy.at((k << 1) | 1), lazy.at(k));
    node.at(k) = reflect(k);
    lazy.at(k) = u;
  }
  inline void thrust(int k) {
    for (int i = height; i; i--) eval(k >> i);
  }
  inline void recalc(int k) {    
    while (k >>= 1) {
      node.at(k) = f(reflect((k << 1) | 0), reflect((k << 1) | 1));
    }
  }
  void update(int a, int b, U x) {
    thrust(a += n); thrust(b += n - 1);
    for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) lazy.at(l) = h(lazy.at(l), x), l++;
      if (r & 1) --r, lazy.at(r) = h(lazy.at(r), x);
    }
    recalc(a); recalc(b);
  }
  void set_val(int a, T x) {
    thrust(a += n);
    node.at(a) = x; lazy.at(a) = u;
    recalc(a);
  }
  T query(int a, int b) {
    thrust(a += n); thrust(b += n-1);
    T vl = t, vr = t;
    for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vl = f(vl, reflect(l++));
      if (r & 1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }
};

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  auto f = [&](int x, int y) {return __gcd(x, y);};
  SegmentTree<int, int> ST(f, f, f, 0, 0);
  ST.build(A);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int l = ST.query(0, i);
    int r = ST.query(i + 1, N);
    ans = max(ans, __gcd(l, r));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 2816
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, R;

const int SIZE = 1 << 17;
struct Segtree {
    int node[2 * SIZE];
    Segtree () {
        memset(node, 0, sizeof(node));
    }
    void reset() {
        memset(node, 0, sizeof(node));
    }
    void add(int x, int val) {
        x += SIZE - 1;
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = (node[2*x+1] + node[2*x+2]);
        }
    }
    int query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        int vl = query(a, b, l, mid, 2*k+1);
        int vr = query(a, b, mid, r, 2*k+2);
        return vl + vr;
    }
};

int fact[100010];
Segtree treeone;
 
signed main() {
    fact[0] = 1;
    for(int i=1; i<=100005; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    while(cin >> N, N) {
        cin >> R;
        vector<int> perm(N);
        iota(perm.begin(), perm.end(), 0);
        for(int i=0; i<R; i++) {
            int s, t; cin >> s >> t;
            s--; t--;
            swap(perm[s], perm[t]);
        }

        treeone.reset();
        int ans = 0;
        for(int i=0; i<N; i++) {
            int mul = fact[N - i - 1];
            int val = perm[i] - treeone.query(0, perm[i]);
            (ans += mul * val) %= MOD;
            treeone.add(perm[i], 1);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6708
import math

A,B,H,M = map(int,input().split())

a = 360 * (H/12 + 1/12*M/60)
b = 360 * M/60

c = abs(a-b)
c = min(c,360-c)
cos = math.cos(math.radians(c))

hypotenuse = math.sqrt(math.pow(A, 2) + math.pow(B, 2) - 2 *A*B*cos)

print(hypotenuse)

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

int main()
{
  int x;
  cin >> x;
  
  int fh = x / 500;
  x -= 500 * fh;
  
  int fo = x / 5;
  
  cout << fh * 1000 + fo * 5 << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
const ll mod = 1e9+7;
const ll INF = 0x3f3f3f3f;
const ll maxn = 1e5 + 5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;
ll qpow(ll a, ll b) { ll s = 1; while (b > 0) { if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1; }return s; }



ll a[maxn];
int main(){
	ll n;
	cin>>n;
	ll max=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>max) max=a[i];
	}
	ll min=INF;
	for(int i=1;i<=max;i++){
		ll sum=0;
		for(int j=0;j<n;j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		if(sum<min) min=sum;
	}
	cout<<min<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int W,H,x,y,r;

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

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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a > b)
		swap(a,b);
	if(a > c)
		swap(a,c);
	if(b > c)
		swap(b,c);
	if(a == b && c != b)
		cout << "Yes";
	else if(b == c && a != b)
		cout << "Yes";
	else
		cout << "No";
	return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define lpx(i,x,n) for(int i=x; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<char, int> pci;
typedef vector<pii> vp;
typedef vector<pci> vpc;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 500000;
int mx = -1e9 , mn = 1e9 ;
int arr[N] ;

int dcmp(double x, double y)
{
    return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}



int main()
{

    string s;cin>> s;
    int r = 0 , l = 0 , c = 0,j=0;
    lp(i,s.size()){
        ++c;
        if(s[i]=='R')++r;
        else ++l;
        if((i < s.size()-1 &&s[i] == 'L' && s[i+1] == 'R')||(i == s.size()-1)){
            //cout << i << ' ' << c << endl;
            if(c%2==0)
                arr[j++] = c/2, arr[j++]=c/2;
            else{
                if(r%2)
                    arr[j++] = c/2, arr[j++] = 1 + (c/2);
                else
                    arr[j++] = 1 + (c/2), arr[j++] = c/2;
            }
            r = 0, l = 0,c=0;
        }
    }
    j = 0;
    lp(i,s.size()){
        if(i < s.size()-1 && s[i] == 'R' && s[i+1] == 'L'){
            cout << arr[j++] << ' ' << arr[j++] << ' ' ;
            ++i;
        }
        else
            cout << "0 ";
    }
    cout << endl;

    return 0;
}
























Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n, d; cin >> n >> d;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    lint x, y; cin >> x >> y;
    if (x * x + y * y <= d * d) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<string, int> Psi;
typedef pair<long long , long long> P;
typedef long long int64;
typedef long long lint;
#define REP(i, n) for(int (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(int (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define FST first
#define SND second

signed main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace AtCoder {
    class Practice {
        static void Main() => CustomMain();

        static void Solve() {
            var n = ReadInt();
            var a = ReadLongArray();

            Array.Sort(a);

            long ans = 0;
            for (int i = n; i < 3 * n; i += 2) {
                ans += a[i];
            }

            WriteAnswer(ans);
        }


        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }

        static long GCD(long a, long b) {
            return b != 0 ? GCD(b, a % b) : a;
        }
    }
}

Measured memory_bytes: 41804
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll a, p;
    cin >> a >> p;
    cout << (3 * a + p) / 2 << endl;
    return 0;
}

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

#define INF 1e+9

int N,W;
int w[101],v[101];
int memo[110][11000];

int knapsack(int i, int j){
	  if(j < 0) return -INF; // ??????????¶?????????????
	  if(i == N) return 0;   // ????????????????????????
	  if(memo[i][j] != -1) return memo[i][j]; //???????¨??????????

	  int ans= 0;
	  ans = max(knapsack(i+1,j), knapsack(i+1, j-w[i]) + v[i]);

	  memo[i][j] = ans;
	  return ans;
}

int _knapsack(int i, int j){
	  if(j < 0) return -INF; // ??????????¶?????????????
	  if(i == N) return 0;   // ????????????????????????

	  int ans= 0;
	  ans = max(knapsack(i+1,j), knapsack(i+1, j-w[i]) + v[i]);

	  return ans;
}

int knapsack_loop(){

	  int dp[N+1][W+1];
	  for(int i=0; i<=N; i++)
			for(int j=0; j<=W; j++) dp[i][j] = -INF;

	  dp[0][0] = 0;
	  for(int i=1; i<=N; i++){
			for(int j=0; j<=W; j++){
				  dp[i][j] = max(dp[i][j], dp[i-1][j]);
				  if(j-w[i] < 0) continue;
				  dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
			}
	  }
	  int ans=0;
	  for(int i=0; i<=W; i++) ans = max(ans,dp[N][i]);
	  return ans;
}



int main(){
	  cin >> N >> W;
	  for(int i=0; i<N; i++) cin >> v[i+1] >> w[i+1];
	  memset(memo,-1,sizeof(memo));
	  cout << knapsack_loop() << endl;
}

Measured memory_bytes: 9840
#include <bits/stdc++.h>
using namespace std;
#define lul           1000000007LL
#define MOD lul
#define ll            long long
#define ld            long double
#define all(x)        (x).begin (),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define pb            push_back
#define mp            make_pair
#define F             first
#define S             second
#define vi            vector<ll>
#define pii           pair<ll,ll>
#define vii           vector<pii>
#define mi            map<ll,ll>
#define lb            lower_bound
#define ub            upper_bound
#define endl          "\n"
#define si            set<ll>
#define gcd(a,b)      __gcd(a,b)
#define lcm(a,b)      (a*(b/gcd(a,b)))
#define rep(i,a,b)    for(unsigned ll i=a;i<b;i++)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  int modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  int modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  int modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  int modPow(ll b, ll p) { int r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  int modInv(int a) { return modPow(a, MOD-2); }
inline  int modDiv(int a,int b) { return modMul(a, modInv(b)); }
inline  int fact(int r){ int ans=1;while(r)ans=modMul(ans,r),r--;return ans; }
inline  int invfact(int r){int ans=1;while(r)ans=modMul(ans,modInv(r)),r--; return ans;}
const ll INF = 1e9+1;
ll power(ll a, ll n) {
    if (n==0) return 1;
    ll k=power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}
bool isPrime(int num){
    bool flag=true;
    for(int i = 2; i*i <= num ; i++) {
       if(num % i == 0) {
          flag = false;
          break;
       }
    }
    return flag;
}
vi v;
void SieveOfEratosthenes()
{
    const int n = 1000000;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }

    // Print all prime numbers
    for (int p=2; p<=n; p++)
       if (prime[p])
          v.pb(p);
}

void solve()
{
    ll n; cin>>n;
    set<string> s;
    for(int i=0; i<n; i++){
        string st;
        cin>>st;
        s.insert(st);
    }
    cout<<s.size();
}

int main()
{
    SPEED;
    ll t = 1;

   // cin>>t;

    while(t--) solve();

   return 0;
}


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

int main() {
    int n,cnt=0;
    cin >> n;
    vector<int>v(n);
    for(int i = 0;i<n;i++){
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    int len = v.size();
    for(int i = 0;i<len-2;i++){
        for(int j = i + 1;j<len-1;j++){
            for(int k = j + 1;k<len;k++){
                if(v[i] + v[j] > v[k] && v[i]!=v[j] && v[i]!=v[k] && v[j]!=v[k]) cnt++;
            }
        }
    }
    cout << cnt << endl;

    
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    i64 x, y;
    cin >> x >> y;
    i64 ans = 1e18;
    forn(d1, 2) forn(d2, 2) {
        i64 res = d1 + d2;
        i64 xx = x * (d1 ? -1 : 1);
        i64 yy = y * (d2 ? -1 : 1);
        if (xx <= yy) uin(ans, res + yy - xx);
    }
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

StNode* fnFind(StNode* poRoot, int nNo)
{
  StNode* poNode = poRoot;
  while (poNode != nullptr)
    if (nNo == poNode->m_nKey)
      return poNode;
    else if (nNo < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;

  return nullptr;
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'f')
    {
      int nNo;
      cin >> nNo;
      if (fnFind(rpoRoot, nNo))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
//fnPstOrder(poRoot);
  return 0;
}

Measured memory_bytes: 21924
from collections import deque

n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
ab = list(map(lambda x: [x[0], x[1], x[0]+x[1]], ab))
ab.sort(key=lambda x:x[2], reverse=True)
ab=deque(ab)
count = 0
ans=0
while len(ab)>0:
  a, b, dif = ab.popleft()
  if count%2==0:
    ans+=a
  else:
    ans-=b
  count+=1
print(ans)


Measured memory_bytes: 41536
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(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 nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        long ans=0,mod=1000000007;
        while(t-->0)
        {
         int n=sc.nextInt(),d=0;
         for(int i=n;;i++)
         {
             if(isprime(i))
             {pw.println(i);break;}
         }
        }
           pw.close();
    }
    static boolean isprime(int p)
    {
        if (p==1) return false;
        for(int i=2;i<=Math.sqrt(p);i++)
        {
            if(p%i==0) return false;
        }
        return true;
    }
}
  

Measured memory_bytes: 32804
N, *A = `dd`.split.map &:to_i
counts = {}
A.each{ |a| counts[a] = (counts[a] || 0) + 1 }
S = counts.values.reduce(0){ |s,m| s + m*(m-1)/2 }
A.each{ |a|
  p S - (counts[a] - 1)
}

Measured memory_bytes: 53640
#include <iostream>
#include <cmath>

using namespace std;

bool IsPrime(int n)
{
    if (n == 1)
        return false;
    int s = sqrt(n);
    for (int i = 2; i <= s; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

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

    int counter = 0;
    for (int i = 0; i < num; i++)
    {
        int target;
        cin >> target;
        if (IsPrime(target))
            counter++;
    }

    cout << counter << endl;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int digit_sum(int x){
    int ans = 0;
    while (x > 9){
        ans += x%10;
        x /= 10;
    }
    ans += x%10;
    return ans;
}


int main() {
    int N;
    cin >> N;
    if (N % digit_sum(N) == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);

$a = substr($n,-1);

if($a == 3){
    echo('bon');
}else if ($a == 0 ||$a == 1 ||$a == 6 ||$a == 8){
    echo('pon');
}else{
    echo('hon');
}

?>

Measured memory_bytes: 16092
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;

// グラフのdfs
VI sorted_ver;
VI used;
VVI edge;

long dfs(long node){
	if (used[node] == 1) return (-1);
	if (used[node] == 2) return 0;
	used[node] = 1;
	REP(i,edge[node].size()) {
		if(dfs(edge[node][i]) == (-1)) return (-1);
	}
	used[node] = 2;
	sorted_ver.push_back(node);
	return 0;
}

int main(void){
	long V,E;
	cin >> V >> E;
	sorted_ver = VI(0);
	used = VI(V,0);
	edge = VVI(V,VI(0));

	REP(i,E){
		long s,t;
		cin >> s >> t;
		edge[s].push_back(t);
	}

	REP(i,V){
		if (used[i] != 2) {
			if (dfs(i) == (-1)) {
				cout << "CYCLE EXIST" << endl;
				exit(0);
			}
		}
	}
	
	#ifdef DEBUG
		dump2d_arr(edge);
		dump1d_arr(sorted_ver);
	#endif
	RREP(i,sorted_ver.size()-1) cout << sorted_ver[i] << endl;

	return 0;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<int> E(1001,-1);
  for(int i = 2; i <= 1000; i++){
    if(E.at(i)==-1){
      E.at(i)=i;
      for(int j = 2; i*j <= 1000; j++){
        if(E.at(i*j)==-1)E.at(i*j)=i;
      }
    }
  }
  map<int,int> divisor;
  for(int i = 2; i <= n; i++){
    int tmp = i;
    while(E.at(tmp)!=tmp){
      divisor[E.at(tmp)]++;
      tmp/=E.at(tmp);
    }
    if(divisor.count(tmp))divisor[tmp]++;
    else divisor[tmp] = 1;
  }
  ll res = 1;
  for(auto p : divisor){
    int count = p.second;
    count++;
    res*=count;
    res%=MOD;
  }
  cout<<res<<endl;
}

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

using namespace std;

const int N = 2000006;
const int mod = 1e9+7;
int add(int a, int b) {
	return a + b >= mod ? a + b - mod : a + b;
}
int mul(int a, int b) {
	return int(1LL * a * b % mod);
}
int fexp(int b, int e = mod - 2) {
	int ans = 1;
	while(e) {
		if(e & 1) ans = mul(ans, b);
		b = mul(b, b);
		e /= 2;
	}
	return ans;
}

int fat[N], ifat[N];

int C(int n, int k) {
	if(n < k) return 0;
	return mul(mul(fat[n], ifat[k]), ifat[n - k]);
}

int main() {
	fat[0] = 1;
	for(int i = 1; i < N; i++) fat[i] = mul(i, fat[i - 1]);
	ifat[N - 1] = fexp(fat[N - 1]);
	for(int i = N - 2; i >= 0; i--) ifat[i] = mul(i + 1, ifat[i + 1]);

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	int ans = 0;
	
	for(int i = r1; i <= r2; i++) {
		int sum = add(C(i + c2 + 1, i + 1), mod - C(i + c1, i + 1));
		ans = add(ans, sum);
	}

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


Measured memory_bytes: 15872
// Problem : C - A+...+B Problem
// Contest : Virtual Judge - practice contest 2
// URL : https://vjudge.net/contest/390405#problem/C
// Memory Limit : 262 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#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,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll N,A,B;
	cin>>N>>A>>B;
	if(A>B || N==1 && A!=B)
	{
		cout<<0<<nl;
		return 0;
	}
	cout<<(N-1)*B+A-(N-1)*A-B+1<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3644