akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;

namespace CGL_2_B_Intersection
{
	class Program
	{
		static void Main ( string[] args )
		{
			int inputCount = int.Parse (Console.ReadLine ());
			StringBuilder output = new StringBuilder (inputCount * 2);

			for (int lp = 0; lp < inputCount; lp++)
			{
				int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

				Vector2 point1 = new Vector2 (inputNum[0], inputNum[1]);
				Vector2 point2 = new Vector2 (inputNum[2], inputNum[3]);
				Vector2 point3 = new Vector2 (inputNum[4], inputNum[5]);
				Vector2 point4 = new Vector2 (inputNum[6], inputNum[7]);

				if (Vector2.Intersection (point1, point2, point3, point4))
				{
					output.AppendLine ("1");
				}
				else
				{
					output.AppendLine ("0");
				}
			}

			Console.Write (output);
		}
	}

	class Vector2
	{
		public Vector2 ( decimal x, decimal y )
		{
			this.X = x;
			this.Y = y;
		}

		public decimal X { private set; get; }
		public decimal Y { private set; get; }

		public static Vector2 operator + ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X + ob2.X, ob1.Y + ob2.Y);
		}
		public static Vector2 operator - ( Vector2 ob1, Vector2 ob2 )
		{
			return new Vector2 (ob1.X - ob2.X, ob1.Y - ob2.Y);
		}
		public static Vector2 operator * ( Vector2 ob, decimal scalar )
		{
			return new Vector2 (ob.X * scalar, ob.Y * scalar);
		}

		public decimal Length ()
		{
			return X * X + Y * Y;
		}

		public static decimal DotProduct ( Vector2 line1, Vector2 line2 )
		{
			return line1.X * line2.X + line1.Y * line2.Y;
		}
		public static decimal CrossProduct ( Vector2 line1, Vector2 line2 )
		{
			return line1.X * line2.Y - line1.Y * line2.X;
		}

		public const int Counter_Clockwise = 1;
		public const int Clockwise = -1;
		public const int OnlineBack = 2;
		public const int OnlineFront = -2;
		public const int OnSegment = 0;

		public static int PointState ( Vector2 point1, Vector2 point2, Vector2 point3 )
		{
			Vector2 line1 = point2 - point1;
			Vector2 line2 = point3 - point1;

			decimal crossProduct = CrossProduct (line1, line2);

			if (crossProduct > 0m)
			{
				return Counter_Clockwise;
			}
			else if (crossProduct < 0m)
			{
				return Clockwise;
			}
			else if (DotProduct (line1, line2) < 0m)
			{
				return OnlineBack;
			}
			else if (line1.Length () < line2.Length ())
			{
				return OnlineFront;
			}

			return OnSegment;
		}

		public static bool Intersection ( Vector2 line1Point1, Vector2 line1Point2, Vector2 line2Point1, Vector2 line2Point2 )
		{
			Vector2 p1 = line1Point1;
			Vector2 p2 = line1Point2;
			Vector2 p3 = line2Point1;
			Vector2 p4 = line2Point2;

			return (PointState (p1, p2, p3) * PointState (p1, p2, p4) <= 0 &&
				PointState (p3, p4, p1) * PointState (p3, p4, p2) <= 0);
		}
	}
}

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
 
long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}
 
int main() {
  long long n;
  cin >>n;
  long long kotae=0;
  if(360%n==0)kotae=360/n;
  else kotae=lcm(n,360)/n;
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
int main(void){
    int h,w;
    cin>>h>>w;
    int sum=1;
    string s[h];
    rep(i,h){
        cin>>s[i];
    }
    rep(i,h){
        cout<<s[i]<<endl<<s[i]<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> a(N);
    for(auto& t : a) cin >> t;
    vector<int> pos(N);
    for(int i=0;i<N;i++) pos[a[i]-1] = i;
    long long res = 0;
    set<int> S;
    S.insert(-1);
    S.insert(N);
    for(int i=0;i<N;i++){
        int p = pos[i];
        auto it = S.upper_bound(p);
        long long m = 1;
        m *= *it-p;
        --it;
        m *= p-*it;
        res += (i+1)*m;
        S.insert(p);
    }
    cout << res << endl;
}

Measured memory_bytes: 11136
import sys
input = sys.stdin.readline

l, r = map(int, input().split())
if r - l > 2019:
    ans = 0
else:
    ans = float('inf')
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i * j) % 2019)
print(ans)


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

int main() {
    int K,A,B;
    cin >> K;
    cin >> A;
    cin >> B;
    int ans = 0;
    for(int i=A;i<B+1;i++){
        if(i % K == 0){
            ans =1;
            break;
        }
    }
    if(ans == 0){
        cout << "NG"<< endl;
    }else{
        cout << "OK"<< endl;
    }
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

typedef pair<int,int> pii;
typedef unsigned long long int ll;
typedef long double ld;

const int DMAX = 1e5+10;

vector <int> vec;
vector <int> arb[DMAX];

int V[DMAX];

ll n;

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

    int t,i,j;

    cin>>n;
    n+=2;
    n=(1LL<<n)-2;
    cout<<n<<'\n';

    return 0;
}


Measured memory_bytes: 2560
(let [[s t] (clojure.string/split (read-line) #" ")
      [a b] (map read-string (clojure.string/split (read-line) #" "))
      u (read-line)]
  (cond (= s u) (println (dec a) b)
        (= t u) (println a (dec b))
        :else (println a b)))


Measured memory_bytes: 83540
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(lint i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint p=1e9+7;

lint gcd(lint m,lint n){
  if(n==0)return m;
  else return gcd(n,m%n);
}

lint lcm(lint m,lint n){
  return m/gcd(m,n)*n;
}

int main(){
  lint pow2[200001];
  pow2[0]=1;
  FOR(i,1,200001){
    pow2[i]=(pow2[i-1]*2)%p;
  }
  lint N;
  cin>>N;
  map<pair<lint,lint> ,lint> m;
  REP(i,N){
    lint A,B;
    cin>>A>>B;
    if(A==0 and B==0 ){
      m[make_pair(0,0)]++;
      continue;
    }
    lint K=gcd(A,B);
    A/=K;
    B/=K;
    if(A<0){
      A*=-1;B*=-1;
    }else if(A==0)B=-1;
    m[make_pair(A,B)]++;
  }
  vector<pair<lint,lint> >v;
  for(auto e:m){
    // cerr<<e.first.first<<" "<<e.first.second<<":"<<e.second<<endl;
    if(e.first.first>0){
      v.push_back(make_pair(e.second,m[make_pair(e.first.second,e.first.first*-1)]));
    }
  }
  lint ans=1;
  lint t=N;
  for(auto e:v){
    if(e.second==0)continue;
    t-=e.first+e.second;
    // cerr<<e.first<<" "<<e.second<<endl;
    lint temp=pow2[e.first]+pow2[e.second]-1;
    temp+=p;
    temp%=p;
    // cerr<<temp<<endl;
    ans*=temp;
    ans%=p;
  }
  lint m0=m[make_pair(0,0)];
  t-=m0;
  ans*=pow2[t];
  ans+=p-1;
  ans%=p;
  ans+=m0;
  ans%=p;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 36960
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N, L; cin >> N >> L;
    vector<string> S;
    string res = "";
    for (int i = 0; i < N; i++)
    {
        string Si; cin >> Si;
        S.push_back(Si);
    }
    sort(S.begin(), S.end());
    for (int i = 0; i < N; i++)
    {
        res += S.at(i);
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
bool sosu[1000010]={1,1,0};
int main(){
	for(int i=4;i<1000010;i+=2)sosu[i]=true;
	for(int i=3;i<1000010;i+=2)
		for(int j=i*3;j<1000010;j+=2*i)sosu[j]=true;
	
	int n;
	while(cin>>n){
		int co=0;
		loop(i,2,n+1)if(!sosu[i])co++;
		cout<<co<<endl;
	}
}

Measured memory_bytes: 2136
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int dp[41][401][401];
int main() {
    rep(i, 41) rep(j, 401) rep(k, 401) dp[i][j][k] = inf;
    dp[0][0][0] = 0;
    int n, ma, mb; cin >> n >> ma >> mb;
    rrep(l, 1, n + 1) {
        int a, b, c; cin >> a >> b >> c;
        for (int i = l - 1; i >= 0; --i) {
            rep(j, 401) {
                rep(k, 401) {
                    if (dp[i][j][k] != inf && j + a <= 400 && k + b <= 400) {
                        chmin(dp[l][j + a][k + b], dp[i][j][k] + c);
                    }
                }
            }
        }
        chmin(dp[l][a][b], c);
    }
    int i = 1, ans = inf;
    while (i * ma <= 400 && i * mb <= 400) {
        rep(l, n + 1) chmin(ans, dp[l][i * ma][i * mb]);
        i++;
    }
    if (ans != inf) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}


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

#ifdef LOCAL_DEBUG
    #include "/home/laxsuryavanshi/Desktop/cp/trace.hpp"
#else
    #define trace(...)
#endif // LOCAL_DEBUG

int32_t main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0); std::cout.tie(0);
    #ifdef LOCAL_INPUT
    freopen("in", "r", stdin);
    #endif
    typedef long long ll;
    ll x, k, d; cin>>x>>k>>d;
    if (static_cast<double>(k) / abs(x) * d > 1.) {
        k -= (abs(x) / d);
        auto nearest = abs(x) % d;
        if (nearest == 0) {
            if (k % 2 == 0) {
                cout<<0;
                return 0;
            } else {
                cout<<d;
                return 0;
            }
        }
        if (x < 0) nearest = -nearest;
        
        if (k % 2 == 0) x = nearest;
        else {
            if (x < 0) {
                trace(1);
                x = (nearest + d);
            }
            else {
                trace(2, x, d);
                x = (nearest - d);
            }
        }
        trace(nearest);
    } else {
        if (x > 0ll) x -= k * d;
        else x += k * d;
    }
    cout<<abs(x);
}


Measured memory_bytes: 3648
MOD=10**9+7
class Fp(int):
    def __new__(self,x=0):return super().__new__(self,x%MOD)
    def inv(self):return self.__class__(super().__pow__(MOD-2,MOD))
    def __add__(self,value):return self.__class__(super().__add__(value))
    def __sub__(self,value):return self.__class__(super().__sub__(value))
    def __mul__(self,value):return self.__class__(super().__mul__(value))
    def __floordiv__(self,value):return self.__class__(self*self.__class__(value).inv())
    def __pow__(self,value):return self.__class__(super().__pow__(value%(MOD-1), MOD))
    __radd__=__add__
    __rmul__=__mul__
    def __rsub__(self,value):return self.__class__(-super().__sub__(value))
    def __rfloordiv__(self,value):return self.__class__(self.inv()*value)
    def __iadd__(self,value):self=self+value;return self
    def __isub__(self,value):self=self-value;return self
    def __imul__(self,value):self=self*value;return self
    def __ifloordiv__(self,value):self=self //value;return self
    def __ipow__(self,value):self=self**value;return self
    def __neg__(self):return self.__class__(super().__neg__())

class Combination:
    def __init__(self,max_n):
        self.max_n=0
        self.fact=[Fp(1)]
        self.ifact=[Fp(1)]
        self.make_fact_list(max_n)
    def C(self,n,k):return self.fact[n]*self.ifact[k]*self.ifact[n-k] if 0<=k<=n else 0
    def H(self,n,k):return self.C(n+k-1,k) if n or k else 1
    def P(self,n,k):return self.fact[n]*self.ifact[n-k] if 0<=k<=n else 0
    def make_fact_list(self,max_n):
        if max_n<=self.max_n: return
        self.fact+=[Fp(0)]*(max_n-self.max_n)
        self.ifact+=[Fp(0)]*(max_n-self.max_n)
        for i in range(self.max_n+1,max_n+1):
            self.fact[i]=self.fact[i-1]*i
            self.ifact[i]=self.ifact[i-1]//i
        self.max_n=max_n

N,K=map(int, input().split())
K=min(N-1,K)
C=Combination(N*2)
ans=Fp(1)
for i in range(1,K+1):
    ans+=C.C(N,i)*C.H(N-i,i)
print(ans)

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 1e5 + 10;

int x, y, a, b, c;
ll ar1[N], ar2[N], ar3[N]; 

vector <ll> ar12;
ll ans;

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

    cin >> x >> y >> a >> b >> c;
    for (int i=1;i<=a;i++){
        cin >> ar1[i];
    }
    for (int i=1;i<=b;i++){
        cin >> ar2[i];
    }
    for (int i=0;i<c;i++){
        cin >> ar3[i];
    }
    sort(ar1 + 1, ar1 + a + 1);
    sort(ar2 + 1, ar2 + b + 1);
    sort(ar3, ar3 + c, greater<ll>());

    for (int i=1;i<=x;i++){
        ar12.pb(ar1[a - i + 1]);
    }
    for (int i=1;i<=y;i++){
        ar12.pb(ar2[b - i + 1]);
    }

    sort(ar12.begin(), ar12.end());
    for (int i=0;i<min(x + y, c);i++){
        // cout << ar12[i] << " ";
        if (ar12[i] < ar3[i]){
            ar12[i] = ar3[i];
        } else{
            break;
        }
    }

    for (auto x : ar12){
        // cout << x << " ";
        ans += x;
    }
    // cout << el;
    cout << ans << el;

    return 0;
}

Measured memory_bytes: 4852
import math
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)


sA = sorted(A)
sB = sorted(B, reverse=True)



m = N//2

if N%2 == 1:
    minMid = sA[m]
    maxMid = sB[m]

    print(maxMid-minMid+1)
    exit()
else:
    m = m-1
    minMidL = sA[m]
    maxMidL = sB[m+1]

    minMidH = sA[m+1]
    maxMidH = sB[m]
    # print(minMidL, maxMidL)
    # print(minMidH, maxMidH)
    # print("=======")
    ans = set()
    aa = minMidL + minMidH
    bb = maxMidL + maxMidH
    # print(aa, bb)
    print(bb-aa + 1)
    # for i in range(minMidL, maxMidL+1):
    #     for j in range(max(i, minMidH), maxMidH+1):
            
    #         ans.add(i+j)
    # print(len(ans))






Measured memory_bytes: 28648
#include <stdio.h>

int main(void)
{
    int A,B,C,X,i,j,e,c;
    c = 0;
    scanf("%d%d%d%d",&A,&B,&C,&X);
    for(i = 0;i <= A;i++){
        for(j = 0;j <= B;j++){
            for(e = 0;e <= C;e++){
                if(500 * i + 100 * j + 50 * e == X) c++;
            }
        }
    }
    printf("%d",c);
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <algorithm>
#include <string>

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

    auto t = s;
    std::reverse(t.begin(), t.end());

    int ans = 0;
    for (int i = 0; i < (int)s.length(); ++i) {
        if (s[i] != t[i]) ++ans;
    }

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


Measured memory_bytes: 256
N, M = map(int, input().split())

g = [ [False] * N for _ in range(N) ]
for _ in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  g[a][b] = True
  g[b][a] = True

vis = [False] * N
ans = 0
def f(v, d):
  global vis, ans
  if d == N:
    ans += 1
    return
  for nxt in range(N):
    if g[v][nxt] and not vis[nxt]:
      vis[nxt] = True
      f(nxt, d + 1)
      vis[nxt] = False

vis[0] = True
f(0, 1)
print(ans)

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

int main(){
    int N;
    int ans = 0;

    //input
    cin >> N;

    char s[N + 1];

    cin >> s;

    for(int i = 0; i < N; i++){
        if(s[i] == 'R'){
            ans++;
        }else{
            ans--;
        }
    }

    if(ans > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

int main() {
  int n;cin>>n;
  int cnt1=1,cnt2=1;
  rep(i,n){
    int a;cin>>a;
    if(a%2==0)cnt2*=2;
    cnt1*=3;
  }
  cout<<cnt1-cnt2<<endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
using namespace std;

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

    vector<pair<int, int>> c;
    c.reserve(n);
    for (int64_t i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;

        c.emplace_back(make_pair(a, b));
    }
    sort(c.begin(), c.end());

    for (int64_t i = 0; i < n; ++i)
    {
        const auto &t = c[i];
        if (t.second >= k)
        {
            cout << t.first << endl;
            break;
        }
        else
        {
            k -= t.second;
        }
    }
    return 0;
}


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

const int N = 1e5+9, M = 1e7, OO = 0x7f7f7f7f;

int main(){
    int n;
    scanf("%d",&n);
    vector<int>v;
    int a[10];
    for(int i=0 ; i<n ; ++i)a[i]=i;
    int x[10] , y[10];
    for(int i=0 ; i<n ; ++i)scanf("%d %d",x+i , y+i);
    double sum=0;
    int d=0;
    do{
        ++d;
        for(int i=0 ; i<n-1 ; ++i){
            sum += (double)sqrt( ( (x[ a[i] ]-x[ a[i+1] ]) * (x[ a[i] ]-x[ a[i+1] ]) ) + ( (y[ a[i] ]-y[ a[i+1] ]) * (y[ a[i] ]-y[ a[i+1] ]) ) );
        }
    }while(next_permutation(a,a+n));
    //cout << sum <<endl;
    printf("%.10lf\n", sum/(double)d);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll N, K;
    cin >> N >> K;
    if (N % K == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    if (abs(N - K) >= N)
    {
        cout << N << endl;
        return 0;
    }
    ll cnt = 0;
    N%=K;
    while (true)
    {
        ll nextN = abs(N - K);
        if (N <= nextN)
        {
            cout << N << endl;
            return 0;
        }
        N = nextN;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N,M,X=map(int,input().split())
C,A=[],[]
min=10000000
for i in range(N):
  A.append(list(map(int,input().split())))
A=np.matrix(A)
for i in range(2**N):
  NP=np.matrix(list(map(int,list(format(i,'b').zfill(N)))))
  result=np.dot(NP,A)
  if np.all(result[0,1:]>=X):
    if min>result[0,0]:
      min=result[0,0]
if min==10000000:
  min=-1
print(min)



Measured memory_bytes: 26816
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 200001;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static boolean [][] grid;
    static int [] bishopr = {-1,1,-1,1};
    static int [] bishopc = {1,1,-1,-1};
    static long H,W,cnt;
    public static void main(String args[]) throws IOException {
           int X = in.nextInt();
           int N = in.nextInt();
           BitSet bs = new BitSet();
        for(int i=0;i<N;i++){
            bs.set(in.nextInt(),true);
        }
        int min = Integer.MAX_VALUE;
        int index =0;
        for(int i=0;i<=200;i++){
            if(!bs.get(i)&&Math.abs(X-i)<min){
                min = Math.abs(X-i);
               index = i;
            }
        }
        out.println(index);

        out.flush();
        }
       static boolean isValid (int r, int c){
           if(r>=0&&r<H&&c>=0&&c<W){
               return true;
           }
           return false;
       }
        private static void dfs(int r, int c) {
            for(int i=0;i<4;i++){
                int nr = bishopr[i] +r;
                int nc = bishopc[i]+c;
                if(isValid(nr, nc)&&!grid[nr][nc]){
                    cnt++;
                    grid[nr][nc] = true;
                    dfs(nr, nc);
                }
            }
        }

        static boolean isEven(long a) {
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
    

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           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;
        }
  
     }
}

Measured memory_bytes: 33040
sub f{
    my $d=@_[0];
    return $F{$d} if $F{$d}!=undef;
    return 0 if $d<0;
    my $result = &f($d-1) + &f($d-2);
    $F{$d}=$result%$mod;
    return $result%$mod;
}
($N,$M)=glob<>;$mod=1e9+7;
@A=(-1);
for(1..$M){
    $a=<>;
    push(@A,$a);
}
push (@A,$N+1);
$D[$_]=$A[$_+1]-$A[$_]-1 for(0..$M);
$F{0}=0;$F{1}=1;$F{2}=1;
$o=1;
$o=($o*&f($_))%$mod for(@D);
print $o

Measured memory_bytes: 97280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j,k;


int main(){
   ll N;
   cin>>N;
   cout<<800*N-(N/15)*200<<endl;


}

Measured memory_bytes: 256
n = int(input())
xl = sorted([tuple(map(int, input().split())) for _ in range(n)])

tmp = sum(xl[0])

res = 0
for i in range(1, n):
    x, l = xl[i]
    if tmp > x-l:
        res += 1
        tmp = min(tmp, x+l)
    else:
        tmp = x+l

print(n-res)

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

int main() {
	int A,B,C,D,p_t,p_b;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	
	if (A >= B){
		p_t = B;
	}else{
		p_t = A;
	}
	if (C >= D){
		p_b = D;
	}else{
		p_b = C;
	}
	
	cout << (p_b + p_t) << endl;
	
	return 0;
}

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

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

int main(){
	string s ; cin >> s ;
	int n = s.size() ;
	vector<int> l(n+1) ;
	vector<int> r(n+1) ;
	l.at(0) = r.at(n) = 0 ;
	int left,right ;
	left = right = 0 ;
	for(int i=0;i<n;i++){
		if(s.at(i)=='<'){
			left++ ;
		}else{
			left = 0 ;
		}
		l.at(i+1) = left ;
	}
	for(int i=n-1;i>=0;i--){
		if(s.at(i)=='>'){
			right++ ;
		}else{
			right = 0 ;
		}
		r.at(i) = right ;
	}
	long long int ans = 0 ;
	for(int i=0;i<n+1;i++){
		ans += max(l.at(i),r.at(i)) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 4740
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
    int  T,X;
    cin >> T >> X;
    cout << (float)T / (float)X;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

const int MAX_N = 500000;
int N;
const int K = 10;
int s[MAX_N];
int s2[MAX_N];
int cache[MAX_N];

int dp(int v) {
  if (v >= N) return false;
  if (v == N - 1) return true;
  if (cache[v] != -1) return cache[v];
  bool asdf = false;
  for (int i = v + 1; i < N; ++i) {
    if ((i - v) * 10 > s[v]) break;
    if (dp(i)) {
      asdf = true;
      break;
    }
  }
  cache[v] = asdf;
  return asdf;
}

int main() {
  scanf("%d", &N);
  memset(cache, -1, sizeof(cache));
  for (int i = 0; i < N; ++i) {
    scanf("%d", s + i);
  }
  bool a = dp(0);
  for (int i = 0; i < N; ++i) {
    s2[i] = s[N - i - 1];
  }
  memcpy(s, s2, MAX_N * sizeof(int));
  memset(cache, -1, sizeof(cache));
  printf(a && dp(0) ? "yes\n" : "no\n");
}

Measured memory_bytes: 17240
#include <iostream>
#include <vector>

using namespace std;

#define MOD 1000000007

typedef long long ll;

ll dp[201][201][201] = {0}; // dp[n][rest U][rest empty box] = ??´????????°

int main() {
	int N; cin >> N;
	vector<int> v;
	for (int i = 0; i < N; ++i) {
		char c; cin >> c;
		if (c != '-') {
			v.push_back(c);
		}
	}
	N = v.size();

	if (N == 0) {
		cout << 1 << endl;
		return 0;
	}
	if (v[0] == 'D') {
		cout << 0 << endl;
		return 0;
	}

	dp[0][1][1] = 1; // v[0] = 'U'
	for (int i = 0; i < N-1; ++i) {
		for (int j = 0; j < N; ++j) {
			for (int k = 0; k < N; ++k) {
				if (v[i+1] == 'U') {
					dp[i+1][j+1][k+1] = (dp[i+1][j+1][k+1] + dp[i][j][k]) % MOD;
					if (j >= 1) {
						dp[i+1][j][k] = (dp[i+1][j][k] + j * dp[i][j][k]) % MOD;
					}
				}
				else { // D
					if (k >= 1) {
//						if (dp[i][j][k]) cout << i << " " << j << " " << k << " : " << dp[i][j][k] << endl;
						dp[i+1][j][k] = (dp[i+1][j][k] + k * dp[i][j][k]) % MOD;
						if (j >= 1) {
							dp[i+1][j-1][k-1] = (dp[i+1][j-1][k-1] + j * k * dp[i][j][k]) % MOD;
						}
					}
				}
			}
		}
	}

	cout << dp[N-1][0][0] << endl;
}

Measured memory_bytes: 62416
pi = 3.1415926
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n = inp()
print(2*n*pi)
#print('No')
#print()

Measured memory_bytes: 61968
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
// ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
// bool isvalid(ll x,ll y,ll n,ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////



int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s;

    cin>>s;

    ll ans = 1;
    ll n = s.size();

    for(ll i=1;i<n;i++){

        if(s[i] == s[i-1]){

            if(i+1<n){
                ans++;
                if(i+2<n){
                    ans++;
                    i += 2;
                }else{
                    break;
                }
            }
        }else{
            ans++;
        }
    }

    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 720
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	a, _ := strconv.Atoi(Scanner())
	x := make([]int, n)
	m := 50*n + 1
	for i := 0; i < n; i++ {
		x[i], _ = strconv.Atoi(Scanner())
	}
	dp := make([][][]int, n+1)
	for i := 0; i < n+1; i++ {
		t := make([][]int, m)
		for j := 0; j < m; j++ {
			t[j] = make([]int, n+1)
		}
		dp[i] = t
	}
	dp[0][0][0] = 1
	for i := 1; i < n+1; i++ {
		for j := 0; j < m; j++ {
			for k := 0; k < n+1; k++ {
				dp[i][j][k] = dp[i-1][j][k]
			}
		}
		for j := x[i-1]; j < m; j++ {
			for k := 1; k < n+1; k++ {
				dp[i][j][k] += dp[i-1][j-x[i-1]][k-1]
			}
		}
	}
	ans := 0
	for j := 1; j < m; j++ {
		if j%a == 0 {
			if j/a <= n {
				ans += dp[n][j][j/a]
			} else {
				break
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 60240
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N; cin >> N;
  vecll AS(N);
  REP(i, N) cin >> AS[i];
  sort(AS.begin(), AS.end());
  set<ll> st;

  ll res = 0;
  REP(i, N) {
    if ((i < N) && AS[i+1] == AS[i]) {
      st.insert(AS[i]);
      continue;
    }
    auto ok = true;
    RNG(k, 1, (int)(sqrt((double)AS[i])+1)) if (AS[i]%k == 0 && ((st.find(k) != st.end()) || st.find(AS[i]/k) != st.end())) {
      ok = false;
      break;
    }

    res += ok;
    st.insert(AS[i]);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 13976
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.length()) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
#define task "atcodedr"
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define pb push_back
#define pf pop_front
#define mp make_pair
#define zs(v) (ll)(v).size()
#define BIT(x, i) (((x) >> (i)) & 1)
#define CNTBIT __builtin_popcountll
#define ALL(v) (v).begin(),(v).end()
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,b,a) for(ll i=(b);i>=(a);--i)
#define REP(i,a,b) for(ll i=(a);i<(b);++i)
typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll dx[4]={-1, 0, 1, 0}, dy[4]={0, 1, 0, -1};
const ll dxx[8]={-1, -1, 0, 1, 1, 1, 0, -1}, dyy[8]={0, 1, 1, 1, 0, -1, -1, -1};
const ll mod=1000000007; /// 998244353
const ll base=311;
const ll N=100+5;

ll n,w,a[N],b[N];
vector<ll> v[5];
void biot()
{
    cin>>n>>w;
    for(ll i=1;i<=n;++i) cin>>a[i]>>b[i];
    for(ll i=0;i<=3;++i) v[i].pb(0);
    for(ll i=1;i<=n;++i) v[a[i]-a[1]].pb(b[i]);
    for(ll i=0;i<=3;++i) sort(v[i].begin()+1,v[i].end(),greater<ll>());
    for(ll i=0;i<=3;++i)
    {
        for(ll j=1;j<zs(v[i]);++j) v[i][j]+=v[i][j-1];
    }
    ll ans=0;
    for(ll i=0;i<zs(v[0]);++i)
    {
        for(ll j=0;j<zs(v[1]);++j)
        {
            for(ll k=0;k<zs(v[2]);++k)
            {
                for(ll c=0;c<zs(v[3]);++c)
                {
                    ll t=a[1];
                    ll sumw=i*t+j*(t+1)+k*(t+2)+c*(t+3);
                    if(sumw>w) continue;
                    ans=max(ans,v[0][i]+v[1][j]+v[2][k]+v[3][c]);
                }
            }
        }
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    biot();
    return 0;
}














Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        String a = sc.next();
        String b = sc.next();

        if (a.equals("H") && b.equals("H")) {
            System.out.println("H");
            return;
        } else if (a.equals("H") && b.equals("D")) {
            System.out.println("D");
            return;
        }

        if (b.equals("H")) {
            System.out.println("D");
            return;
        } else {
            System.out.println("H");
        }
    }
}

Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl;
const int MOD = 1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<bool> is_safe(n + 1, true);
    int k;
    rep(i, m) cin >> k, is_safe[k] = false;
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    if (is_safe[1]) dp[1] = 1;
    repk(i, 2, n + 1)
    {
        if (is_safe[i - 1])
            dp[i] += dp[i - 1];
        if (is_safe[i - 2])
            dp[i] += dp[i - 2];
        dp[i] %= MOD;
    }
    cout << dp[n] << endl;
}

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

signed main(){
  
  int n;
  cin>>n;
  
  int ans = 0;
  
  for(int i=1;i<=n;i++){
    
    if( 1 <= i && i <= 9 ) ans++;
    if( 100 <= i && i <= 999 ) ans++;
    if( 10000 <= i && i <= 99999 ) ans++;
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
/*int main(){
    
    ll n;
    while (cin>>n) {
        vector<ll> v;
        for(int i=0;i<n+1;i++){
            v.push_back(i);
        }
        ll b=v[v.size()-1];
        for(int i=2;i<=n;i++){
            ll j=2;
            while(i*j<=b){
                v[i*j]=0;
                j++;
            }
        }
        ll ans=0;
        for(int i=0;i<v.size();i++){
           // cout<<v[i]<<endl;
            if(v[i]!=0)ans++;
        }
        cout<<ans-1<<endl;
    }
    
    
    return 0;
}*/
int main(){
    
    ll n;
    while(cin>>n){
       /* ll ans=0;
        for(int i=3;i<=n;i+=2){
            int flag=0;
        for(int j=3;j<=sqrt(i);j+=2){
            if(i%j==0){
                flag=1;
                break;
            }
        }
            if(flag==0){
                ans++;
            }
    }
        cout<<ans+1<<endl;*/
        
        vector<bool> IsPrime;
        if(n+1>IsPrime.size()){
            IsPrime.resize(n+1,true);
        }
        IsPrime[0]=false;
        IsPrime[1]=false;
        for(int i=2;i<=sqrt(n);i++){
            if(IsPrime[i]){
                for(ll j=2;i*j<=n;++j){
                    IsPrime[i*j]=false;
                }
        }
        
        }
        ll ans=0;
        for(int i=0;i<IsPrime.size();i++){
            if(IsPrime[i])ans++;
        }
        cout<<ans<<endl;
        }
    
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

struct edge{int to,id;};
vector<vector<int>>g;
vi ans;
int dp[1000005];

int dfs(int v){
    if(dp[v]!=-1) return dp[v];
    int res=0;
    for(int i=0;i<g[v].size();++i){
        res=max(res,dfs(g[v][i])+1);
    }
    return dp[v]=res;
}

int main(){
    int n,m;
    cin>>n>>m;
    g.assign(n, vector<int>());
    rep(i,m){
        int a,b;
        cin>>a>>b;
        --a;--b;
        g[a].PB(b);
    }
    mem(dp,-1);
    int k=0;
    rep(i,n){
        k=max(k,dfs(i));
    }
    cout<<k<<endl;
}

Measured memory_bytes: 11648
#include <stdio.h>
#include <stdlib.h>

int main()
{ char a[4];
int i,t;
 while(~scanf("%s",&a))
 { int t=0;
    for(i=0;i<4;i++)
     {
         if(a[i]=='+')
             t++;
         else
            if(a[i]=='-')
            t--;
     }
     printf("%d\n",t);
 }

    return 0;
}


Measured memory_bytes: 128
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  //最小のやつが他の敵全員を殴る（他の敵HP = 他の敵HP % 最小HP）
  //上の式の結果が0になったらそいつはどうしようもないのでリストから外す
  //一番最小のやつに交代して他の敵を殴る
  //最小のやつ以外のHPが0になるか、殴り終わった後の敵のHPが1になったら終了
  var output = list[0];
  
    for(var i = 1; i < list.length; i++){
      
      output = gcd(output,list[i]);
    }
    //myout(list);
  
  myout(output);
}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}
Main(myin());


Measured memory_bytes: 17612
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
  string t[4] = {"dream","dreamer","erase","eraser"};
  for(int i = 0 ; i < 4 ; i++){
    reverse(t[i].begin(), t[i].end());
  }
    
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  
  int i = 0;
  while(i < 4){
    if(s.substr(0,t[i].size()) == t[i]){
      s.erase(s.begin(), s.begin() + t[i].size());
      i = 0;
    }else i++;
  }
  
  if(s.size()) cout << "NO" << endl;
  else cout << "YES" << endl;
  
  return 0;
}
  
  
  
  

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

const int Limit = 100010;
using edge = struct {int to; int64_t cost;};
vector<edge> Tree[Limit];	// Vector<edge> の 配列
int64_t Depth[Limit];

// 深さ優先探索　再帰で全点の深さを得る
void dfs(int currentPoint, int parentPoint , int64_t d)
{
	Depth[currentPoint] = d;
	for(auto &e : Tree[currentPoint] ){
		if (e.to == parentPoint){continue;}
		dfs(e.to, currentPoint, d + e.cost);
	}
}

int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;

	// 頂点は 0-index とする
	int N;
	cin >> N;

	for(int i=0; i<N-1; ++i){
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--;
		Tree[a].push_back({b,c});
		Tree[b].push_back({a,c});
	}

	int K,Q;
	cin >> Q >> K;
	K--;

//	vector<int64_t> ans;

	dfs(K,-1,0);
	for(int i=0;i<Q;++i){
		int x,y;
		cin >> x >> y;
		x--;y--;
//		ans.push_back( Depth[x]+Depth[y] );
		cout << Depth[x]+Depth[y] << endl;
	}

//	for(auto i : ans){
//		cout << i << endl;
//	}

	return 0;
}


Measured memory_bytes: 14336
def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod
mod = 10**9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0,1]

k = int(input())
s = input()
t = len(s)
n = k + t
for i in range(2,n+1):
    fact.append((fact[-1] * i) % mod)
    inv.append((inv[mod % i] * (mod - (mod // i))) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)
ans = 0
for i in range(k+1):
    ans += (cmb(k-i+t-1,t-1,mod)*pow(25,k-i,mod)*pow(26,i,mod))%mod
    ans %= mod
print(ans)

Measured memory_bytes: 227108
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}
int main(void){
    int n,k;
    scanf("%d %d",&n,&k);

    int p[n];
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }

    qsort(p, n, sizeof(int), compare_int);
    /*クイックソート*/

    int ans=0;
    for(i=0;i<k;i++){
        ans+=p[i];
    }
    printf("%d\n",ans);
    return 0;
}


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

int main() {
    
  int A,B,C;
  cin >> A >> B >> C ;
  
  if((A*B)>C){
   
      cout<< C <<endl;
      
  }
  else if((A*B)<C){
   
      cout<< A*B <<endl;
      
  }
  else{
    
      cout <<C << endl;
      
  }
    
  
}


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

int main(){
	int n;
    cin >> n;
    vector<int> a(n+1, -1), b(n+1,0);
    for(int i=1; i<n+1; i++) cin >> a[i];
    
    for(int i=n; i>0; i--){
        int box=0;
        for(int j=2*i; j<n+1; j += i){
            box += b[j];
        }
        if(box%2!=a[i]){
            b[i]=1;
        }
    }
    cout << count(b.begin(),b.end(),1) << endl;
    for(int i=1; i<n+1; i++){
        if(b[i]==1){
            cout << i << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    
    int o = 0;
    int q = 0;
    rep(i, n) {
        if (a[i]%2 == 1) o++;
        if (a[i]%4 == 0) q++;
    }

    if (o+q == n) {
        yns(q+1 >= o);
    }
    else {
        yns(q >= o);
    }
    return 0;
}

Measured memory_bytes: 768
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N, K;
    std::cin >> N >> K;

    std::vector<int64_t> A(200000+1);
    for (decltype(N) i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A[t]++;
    }

    std::sort(std::begin(A), std::end(A),
              [](const auto& a, const auto& b) {
                  return a > b;
              });

    int64_t sum = 0;
    for (int64_t i = K; i < A.size();++i) {
        sum += A[i];
    }
    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 1792
n = int(input())
a = list(map(int, input().split()))
b = set()
c = [0]*n

for i in range(n, 0, -1):
  x = 0
  for j in range(2*i, n+1, i):
    x+=c[j-1]
  if a[i-1] != x%2:
    c[i-1] += 1
    b.add(i)
print(len(b))
print(*b)

Measured memory_bytes: 17224