akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T> inline void scf(T &x) {
	bool f = 0;
	x = 0;
	char c = getchar();
	while(c != '-' && (c < '0' || c > '9')) c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	if(f) x = -x;
	return;
}

template <typename T1, typename T2> void scf(T1 &x, T2 &y) {
	scf(x);
	return scf(y);
}

template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z) {
	scf(x);
	scf(y);
	return scf(z);
}

template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w) {
	scf(x);
	scf(y);
	scf(z);
	return scf(w);
}

inline char mygetchar() {
	char c = getchar();
	while(c == ' ' || c == '\n') c = getchar();
	return c;
}

template <typename T> inline bool chkmax(T &x, const T &y) {
	return y > x ? x = y, 1 : 0;
}

template <typename T> inline bool chkmin(T &x, const T &y) {
	return y < x ? x = y, 1 : 0;
}

#ifdef King_George
#define DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

//---------------------------------------------------------head----------------------------------------------------

const int maxn = 1e5 + 100;

int n, a[maxn];

int main() {
	scf(n);
	forn(i, 1, n) {
		scf(a[i]);
	}
	long long l = 2, r = 2;
	for (int i = n; i; --i) {
		long long x = a[i];
		if(l % x) {
			long long y = l / x + 1;
			l = y * x;
		}
		r -= r % x;
		if(l > r) {
			puts("-1");
			return 0;
		}
		r += x - 1;
	}
	printf("%lld %lld\n", l, r);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	IOS;
	string s,t;
	cin>>s>>t;
	int n=s.size();
	int m=t.size();
	int mn=MOD;
	for(int i=0;i<=n-m;i++)
	{
		int cnt=0;
		for(int j=0;j<m;j++)
		{
			if(s[i+j]!=t[j])
			{
				cnt++;
			}
		}
		mn=min(mn,cnt);
	}
	cout<<mn<<endl;

}

Measured memory_bytes: 3664
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

a = ['dream', 'dreamer', 'erase', 'eraser']

def solve():
    s = input()

    s = s[::-1]

    for i in range(4):
        a[i] = a[i][::-1]
    
    t = ''

    while t!=s:
        ok = False
        for i in a:
            temp = t+i
            if len(temp)<= len(s) and temp == s[:len(temp)]:
                t = temp
                ok = True
                continue
        if not ok:
            print('NO')
            return

        



    print('YES')



solve()


Measured memory_bytes: 3556
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int d,e;
  while(cin>>d>>e,d||e){
    int i,j,k;
    double m=1000;
    for(i=0;i<=d;i++){
      j=d-i;
      double di=sqrt(i*i+j*j);
      m=min(m,fabs(di-e));
    }
    cout << m << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	int N, T, E;
	
	scanf("%d %d %d", &N, &T, &E);
	
	for (int i = 0; i < N; i++){
		int x;
		scanf("%d", &x);
		for (int j = 1; x * j - T <= E; j++){
			if (abs(x * j - T) <= E){
				printf("%d\n", i + 1);
				return (0);
			}
		}
	}
	
	printf("-1\n");
	return (0);
}

Measured memory_bytes: 1024
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  let n' = fromIntegral n
  xys <- map (map (read :: String -> Double) . words) <$> getNLine_ n
  print $ ans n' xys

ans :: Double -> [[Double]] -> Double
ans n' xys = (/n') . sum $ distance <$> xys <*> xys where
  distance [a,b] [c,d] = sqrt $ (a-c)^2 + (b-d)^2

getNLine_ :: Int -> IO [String]
getNLine_ n = replicateM n getLine


Measured memory_bytes: 636
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
x = list(map(int, readline().split()))
v = [0] * 100
cnt = 0
for i in range(100):
    for xx in x:
        cnt += (xx - i) ** 2
    v[i] = cnt
    cnt = 0
print(min(v))


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

const int INF = 10000000;

int main(){
  
  while(1){
  
  int n;
  int d[11][11] = {0};
  int m=0;
  
  scanf("%d",&n);
  
  if(n == 0)break;
    for(int i = 0;i < 10;i++){
    for(int j = 0;j < 10;j++){
      if(i == j) continue;
      d[i][j] = INF;
    }
  }
  
  for(int i = 0;i < n;i++){
    int a,b,c;
    
    scanf("%d%d%d",&a,&b,&c);
    
    d[a][b] = c;
    d[b][a] = c;
    
    m = max(m,max(a,b));
    
  }
  
  m++;
  
  for(int i = 0;i < m;i++){
    for(int j = 0;j < m;j++){
      for(int k = 0;k < m;k++) d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
    }
  }
  int ans1=0,ans2=100000000;
  for(int i = 0;i < m;i++){
    int tmp = 0;
    for(int j = 0;j < m;j++){
      if(i == j)continue;
      tmp += d[i][j];
    }
    if(ans2 > tmp){
      ans2 = tmp;
      ans1 = i;
    }
  }
  
  
  printf("%d %d\n",ans1,ans2);
  }
  
  return 0;
}
      
  
  


Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <iomanip>
typedef long long ll;

using namespace std;

int main() {
    int goodsNum, maxWeight;
    cin >> goodsNum >> maxWeight;
    
    vector<ll> goodsWeight(goodsNum);
    vector<int> goodsValue(goodsNum);
    for(int i = 0; i < goodsNum; i++) {
        cin >> goodsWeight[i] >> goodsValue[i];
    }
    
    // 各商品、価値の時の重さを保持する
    vector<vector<ll>> dp = vector<vector<ll>>(goodsNum, vector<ll>(100001, 0));
    ll ans = goodsValue[0];
    for(int i = 0; i < goodsNum; i++) {
        dp[i][goodsValue[i]] = goodsWeight[i];
        if(i == 0) {
            continue;
        }
        
        for(ll j = 0; j < 100001; j++) {
            if(dp[i - 1][j] > 0) {
                // 重さが小さい方をとる(初期値の場合はそのまま代入)
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
                if(dp[i][j] == 0) {
                    dp[i][j] = dp[i - 1][j];
                }
                
                if(dp[i - 1][j] + goodsWeight[i] <= maxWeight) {
                    ans = max(ans, j + goodsValue[i]);
                    
                    // 重さが小さい方をとる(初期値の場合はそのまま代入)
                    dp[i][j + goodsValue[i]] = min(dp[i - 1][j] + goodsWeight[i], dp[i - 1][j + goodsValue[i]]);
                    if(dp[i][j + goodsValue[i]] == 0) {
                        dp[i][j + goodsValue[i]] = dp[i - 1][j] + goodsWeight[i];
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 79488
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
       int N =sc.nextInt();
       int M =sc.nextInt();
       int a=0;
      
      for(int i=1;i<=M;i++){
        a +=sc.nextInt();
      }
       if(N-a >=0){
       System.out.println(N-a);
       }
        else if(N-a <0)  {
        System.out.println("-1");
        }
    }
}

Measured memory_bytes: 46156
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

template<int MOD>
struct ModInt {
	static const int kMod = MOD;
	unsigned x;
	ModInt() :x(0) {}
	ModInt(signed x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; }
	ModInt(signed long long x_) { x_ %= MOD; if (x_ < 0)x_ += MOD; x = x_; }
	int get()const { return (int)x; }
	ModInt &operator+=(ModInt m) { if ((x += m.x) >= MOD)x -= MOD; return *this; }
	ModInt &operator-=(ModInt m) { if ((x += MOD - m.x) >= MOD)x -= MOD; return *this; }
	ModInt &operator*=(ModInt m) { x = (unsigned long long)x*m.x%MOD; return *this; }
	ModInt &operator/=(ModInt m) { return *this *= m.inverse(); }
	ModInt operator+(ModInt m)const { return ModInt(*this) += m; }
	ModInt operator-(ModInt m)const { return ModInt(*this) -= m; }
	ModInt operator*(ModInt m)const { return ModInt(*this) *= m; }
	ModInt operator/(ModInt m)const { return ModInt(*this) /= m; }
	ModInt operator-()const { return ModInt(MOD - (signed)x); }
	bool operator==(ModInt m)const { return x == m.x; }
	bool operator!=(ModInt m)const { return x != m.x; }
	ModInt inverse()const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		if (u < 0)u += MOD;
		return ModInt(u);
	}
};
template<int MOD>
ostream &operator<<(ostream &os, const ModInt<MOD> &m) { return os << m.x; }
template<int MOD>
istream &operator>>(istream &is, ModInt<MOD> &m) { signed long long s; is >> s; m = ModInt<MOD>(s); return is; };

template<int MOD>
ModInt<MOD> pow(ModInt<MOD> a, unsigned long long k) {
	ModInt<MOD> r = 1;
	while (k) {
		if (k & 1)r *= a;
		a *= a;
		k >>= 1;
	}
	return r;
}

using mint = ModInt<MOD>;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S; cin >> S;
	int n = S.size();
	auto dp = gen_v<mint>(n + 1, 13);
	dp[0][0] = 1;
	rep(i, 0, n) {
		rep(m, 0, 13) {
			int mod = m;
			mod *= 10;
			mod %= 13;
			if (S[i] == '?') {
				rep(j, 0, 10) {
					dp[i + 1][(mod + j) % 13] += dp[i][m];
				}
			}
			else {
				int d = S[i] - '0';
				dp[i + 1][(mod + d) % 13] += dp[i][m];
			}
		}
	}

	dump(dp);
	mint ans = dp[n][5];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8912
import java.util.*;

class Main {
    private static Scanner scan = new Scanner(System.in);

    public static void out(int num) {
        System.out.println(num);
    }

    public static void main(String[] args) {
        int a = scan.nextInt();
        int b = scan.nextInt();

        int x = a + b;
        int y = a - b;
        int z = a * b;

        if (x <= y) {
            if (y <= z) {
                out(z);
            } else {
                out(y);
            }
        } else {
            if (x <= z) {
                out(z);
            } else {
                out(x);
            }
        }
    }

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<set>
#define lli long long int
#define pb push_back
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define rep(i,a,n) for(i=a;i<n;i++)
#define all(v) (v.begin(),v.end())
#define ppb pop_back
#define vsz v.size()
#define pi 3.141592653589793238
using namespace std;
int main()
{
	lli t,n,i,j,ans=0;
	cin>>n;
	for(i=1;i<n;i++){
		ans+=(n-1)/i;
	}
	cout<<ans;	
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;

string s;

int main()
{
	ios::sync_with_stdio(false);
	cin >> s;
	int len = s.length();
	int ans = 0;
	for(int i=0;i<len-1;i++)
	{
		if(s[i]!=s[i+1]) ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 512
n=int(input())
ans=[]
m=0
m+=n
co=0
ju=True
li=[]
while n>3:
    li.clear()
    while len(li)<2:
        co+=1
        if co*2%3:
            if co*2>30000:
                ju=False
                break
            else:
                li.append(co*2)
    if ju and n>2:
        for i in li:
            ans.append(i)
        n-=2
    else:
        break
ju=True
co=0
while n>1:
    li.clear()
    while len(li)<2:
        co+=1
        if co*3%2:
            if co*3>30000:
                ju=False
                break
            else:
                li.append(co*3)
    if ju:
        ans.append(li[0])
        ans.append(li[1])
        n-=2
    else:
        break
co=1
while n>0:
    ans.append(co*6)
    co+=1
    n-=1
if m==3:
    ans=[2,5,63]
elif m==4:
    ans=[2,5,50,63]
for i in range(m):
    if i==n-1:
        print(ans[i])
    else:
        print(ans[i],end=' ')

Measured memory_bytes: 4188
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val seq1 = for(i<-1 to 9) yield List(i,i,i)
  val seq2 = for(i<-1 to 7) yield List(i,i+1,i+2)

  def check(m:List[Int], count:Int):Boolean =  {
    if(m.length != count) false
    else if(count==2) {
      val List(x,y) = m
      if(x==y) true else false
    } else {
      if((0 to 8).exists( i=> check(m diff seq1(i),count-3))) {
        true
      } else {
        (0 to 6).exists(i=> check(m diff seq2(i),count-3) )
      }
    }
  }

  Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
    val l = line.map(_.asDigit).toList
    val m = (1 to 9).filter { i=> if(l.count( _==i ) >= 4) false else check(i::l,14) }
    if(m.length>0) println(m.mkString(" ")) else println(0)
  }
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;
    cin>>s;
    int n=s.size();
    rep(i,n){
        if(i+1<n&&s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
        if(i+2<n&&s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
void main(void)
{
  int N,M,*A,tmp=0;
  scanf("%d %d",&N,&M);
  A=(int*)malloc(sizeof(int)*N);
  for(int i=0;i<M;i++){
    scanf("%d",&A[i]);
    tmp=tmp+A[i];
  }
  if(tmp<=N){
    printf("%d",N-tmp);
  }else{
    printf("-1");
  }


  
}

Measured memory_bytes: 1776
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    int K; cin >> K;
    rep(i, N) {
        int h; cin >> h;
        if (h >= K) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=y)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)
#define int ll

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef long long ll;


signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    int x;
    int a[100010];
    cin>>n>>x;
    int mn=1;
    f(n){
        cin>>a[i];
        a[i]=max(a[i],x)-min(a[i],x);
        if(i==0) mn=a[i];
        mn=__gcd(mn,a[i]);
    }
    cout<<mn;
    return 0;
}



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

int main() {
  int abc[3];
  for (int i{}; i < 3; ++i) cin >> abc[i];
  sort(abc, abc+3);
  cout << ((abc[0] == abc[1] && abc[0] != abc[2]) || (abc[1] == abc[2] && abc[0] != abc[1]) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
b = 1
e = 100000
score = 0
while True:
    mid = (e + b) // 2
    score = (mid * (mid + 1)) // 2
    if score >= n:
        e = mid
    else:
        b = mid
    if abs(e - b) <= 1:
        break
    #print(mid)
if b * (b + 1) // 2 >= n:
    ans = b
else:
    ans = e

rest = ((ans * (ans + 1)) // 2) - n
for num in range(1, ans + 1):
    if rest == num:
        continue
    print(num)

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

int main(){
    int n, m;   cin >> n >> m;
    vector<int> a(m);
    for(int i=0; i<m; i++)  cin >> a.at(i);

    sort(a.begin(), a.end());
    
    vector<int> dis(m);
    for(int i=0; i<m-1; i++)
        dis.at(i) = a.at(i+1)-a.at(i);
    
    sort(dis.begin(), dis.end(), greater<int>());

    ll ans = a.back() - a.at(0);
    for(int i=0; i<min((int)dis.size(), n-1); i++)
        ans -= dis.at(i);

    cout << ans << endl;
        
    
}

Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

dish_list = [a, b, c, d, e]
min_val = 100
idx = 0
for i, x in enumerate(dish_list):
    if x%10 == 0:
        continue
    val = x % 10
    if val < min_val:
        min_val = val
        idx = i

ans = 0
for i, dish in enumerate(dish_list):
    if i == idx:
        continue

    wait_order =  10 - dish_list[i]%10 if dish_list[i]%10 != 0 else 0

    ans += dish_list[i] + wait_order

print(ans + dish_list[idx])

Measured memory_bytes: 3064
#include <iostream>
#include <array>

namespace ABC170
{

  class C
  {
  public:
    C() = default;
    ~C() = default;


    void Run()
    {
      int X, N;
      std::array<int, 301> p = {};
      std::cin >> X;
      std::cin >> N;
      for (int i = 0; i < N; ++i)
      {
        int v;
        std::cin >> v;
        p[v] = 1;
      }

      auto answer = 0;
      for (int i = 0; i <= N; ++i)
      {
        if (p[X - i] == 0) { answer = X - i; break; }

        if (p[X + i] == 0) { answer = X + i; break; }
      }


      std::cout << answer << std::endl;
    }
  };

}

int main()
{

  ABC170::C prob;
  prob.Run();

  return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int64_t mod = 998244353;
int64_t power(int64_t n, int64_t m) {
  // cout << n << "^" << m << "=";
  int64_t ret = 1;
  while (m) {
    if (m % 2) {
      ret = (ret * n) % mod;
    }
    n = (n * n) % mod;
    m /= 2;
  }
  // cout << ret << endl;
  return ret;
}

int main(void) {
  int N;
  cin >> N;
  vector<int> D(N);
  int first;
  rep(i, N) {
    int d;
    cin >> d;
    D[d]++;
    if (i == 0) {
      first = d;
    }
  }
  if (D[0] != 1 || first != 0) {
    cout << 0 << endl;
    return 0;
  }
  int last = N - 1;
  while (D[last] == 0) --last;

#ifdef DEBUG
  rep(i, N) { cout << D[i] << " "; }
  cout << endl;
#endif
  int64_t answer = 1;
  for (int i = 2; i <= last; ++i) {
    int64_t times = power(D[i - 1], D[i]);
    answer = (answer * times) % mod;
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long t,x;
	cin>>t>>x;
	cout<<t/x<<".";
	t=t%x;
	int a;
	for(int i=0;i<10;i++){
		if(i==9){
			a=t*10%x*10/x;
			if(a>4){
				t=t*10;
				cout<<t/x+1;
			}
			else{
				t=t*10;
				cout<<t/x;
			}
		}
		else{
			t=t*10;
			cout<<t/x;
			t=t%x;
		}
	}
}

Measured memory_bytes: 256
n = int(input())
an = list(map(int, input().split()))

am = 1000
st = 0
for a1, a2 in zip(an, an[1:]):
    am += a1 * st
    st = 0
    if a1 < a2:
        st, am = divmod(am, a1)

am += an[-1] * st
print(am)


Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int c=0, d;
		d = Integer.valueOf(s);
		for(int i = 0;i < s.length();++i){
			c += s.charAt(i) - 48;
		}
		if(d % c == 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = s; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i,0,n+1) cin >> a[i];
  ll ans = 0;
  rep(i,0,n) {
    ll b;
    cin >> b;
    if (a[i] >= b) {
      ans += b;
      b = 0;
    } else {
      ans += a[i];
      b -= a[i];
      if (a[i+1] >= b) {
        ans += b;
        a[i+1] -= b;
      } else {
        ans += a[i+1];
        a[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4028
//long long -> ll
//http://web.mit.edu/~ecprice/acm/acm08/notebook.html#file12
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include<bits/stdc++.h>
typedef long long ll;
#define x first
#define y second
#define all(aaa) (aaa).begin(),(aaa).end()
#define REP(i,sss,eee) for(long long i=sss;i<=eee;++i)
#define pb push_back
#define pii pair<long long,long long>
#define vi vector<long long>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
#define N 1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}

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

long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
long long mod;
std::vector<std::vector<long long>> g;
std::vector<long long> ways;
std::vector<long long> fin,topo,parval,par;
long long dfs(long long num,long long fpar)
{
	std::vector<long long> vec;
	ways[num]=1;
	for(auto it:g[num])
	{
		if(it==fpar){continue;}
		else
		{
			par[it]=num;
			dfs(it,num);
			ways[num]=((ways[num]*(1+ways[it]))%mod);
			vec.pb(((1+ways[it])%mod));
		}
	}
	vector<long long> pre,suff;
	long long pro=1;
	for(auto it:vec)
	{
		pro=((pro*it)%mod);
		pre.pb(pro);
	}
	pro=1;
	long long sz=vec.size();
	for(long long i=sz-1;i>=0;--i)
	{
		pro=((pro*vec[i])%mod);
		suff.pb(pro);
	}
	long long ct=0;
	reverse(suff.begin(),suff.end());
	for(auto it:g[num])
	{
		if(it==fpar){
			continue;
		}
		else
		{
			long long ans=1;
			if(ct!=0){ans=((ans*pre[ct-1])%mod);}
			if(ct!=sz-1){ans=((ans*suff[ct+1])%mod);}
			parval[it]=ans;
			++ct;
		}
	}
	topo.pb(num);
	return ways[num];
}
long long solve()
{
	long long n;cin>>n>>mod;
	g.resize(n);ways.resize(n,1);fin.resize(n,1);parval.resize(n,0);par.resize(n);
	REP(i,0,n-2)
	{
		long long a,b;
		cin>>a>>b;--a;--b;
		g[a].pb(b);g[b].pb(a);
	}
	dfs(0,-1);fin[0]=ways[0];
	//for(auto it:parval){cout<<it<<" ";}cout<<"\n";
	reverse(topo.begin(),topo.end());
	std::vector<long long> factor(n,1);
	for(auto it:topo)
	{
		if(it==0){continue;}
		long long p=par[it];
		ll mt=(((parval[it]*factor[p])%mod+1)%mod);
		//cout<<it<<" "<<p<<" "<<parval[it]<<" "<<ways[it]<<" "<<mt<<"\n";
		factor[it]=((factor[it]*mt)%mod);
		fin[it]=((ways[it]*mt)%mod);
	}
	for(auto it:fin){cout<<it<<"\n";}
}
signed main(){
	speed
	long long tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 24052
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vll a;

lli solve(lli i){
    if(i == n) return 1;
    if(a[i+1] < a[i]){
        while(i+1 < n && a[i+1] <= a[i]) i++;
        if(i+1 == n) return 1;
        return solve(i+1)+1;
    }else if(a[i+1] > a[i]){
        while(i+1 < n && a[i+1] >= a[i]) i++;
        if(i+1 == n) return 1;
        return solve(i+1)+1;
    }else{
        while(i+1 < n && a[i+1] == a[i]) i++;
        return solve(i);
    }
}

int main(){
    cin >> n;
    a = vll(n+1);
    for(lli i = 0;i < n;i++) cin >> a[i];
    cout << solve(0) << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
 
import java.util.*;
class Main {
 
    static char[] xx = new char[] {'S','H','C','D'};
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean[][] l = new boolean[4][13];
        for(int i = 0; i < n; i++) {
            char k = sc.next().charAt(0);
            int r = sc.nextInt();
            if(k == 'S') {
                l[0][r-1] = true;
            }
            if(k == 'H') {
                l[1][r-1] = true;
            }
            if(k == 'C') {
                l[2][r-1] = true;
            }
            if(k == 'D') {
                l[3][r-1] = true;
            }
        }
        for(int i = 0 ; i< 4; i++) {
            for(int j = 0; j < 13; j++) {
                if(!l[i][j]) {
                    System.out.println(xx[i] + " " + (j+1));
                }
            }
        }
    }
}


Measured memory_bytes: 26292
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
        int[] AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int ans;
        if (AB[0] + AB[1] >= 24) { ans = AB[0] + AB[1] - 24; }
        else { ans = AB[0] + AB[1]; }
        Console.WriteLine(ans.ToString());
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <deque>
#include <string>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <unordered_map>
#include <bitset>
#include <fstream>
#pragma warning(disable:4996)
#define hayai ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3F3F3F3F
#define MAX 100001
#define MAXLOGO 17
#define MOD 1000000007
#define ALPHABET 128
using namespace std;
typedef long long ll;

//freopen("perimetric_chapter_1_input.txt", "r", stdin);
//freopen("result.txt", "w", stdout);



int main (void)
{
    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(a * c, max ( b * d, max(a * d, b * c))) << endl;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
long long p;
long long R[10005];
long long tenth[200005];

int main(){
	int len;
	cin>>len>>p;
	string s;
	cin>>s;
	if(p==2 || p==5){
		long long ret = 0;
		if(p==2){
			for(int i=0; s[i]; i++){
				int num = (int)(s[i]-'0');
				if(num%2==0) ret+=(i+1);
			}
		}
		if(p==5){
			for(int i=0; s[i]; i++){
				int num = (int)(s[i]-'0');
				if(num%5==0) ret+=(i+1);
			}
		}
		cout<<ret;
		return 0;
	}
	tenth[0] = 1;
	tenth[1] = 10%p;
	for(int i=2; i<=200000; i++){ //0이 i개일 때 p로 나눈 나머지 
		tenth[i] = (tenth[i-1]*10)%p; 
	}
	R[0] = 1;
	int curr = 0;
	for(int i=0; s[i]; i++){
		curr*=10;
		curr+=(int)(s[i]-'0');
		curr%=p;

		R[(curr*tenth[len-i-1])%p]++;
		
	}	
	long long ans = 0;
	
	for(int i=0; i<p; i++){
		ans+=R[i]*(R[i]-1)/2;
	}
	cout<<ans;
}

Measured memory_bytes: 5308
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(b*b+c*c==a*a)
cout<<b*c/2;
if(a*a+c*c==b*b)
cout<<a*c/2;
if(b*b+a*a==c*c)
cout<<a*b/2;
return 0;
}


Measured memory_bytes: 256
/*
float like a butterfly
sting like a Bee

?#%^*&~`!  YOUR ONLY LIMIT IS YOUR MIND

*/

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_bsck
#define pop pop-back
#define S second
#define F first
#define q '\n'
#define w .size()

using namespace std;

int main() {
	fast;
	long long int x;
	cin >> x;
	if (360 % x == 0){
		cout << 360 / x;
	}else {
		for (long long int i = 2; i < 100000000 + 50000000; i++){
		if ((x * i) % 360 == 0){
			cout << i;
			break;
		}
	}
	}
	
}


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

const int N = 20;
int n, m;
ll x, c[N], a[N][N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++) {
		cin >> c[i];
		for(int j = 0; j < m; j++)
			cin >> a[i][j];
	}

	ll ans = 1e18;
	for(int i = 1; i < (1<<n); i++) {
		ll cur[m+5]; memset(cur, 0, sizeof cur);
		ll cost = 0;
		for(int j = 0; j < n; j++) {
			if(i&(1<<j)) {
				for(int k = 0; k < m; k++)
					cur[k] += a[j][k];
				cost += c[j];
			}
		}

		bool ok = 1;
		for(int j = 0; j < m && ok; j++)
			if(cur[j] < x) ok = 0;

		if(ok)
			ans = min(ans, cost);
	}

	cout << ((ans==1e18)?(-1):(ans)) << '\n';

	return 0;
}

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

using namespace std;

int n, k;
int a[100001];
int b[100001];
int kol;
map <int, int> pos;

int main () {
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
		b[i] = a[i];
	}     
	sort (b + 1, b + n + 1);
	for (int i = 1;i <= n;i ++) {
		pos[b[i]] = i % 2;	
	}
	for (int i = 1;i <= n;i ++) {
		if (i % 2 != pos[a[i]]) {
			kol ++;
		}
	}
	cout << kol / 2;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
 
using namespace std;
 
int main() 
{
    ios::sync_with_stdio(false);

    int a[4][4];
    int n, b;

    for (int i = 1; i <= 3; i++)
    {
        for (int j = 1; j <= 3; j++)
        {
            cin >> a[i][j];
        }
    }

    cin >> n;

    while (n--)
    {
        cin >> b;

        for (int i = 1; i <= 3; i++)
        {
            for (int j = 1; j <= 3; j++)
            {
                if (b == a[i][j]) a[i][j] = 0;
            }
        }

    }

    if (not(a[1][1] or a[1][2] or a[1][3]))
        cout << "Yes\n";
    else if (not(a[2][1] or a[2][2] or a[2][3]))
        cout << "Yes\n";
    else if (not(a[3][1] or a[3][2] or a[3][3]))
        cout << "Yes\n";
    else if (not(a[1][1] or a[2][2] or a[3][3]))
        cout << "Yes\n";
    else if (not(a[3][1] or a[2][2] or a[1][3]))
        cout << "Yes\n";
    else if (not(a[1][1] or a[2][1] or a[3][1]))
        cout << "Yes\n";
    else if (not(a[1][2] or a[2][2] or a[3][2]))
        cout << "Yes\n";
    else if (not(a[1][3] or a[2][3] or a[3][3]))
        cout << "Yes\n";
    else cout << "No\n";


    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int h,w;
    cin >> h >> w;
    vector<string> b(h);
    for(int i=0;i<h;i++){
        int ok=0;
        cin >> b[i];
        for(int j=0;j<w;j++){
            if(b[i][j]=='#'){
                ok=1;
            }
        }
        if(ok==0){
            i--;
            h--;
        }
    }
    for(int i=0;i<w;i++){
        int ok=0;
        for(int j=0;j<h;j++){
            if(b[j][i]=='#'){
                ok=1;
            }
        }
        if(ok==0){
            for(int j=0;j<h;j++){
                b[j].erase(i,1);
            }
            i--;
            w--;
        }
    }
    for(int i=0;i<h;i++){
        cout << b[i] << endl;
    }
}


Measured memory_bytes: 256
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
// scanf("%d", &x); => std::cin >> x;
// printf("%d\n", x); => std::cout << x << "\n";

int main() {
    int n, x, t;
    int ans = 0;
    scanf("%d%d%d", &n, &x, &t);
    if (n % x == 0) {
        ans = (n / x) * t;
    } else {
        ans = (n / x) * t + t;
        // printf("%d\n",n % x);
    }

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

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define int long long
#define endl "\n"

const int N=(1<<18)+5;

int cache[N][52];
pair<int,int> arr[20];
int pos[20];
int n;

int dp(int mask,int val)
{
    
    if(mask==((1<<n)-1))
        return 0;
    int &ans=cache[mask][val];
    if(ans!=-1)
        return ans;
    ans=1e9;
    vector<int> v;
    for(int i=0;i<n;i++)
    {
        if(mask&(1<<i))
            v.push_back(i+1);
    }
    int sz=v.size()+1;
    for(int i=0;i<n;i++)
    {
        if(mask&(1<<i))
            continue;
        int temp=v.end()-upper_bound(v.begin(),v.end(),i+1);
        temp+=pos[i+1];
        temp-=sz;
        if(arr[i+1].first>=val && (abs(sz-pos[i+1])%2)==0)
            ans=min(ans,temp+dp((mask|(1<<i)),arr[i+1].first));
        
        if(arr[i+1].second>=val && (abs(sz-pos[i+1])%2)!=0)
            ans=min(ans,temp+dp((mask|(1<<i)),arr[i+1].second));    
    }
    return ans;
}

int32_t main()
{
    IOS;
    
    memset(cache,-1,sizeof cache);
    
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i].first;
    
    for(int i=1;i<=n;i++)
        cin>>arr[i].second;
        
    for(int i=1;i<=n;i++)
        pos[i]=i;
        
    int ans=dp(0,0);
    if(ans==1e9)
        ans=-1;
    cout<<ans;    
    
    return 0;
}

Measured memory_bytes: 106880
#include <cstdio>
#include <cstdlib>
#include <utility>
 
using namespace std;
 
#define inf 1<<21
 
int m,n,k,d,p1,p2,dis,cost,ans;
int C[6],E[108][108];
int D[108][64];
char p1_s[5],p2_s[5];
 
int id(char *s) {
    if(*s=='H') return 0;
    if(*s=='D') return 107;
    if(*s=='C') return atoi(s+1);
    if(*s=='L') return 6+atoi(s+1);
}
 
int main() {
    while(scanf("%d %d %d %d",&m,&n,&k,&d),m) {
        for(int i=0;i<m;i++) scanf("%d",&C[i]);
        for(int i=0;i<108;i++) for(int j=0;j<108;j++) E[i][j]=inf;
        for(int i=0;i<d;i++) {
            scanf("%s %s %d",p1_s,p2_s,&dis);
            p1=id(p1_s),p2=id(p2_s);
            if(E[p1][p2]>dis) E[p1][p2]=E[p2][p1]=dis;
        }
        for(int i=0;i<108;i++) for(int j=0;j<64;j++) D[i][j]=inf;
        D[0][0]=0;
        while(1) {
            bool update=false;
            for(int i=0;i<108;i++) {
				for(int bit=0;bit<64;bit++) {
					if(D[i][bit]==inf) continue;
					for(int j=0;j<108;j++) {
						if(E[i][j]==inf) continue;
						cost=D[i][bit]+E[i][j]*k;
						if(1<=j&&j<=6) {
							if(!(bit&(1<<(j-1)))&&(cost-C[j-1])<D[j][bit|(1<<(j-1))]) {
								D[j][bit|(1<<(j-1))]=cost-C[j-1];
								update=true;
							}
						}else if(cost<D[j][bit]) {
							D[j][bit]=cost;
							update=true;
						}
					}
				}
            }
            if(!update) break;
        }
		ans=inf;
		for(int i=0;i<64;i++) if(ans>D[107][i]) ans=D[107][i];
		printf("%d\n",ans);
    }
}

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


int i[10010];

int main() {

	int max = -1500000;
	int min = 15000000;
	long long som = 0;
	int a;


	cin >> a;

	for (int n = 0; n < a; n++) {

		cin >> i[n];

		if (max < i[n])max = i[n];
		if (min > i[n])min = i[n];

		som +=i[n];
	}

	cout << min << " " << max << " " << som << endl;












	return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<29
#define EPS 1e-9
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))
#define DEBUG 0

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
string FILE_NAME = "testcase.A";
string NAME;
string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

string i2s (int n, int digit )
{
	stringstream ss;
	ss << n;
	string s = ss.str();
	while (s.length() < digit ){
		s = '0' + s;
	} // end while

	return s;
}

int c[10];

int main()
{
//	cut here before submit 
#if DEBUG
	NAME = FILE_NAME;
	int CNT = 1;
	NAME += itos (CNT );
	while (freopen (NAME.c_str() , "r", stdin ) != NULL ) {
#endif
	memset (c, 0, sizeof (c ) );
	ios_base::sync_with_stdio(0);
	int n, m; cin >> n >> m;
	rep (i, 10 ) cin >> c[i];
	string res = "";

	rep (i, pow(10, n ) ){
		string num = i2s(i, n );
		int curr = 0;
		rep (j, num.length() ){
			curr += c[(int)(num[j] - '0')];
		} // end rep
		if (num.length() == n && curr <= m ){
			res = num;
			break;
		} // end if
	} // end rep
	
	cout << (res.empty() ? "NA" : res ) << endl;

#if DEBUG
	CNT++;	// cut here before submit
	NAME = FILE_NAME;
	NAME += itos (CNT );
	} // end loop; cut here before submit
#endif			
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; ++i){
    cin >> d[i];
  }
  ll res = 0;
  for(int i = 0; i < N; ++i){
    for(int j = i+1; j < N; ++j){
      res += d[i] * d[j];
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import Control.Arrow (second)
import Data.List
import qualified Data.Vector.Unboxed as V
import qualified Data.ByteString.Char8 as B

solve :: V.Vector Bool -> Int
solve xs = let _L = V.length xs; _M = V.length $ V.filter id xs in _L - abs (_L - 2 * _M)

main = do
  stringS <- B.getLine
  let xs = V.unfoldr (\n -> if n == B.length stringS then Nothing else Just (B.index stringS n == '0', n+1)) 0
  print $ solve xs



Measured memory_bytes: 1020
import sys
import math
read = sys.stdin.read
readline = sys.stdin.buffer.readline
INF = float('inf')


def main():
    A, B, K = map(int, readline().split())
    C = []
    for i in range(1,min(A,B)+1):
        if A%i==0 and B%i==0:
            C.append(i)

    print(C[-K])

if __name__ == '__main__':
    main()


Measured memory_bytes: 9248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_3_D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] line = ReadIntAr();
            int rlt = 0;
            for (int i = line[0]; i <= line[1];i++)
            {
                if (line[2] % i == 0) rlt++;
            }
            Console.WriteLine("{0}",rlt);
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 17944
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		double n = sc.nextDouble();

		double total = 0;
		int count = 0;

		for (int i = 1; i <= n; i++) {
			if(i % 2 == 1) {
				count++;
			}
		}

		System.out.println(count / n);
	}

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
const ll mod = 1000000007;
vector<ll> inv, FactorialInv, Factorial;
ll beki(ll a, ll b){
    ll ret = 1 % mod;
    a %= mod;
    while(b) {
        if(b & 1LL) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}
void init_combination(ll MAX){
    Factorial.resize(MAX + 1);
    FactorialInv.resize(MAX + 1);
    inv.resize(MAX + 1);
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    if(b < 0) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll N, K;
vector<ll> Div;
vector<vector<ll>> mp;
vector<ll> ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    for(ll i = 1; i * i <= N; i++) {
        if(N % i != 0) continue;
        Div.push_back(i);
        if(i * i == N) continue;
        ll k = N / i;
        Div.push_back(k);
    }
    sort(Div.begin(), Div.end());
    mp.resize(Div.size());
    ans.resize(Div.size());
    for(int i = 0; i < Div.size(); i++) {
        //cerr << Div[i] << " ";
        for(int j = i + 1; j < Div.size(); j++) {
            if(Div[j] % Div[i] == 0) mp[j].push_back(i);
        }
    }
    //cerr << endl;
    for(ll i = 0; i < Div.size(); i++) {
        ll num = (Div[i] + 1) / 2;
        ans[i] = beki(K, num);
        for(auto j : mp[i]) {
            //cerr << i << " " << j << endl;
            ans[i] += mod - ans[j];
            ans[i] %= mod;
        }
    }
    ll sum = 0;
    for(int i = 0; i < Div.size(); i++) {
        //cerr << Div[i] << " " << ans[i] << endl;
        if(Div[i] & 1) sum += ans[i] * Div[i];
        else sum += ans[i] * Div[i] / 2;
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;


const int maxn = 1005, maxm = 2005;
vector<pair<int,int>>g[maxn],gr[maxn];
int n,m;
int32_t main(){
	IOS
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int u,v;cin>>u>>v;
		g[u].push_back({v,i});
		gr[v].push_back({u,i});
	}
	            vector<vector<int>>dis(n+1,vector<int>(n+1,1e18));
				vector<vector<int>>use(n+1,vector<int>(n+1,0000));
				vector<vector<int>>par(n+1,vector<int>(n+1,0000));
				for(int s=1;s<=n;s++){
					vector<int>inq(n+1);
					queue<pair<int,int>>q;
					q.push({s,0});
					inq[s]=1;
					while( q.size() ){
						int u = q.front().first;
						int d = q.front().second;
						q.pop();inq[u]=0;
						for(auto [v,i]:g[u]){
							if( dis[s][v] > d + 1){
								dis[s][v] = d + 1;
								par[s][v] = u;
								use[s][v] = i;
								if( !inq[v] ){
									q.push({v,dis[s][v]});
									inq[v]=1;
								}
							}
						}
					}
				}
				int root = 1;
				for(int s=1;s<=n;s++){
					//bug2(u,dis[s][s]);
					if( dis[s][s] < dis[root][root] ){
						root = s;
					}
				}
				if( dis[root][root] >= 1e10){
					cout << - 1 << endl;
					return 0;
				}
				set<int>st;
				int cur = root;
				list<int>ans;
				// used edges:::::
				/*while( !st.count(use[root][cur]) ){
					ans.push_front(use[root][cur]);
					st.insert(use[root][cur]);
					cur = par[root][cur];
				}*/
				// used nodes:::::
				while( !st.count(par[root][cur]) ){
					ans.push_front(par[root][cur]);
					st.insert(par[root][cur]);
					cur = par[root][cur];
				}
				cout << ans.size() << endl;
				for(auto e:ans){
					cout << e <<" ";
				}
				cout << endl;
				return 0;
	
}
/*
 * long long or int?
 * index out of bound?
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


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

using namespace std;

typedef long long ll;

const ll mod=1e9+7;
const ll maxn=5e5+5;

int main(){
	int n,r;
	scanf("%d%d",&n,&r);
	int ans=0;
	while(n){
		n/=r;
		ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256