akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = scan.nextLong();
        }
        long[] sum = new long[N+1];
        for (int i = 0; i < N; i++) {
            sum[i+1] = sum[i] + a[i];
        }
        List<Long> list = new ArrayList<>();
        long max = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = i; j <= N; j++) {
                long x = sum[j]-sum[i-1];
                list.add(x);
                max = Math.max(max, Long.highestOneBit(x));
            }
        }
        long ans = 0;
        for (long current = max; 0 < current; current /= 2) {
            int count = 0;
            List<Long> newlist = new ArrayList<>();
            int listsize = list.size();
            for (int i = 0; i < listsize; i++) {
                long target = list.get(i);
                if (0 < (target & current)) {
                    count+=1;
                    newlist.add(target);
                }
            }
            if (K <= count) {
                list = newlist;
                ans += current;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 51060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_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);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,K; cin >> N >> K;
    vector<ll> p(N); for(auto& in:p) cin >> in;
    vector<double> cusum(N+1);
    for(int i = 0; i < N;i++){
        
        double s = (1+p[i])*p[i]/(double)p[i]/2.0;
        cusum[i+1] = cusum[i] + s;
    }
    
    for(int i = K; i <= N;i++){
        res = max(res,cusum[i]-cusum[i-K]);
    }
    
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<double>() << endl;
    return 0;
}


Measured memory_bytes: 3456
import itertools
n, m = map(int, input().split())
edge = [[0 for _ in range(n)] for _ in range(n)]
e = [[int(i)-1 for i in input().split()]for _ in range(m)]
for ei in e:
    i, j = ei
    edge[i][j] = 1
    edge[j][i] = 1

paths = itertools.permutations([i for i in range(n)], n)
ok = 0
for path in paths:
    if path[0] != 0:
        continue
    flag = True
    for ei in range(len(path)-1):
        if edge[path[ei]][path[ei+1]] == 0:
            flag = False
        if flag is False:
            break
    if flag:
        ok += 1
print(ok)

Measured memory_bytes: 73672
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int dp[101][100001];
int n;
int weight[200001];
int value[200001];
 
int rec(int idx,int knap)
{   
    if(dp[idx][knap]!=-1) return dp[idx][knap];
    if(idx==n) return 0;
 
    if(knap<0)  return 0;
  //  if(knap==0) return 0;
  // cout<<max(rec(idx+1,knap),(value[idx]+rec(idx+1,knap-weight[idx])));
    //cout<<" "<<"\n";
    if(weight[idx]>knap)  return dp[idx][knap]=rec(idx+1,knap);
    return dp[idx][knap]=max(rec(idx+1,knap),(value[idx]+rec(idx+1,knap-weight[idx])));
   
}
 
 
signed main(){ 
 
   for(int i=0;i<101;i++)
   {
       for(int j=0;j<100001;j++)
        dp[i][j]=-1;
   }
    int w;
    cin>>n>>w;
 
        for(int i=0;i<n;i++)
        {
        cin>>weight[i]>>value[i];
        }
        //cout<<w;
    cout<<rec(0,w);
 
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int n,k;
    cin>>n>>k;
    int i=0;
    while(n!=0){
        n /= k;
        i++;
    }
    cout<<i<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;

ll Cc(ll n, ll m)
{
    if (m > n / 2)
        m = n - m;
    ll a = 1, b = 1;
    for (int i = 1; i <= m; i++)
    {
        a *= n + 1 - i;
        b *= i;
        if (a % b == 0)
        {
            a /= b;
            b = 1;
        }
    }
    return a / b;
}
const int maxn = 1e5 * 2 + 2;
int a[maxn], num[maxn];
ll c[maxn];
int main()
{
    int k;
    scanf("%d", &k);
    int mm = 0;
    for (int i = 1; i <= k; i++)
    {
        scanf("%d", &a[i]);
        mm = max(a[i], mm);
        num[a[i]]++;
    }
    for (int i = 2; i <= k; i++)
        c[i] = Cc(i, 2);
    ll ans = 0;
    for (int i = 1; i <= mm; i++)
        if (num[i])
            ans += c[num[i]];

    for (int i = 1; i <= k; i++)
    {
        ll ansn = ans;
        ansn -= c[num[a[i]]];
        ansn += c[num[a[i]] - 1];
        printf("%lld\n", ansn);
    }
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
  double hako[11][11];
int main(){
  int n,d;
  cin >> n >> d;
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin >> hako[i][j];
    }
  }
  int res = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double dis = 0;
      for(int k=0;k<d;k++){
        double poi =  hako[i][k] - hako[j][k];
        dis += poi * poi;
      }
      double hantei = sqrt(dis) - (int)sqrt(dis);
      if(hantei*hantei < 0.00001 )res++;
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N = ni()
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum
pn = seachPrimeNum(10000)
res=[]
for i in pn:
    if("1" == str(i)[-1]):
        res.append(i)
#print(len(res))
print(*res[:N])
#ans = []
#for i in range(N):
    #print(res[i],"",end="")
    
#print()

Measured memory_bytes: 12456
/* tempate
 *
 *
 */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n + 1);
    ll res = 0;
    rep(i, n + 1) cin >> a[i];
    rep(i, n){
        ll b; cin >> b;
        ll mn = min(b, a[i]);
        a[i] -= mn;
        res += mn;
        b -= mn;
        mn = min(b, a[i + 1]);
        a[i + 1] -= mn;
        res += mn;
    }
    cout << res;
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


// union find
class UnionFind {
private:
  vector<LL> p;
  
public:
  UnionFind(LL size) : p(size, -1) {}

  bool unionSet(LL x, LL y) {
    x = root(x);
    y = root(y);
    
    if (x != y) {
      if (x > y) { swap(x, y); }
      p[x] += p[y];
      p[y] = x;
    }   

    return x != y;
  }

private:
  LL root(LL x) {
    return p[x] < 0 ? x : p[x] = root(p[x]);
  }
};


VVL es; //{cost, x, y}
LL kruskal(int n) {
    SORT_ASC(es);
    UnionFind uf = UnionFind(n);
    LL res = 0;

    for(auto e : es){
        LL cost = e[0];
        LL x = e[1];
        LL y = e[2];
        if (uf.unionSet(x, y)) {
            res += cost;
        }
    }
    return res;
}


void Main()
{
    int n;cin>>n;

    VVL m(n);
    VVL tate(n);
    VVL yoko(n);
    REP(i,n){
        LL x,y;cin>>x>>y;
        m[i]={x,y};
        tate[i]={x,i};
        yoko[i]={y,i};
    }
    SORT_ASC(tate);
    SORT_ASC(yoko);


    REP(i,n-1){
        es.PB({tate[i+1][0]-tate[i][0],tate[i+1][1],tate[i][1]});
        es.PB({yoko[i+1][0]-yoko[i][0],yoko[i+1][1],yoko[i][1]});
    }

    LL result = kruskal(n);
    cout<<result<<endl;

    
	return;
}

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

Measured memory_bytes: 31416
n = input()
list_1 = [2, 4, 5, 7, 9]
list_2 = [0, 1, 6, 8]
list_3 = [3]
if int(n[-1]) in list_1:
    print('hon')
elif int(n[-1]) in list_2:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9172
import sys
for line in sys.stdin.readlines():
	stack=[]
	for foo in line.strip().split():
		if foo=="+":
			foo=stack.pop()+stack.pop()
		elif foo=="*":
			foo=stack.pop()*stack.pop()
		elif foo=="-":
			foo=-stack.pop()+stack.pop()
		elif foo=="/":
			foo=1.0/stack.pop()*stack.pop()
		stack.append(float(foo))
	print "{:.6f}".format(stack[0]+0)

Measured memory_bytes: 4232
S = input()
MOD = 10 ** 9 + 7
N = 13
dp = [0 for _ in range(N)]
dp[0] = 1

mul = 1
for i in range(len(S)):
  c = S[len(S) - i - 1]
  nextDP = [0 for _ in range(N)]

  if c == "?":
    for k in range(10):
      for j in range(N):
        nextDP[(k * mul + j) % N] += dp[j]
        nextDP[(k * mul + j) % N] %= MOD
  else:
    k = int(c)
    for j in range(N):
      nextDP[(k * mul + j) % N] += dp[j]
      nextDP[(k * mul + j) % N] %= MOD

  mul *= 10
  mul %= N
  dp = nextDP
print(dp[5])

Measured memory_bytes: 43884
#include<map>
#include<set>
#include<list>
#include<limits>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
ll bit[100010];
int n;
int k;
ll sum(int i){
	ll s = 0;
	while(i > 0){
		s +=bit[i];
		i -=i&-i;
	}
	return s;
}

void add(int i,int x){
	while(i <=n){
		bit[i] +=x;
		i +=i&-i;
	}
}

int main(){
	while(cin>>n>>k,n||k){
		memset(bit,0,sizeof(bit));
		for(int i = 0;i < n;i++){
			int num;
			cin>>num;
			add(i+1,num);
		}
		ll res =numeric_limits<ll>::min();
		for(int i = 1;i+k-1<=n;i++){
			res =max(sum(i+k-1)-sum(i-1),res);
		}
		cout <<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 1944
#include<cstdio>
using namespace std;
int main()
{
	int n,a,i;
	double s;
	s=0.0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		s+=(double)1.0/a;
	}
	s=1.0/s;
	printf("%lf\n",s);
	return 0;
}

	

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

int main(){
    int N,A,B,r0,r1;
    cin >> N >> A >> B;
    
    r0 = min(A,B);
    r1 = max(A+B-N,0);

cout << r0 << " " << r1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
    #include<vector>
    #include<cstdio>
    #include<algorithm>
    #include<map>
    using namespace std;
    typedef long long ll;
    typedef pair<ll,ll> ii;
    const int INF = 0x3f3f3f3f;
    int main()
    {
        ll n,i;
        scanf("%lld",&n);
        vector<ll> ns(n);
        for(i=0;i<n;i++)
            scanf("%lld",&ns[i]);
        ll ma=-INF,mi=INF;
        ll maw,miw;
        ll zs=0,fs=0;
        for(i=0;i<n;i++)
        {
            if(ns[i] > 0)
                zs++;
            else if(ns[i] < 0)
                fs++;
            if(ma < ns[i])
            {
                ma = ns[i];
                maw = i;
            }
            if(mi > ns[i])
            {
                mi = ns[i];
                miw = i;
            }
        }
        vector<ii> xl;
        if(ma == mi)
        {
            printf("0\n");
            return 0;
        }
        else if(mi >= 0)
        {
        ex1:for(i=1;i<n;i++)
            {
                while(ns[i-1] > ns[i])
                {
                    ii ne(maw,i);
                    xl.push_back(ne);
                    ns[i] += ns[maw];
                    if(ns[i] > ma)
                    {
                        ma = ns[i];
                        maw = i;
                    }
                }
            }
        }
        else if(ma <= 0)
        {
        ex2:for(i=n-2;i>=0;i--)
            {
                while(ns[i] > ns[i+1])
                {
                    ii ne(miw,i);
                    xl.push_back(ne);
                    ns[i] += ns[miw];
                    if(ns[i] < mi)
                    {
                        mi = ns[i];
                        miw = i;
                    }
                }
            }
        }
        else
        {
            if(-mi < ma)
                goto ex1;
            else
                goto ex2;
        }
        printf("%d\n",xl.size());
        for(i=0;i<xl.size();i++)
            printf("%lld %lld\n",xl[i].first+1,xl[i].second+1);
        return 0;
    }

Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,K,val = 1,count = 0;
    cin >> N >> K;

    while(N >= val){
        val *= K;
        count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
 int a, b;
   cin >> a;
   cin >> b;

   if(a<b){
     cout << "a < b";
   }else if(a>b){
       cout << "a > b";
   }else{
       cout << "a == b";
   }

   cout << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(20) << x << endl
const int MOD = 1e9 + 7;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 1e-8;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};


template <int mod = 1000000007>
struct Combination {
  std::vector<long long> fac, finv, inv;
  Combination(const long long n) : fac(n + 1, 0), finv(n + 1, 0), inv(n + 1, 0) {
    for (long long i = 0; i < n + 1; ++i) {
      bool one_or_zero = i == 0 || i == 1;
      fac[i] = one_or_zero ? 1 : fac[i - 1] * i % mod;
      inv[i] = one_or_zero ? 1 : mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = one_or_zero ? 1 : finv[i - 1] * inv[i] % mod;
    }
    inv[0] = 0;
  }
  long long operator()(const long long n, const long long r) {
    if (n < r || n < 0 || r < 0)
      return 0;
    else if (n == r || r == 0)
      return 1;
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
  }

  long long perm(const long long n, const long long r) {
    if (n < r || n < 0 || r < 0)
      return 0;
    else if (r == 0)
      return 1;
    return fac[n] * finv[n - r] % mod;
  }
};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;
  Combination<MOD> comb(max(n + 1, m + 1));

  ll ans = 0;
  for(int i = 1; i <= n; ++i) {
    if(i % 2 == 1) ans += comb(n, i) * comb.perm(m - i, n - i) % MOD;
    else ans -= comb(n, i) * comb.perm(m - i, n - i) % MOD;
    while(ans < 0) ans += MOD;
    ans %= MOD;
  }
  ans = (ans * comb.perm(m, n)) % MOD;
  ll al = comb.perm(m, n) * comb.perm(m, n) % MOD;
  ans = al - ans;
  while(ans < 0) ans += MOD;

  out(ans % MOD);

  return 0;
}


Measured memory_bytes: 14952
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main() {
    int x;
    cin >> x;
    if(x==7 or x==5 or x==3){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Control.Monad

data State = State !Int !Int !Int deriving Show

step :: State -> State -> Maybe State
step (State t a b) next@(State t' a' b') =
    let
        dt = t' - t
        da = abs (a - a')
        db = abs (b - b')
        distance = da + db
        in
            if dt >= distance && even (distance - dt)
                then Just next
                else Nothing

main = do
    n <- readLn :: IO Int
    l <- replicateM n ((\[t, a, b] -> State t a b) . map read . words <$> getLine)
    putStrLn $ case foldM step (State 0 0 0) l of
        Just _  -> "Yes"
        Nothing -> "No"
    

Measured memory_bytes: 80252
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

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

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

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

long long ngcd(vector<long long> a) {
  long long res = a[0];
  for(int i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vi a(n);
  rep(i,n) cin>>a[i];
  
  vll l(n+1),r(n+1);
  rep(i,n){
    l[i+1]=gcd(l[i],a[i]);
  }
  rrep(i,n){
    r[i]=gcd(r[i+1],a[i]);
  }
  ll ans=0;
  rep(i,n){
    chmax(ans,gcd(l[i],r[i+1]));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2176
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

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

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

int main(void){
    int a, b;
    int count = 0;

    cin >> a >> b;

    if(a>b){
        count = a + (a - 1);
    }else if(a<b){
        count = b + (b - 1);
    }else{
        count = a + b;
    }

    cout << count << endl;
}

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

int main(){
    int n;
    cin >> n;
    int min = 1000000;
    for(int i = 1; i<= n/2; ++i){
        int p = i, q = n-i, s = 0;
        while(p > 0){
            s += p%10; p /= 10;
        }
        while(q > 0){
            s += q%10; q /= 10; 
        }
        if(s < min) min = s;
    }
    cout << min << endl; return 0;
}

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

int main() {

	int X, A, B;
	cin >> X >> A >> B;

	if (A >= B) cout << "delicious" << endl;
	else if (A <= B && (B - A) <= X) cout << "safe" << endl;
	else cout << "dangerous" << endl;

	return 0;
}

Measured memory_bytes: 256
####################
#  AC:     ms (PyPy)
####################

def main():
    MOD = 10**6+3
    # preprocess
    fac = [None] * (MOD+1)
    fac[0] = fac[1] = 1
    for i in range(2, MOD+1):
        fac[i] = (fac[i-1] * i) % MOD

    Q = int(input())
    for i in range(Q):
        x, d, n = map(int, input().split())

        if d == 0:
            print(pow(x, n, MOD))
            continue
        
        xd = (x * pow(d, MOD-2, MOD)) % MOD
        if xd == 0 or xd + (n-1) >= MOD:
            print(0)
            continue

        print(pow(d, n, MOD) * fac[xd+(n-1)] * pow(fac[xd-1], MOD-2, MOD) % MOD)


if __name__ == "__main__":
    main()

Measured memory_bytes: 75612
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    string N;
    cin >> N;

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(ll i = 0; i < N; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
vector<pair<int,int>> edge[100005];
int ans[100005]={};

void dfs(int from,int pre,int precolor){
    int color=1;
    for(auto e:edge[from]){
        int to,id;
        tie(to,id)=e;
        if(to==pre) continue;
        if(color==precolor) color++;
        ans[id]=color;
        dfs(to,from,color);
        color++;
    }
}
signed main(){
    int n;cin>>n;
    rep(i,n-1){
        int a,b;cin>>a>>b;
        edge[a-1].emplace_back(b-1,i);
        edge[b-1].emplace_back(a-1,i);
    }
    rep(i,n-1) ans[i]=-1;
    dfs(0,-1,-1);

    int ansnum=0;
    rep(i,n-1){
        ansnum=max(ansnum,ans[i]);
    }
    cout<<ansnum<<endl;
    rep(i,n-1) cout<<ans[i]<<endl;
    return 0;
}

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


int main(){
    int a, b;
    cin >> a >> b;
    if(a<b){
        cout << "a < b" << endl;
    }else if(a>b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"

#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define inp(x) (cin>>x,x)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

//#define lint long long
typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> livec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx9[9] ={ 0,1,1,1,0,0,-1,-1,-1 },
dy9[9] ={ 1,1,0,-1,0,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
	setc;

	lint n;cin>>n;
	lint ans=0;
	rep(i,n)ans+=i+1;
	co(ans);
	gc();
}

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

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

int main(){
  int N; cin>>N;
  ll res = 0;
  vector<int> A(N+1),B(N+1),C(N);
  rep1(i,N)cin>>A.at(i);
  rep1(i,N)cin>>B.at(i);
  rep1(i,N-1)cin>>C.at(i);

  rep1(i,N-1)if(A.at(i)==A.at(i+1)-1)res+=C.at(A.at(i));
  for(auto d:A)res+=B.at(d);
  cout<<res<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,ans=0;
    cin>>n;
    vector<ll> s(n);
    for(auto& i:s) cin>>i;
    Fr(c,n-1){
        vector<bool> vis(n);
        ll ka=0;
        fr(i,(n-1)/c){
            if(vis[i*c]) break;
            vis[i*c]=1;
            if(vis[n-1-i*c]) break;
            vis[n-1-i*c]=1;
            ka+=s[i*c]+s[n-1-i*c];
            ans=max(ans,ka);
            //if(ka==13) cout<<c<<" "<<i<<endl;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>

int main(void){
    int N, tmp=200001, ans=0;
    std::cin >> N;
    for (int i=0; i<N; ++i){
        int a;
        std::cin >> a;
        if (a < tmp){
            ++ans;
            tmp = a;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3520
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const int N_MAX = 100010;
ll Per[N_MAX] = {}; // n!
ll Per_inv[N_MAX] = {}; //(n!)^-1

ll nCr(ll n, ll r){
    if(n<r) return 0;

    if (n == r || r == 0)
        return 1;
    else
        return Per[n] * Per_inv[n-r] % mod * Per_inv[r] % mod;  
}

// a^b mod p
ll mod_pow(ll a, ll b){
    if(b==0) return 1;

    // 肩が奇数
    if(b%2==1){
        return a * mod_pow(a, b-1) % mod;
    }
    else{
        return mod_pow(a*a % mod, b/2) % mod;
    }
}

vector<ll> A;

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

    // input
    int N;
    cin >> N;

    A.resize(N+1);
    FOR(i, 0, N+1){
        cin >> A.at(i);
    }

    // 重複探し
    map<ll, int> mp;
    for(ll a : A){
        mp[a]++;
    }

    int dup_val;
    for(auto p : mp){
        if(p.second == 2){
            dup_val = p.first;
        }
    }

    int left = -1;
    int right = -1;
    FOR(i, 0, N+1){
        if(A[i]==dup_val){
            if(left==-1){
                left = i;
            }else{
                right = i;
            }
        }
    }

    // nCr高速化準備
    Per[1] = 1;
    FOR(i, 2, N_MAX){
        Per[i] = i * Per[i-1] % mod;
    }

    Per_inv[1] = 1;
    FOR(i, 2, N_MAX){
        Per_inv[i] = mod_pow(Per[i], 1000000005);
    }

    FOR(k, 1, N+2){
        ll all = nCr(N+1, k);
        ll dup = nCr(N - right + left, k-1);
        ll a = all - dup;
        if(a<0){
            a+=mod;
        }
        p(a%mod);
    }
        
    return 0;
}

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


int main() {
	// your code goes here
	ll n,k;
	cin>>n>>k;
	int arr[n];
	ll brr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	//	brr[i]=0;
	}
	if(n!=0)
	{
	brr[0]=0;
	brr[1]=abs(arr[1]-arr[0]);

	ll p;
	ll mi=0,m=0;
	for(ll i=2;i<n;i++)
	{
		mi=INT_MAX;
		p=i-1;
		if(i<=k)
		{
		while(p>=0)
		{
		m=brr[p]+abs(arr[i]-arr[p]);
		if(m<mi)
		mi=m;
		p--;
		}
	}
	else
	{
				while(p>=i-k)
		{
		m=brr[p]+abs(arr[i]-arr[p]);
		if(m<mi)
		mi=m;
		p--;
		}
	}
	brr[i]=mi;
}
cout<<brr[n-1];
}
else
{
cout<<"0";
}
	return 0;
}

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

int main(){

  int n;

  while(cin >> n, n){
    int x,y,ans = 0,t = 0;

    for(int i=0;i<12;i++){
      cin >> x >> y;

      ans += (x - y);

      if(ans >= n && t == 0){
	cout << i+1 << endl;
	t = 1;
      }
    }

    if(t == 0) cout << "NA" << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

//mod(1e9+7)
const int mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x = 0) : x(x % mod){}
    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
};

vector<mint> dp(13);

int main() {
    string s; cin >> s;
    int n = s.size();
    vint mo(n);
    mo[n-1] = 1;
    for (int i = n-2; i >= 0; i--) {
        mo[i] = (mo[i+1]*10)%13;
    }
    dp[0] = 1;
    for (int i = n-1; i >= 0; i--) {
        vector<mint> next_dp(13,0);
        if (s[i] != '?') {
            int x = (s[i] - '0') * mo[i] % 13;
            rep(j,13) next_dp[(j+x)%13] += dp[j];
        }
        else {
            rep(j,13) {
                rep(k,10) {
                    int x = k*mo[i]%13;
                    next_dp[(j+x)%13] += dp[j];
                }
            }
        }
        swap(dp,next_dp);
    }
    cout << dp[5].x << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B;
    cin >> A >> B;
    int temp = 0;
    temp = max(temp, A + B);
    temp = max(temp, A + A - 1);
    temp = max(temp, B + B - 1);
    cout << temp << endl;
}


Measured memory_bytes: 256
class Graph:
    def __init__(self, n, adj):
        self.adj = adj
        self.cnt = 0
        self.depth = 0
        self.ds = [-1] * n

    def solve(self, u):
        self.ds[u] = self.depth
        if self.ds.count(-1) == 0:
            self.cnt += 1
            return

        self.depth += 1
        for v in self.adj[u]:
            if self.ds[v] == -1:
                self.solve(v)
                self.ds[v] = -1
        self.depth -= 1


def main():
    n, m = map(int, input().split())
    adj = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    graph = Graph(n, adj)
    graph.solve(0)
    print(graph.cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
int main()
{
	char a[10], b[10];
	scanf("%s %s",a,b);
	int s = 0;
	for(int i = 0 ;a[i] != '\0';i++)
		s = s*10 + a[i] - '0';
	for(int i = 0 ;b[i] != '\0';i++)
		s = s*10 + b[i] - '0';
	int t = sqrt(s);
		printf(t * t == s ? "Yes":"No");
	return 0;
 } 

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

using namespace std;

class Disjointset {
private:
	vector<int> p, rank;
public:
	Disjointset(int size) {
		p.resize(size, 0);
		rank.resize(size, 0);
		for (int i = 0; i < size; ++i) {
			p[i] = i;
		}
	}

	int find(int v) {
		if (p[v] != v)
			p[v] = find(p[v]);
		return p[v];
	}

	bool isSame(int x, int y) {
		return find(x) == find(y);
	}

	void unite(int x, int y) {
		link(find(x), find(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		} else {
			if (rank[x] == rank[y])
				++rank[y];
			p[x] = y;
		}
	}
};

int main() {

	int n, q;
	scanf("%d %d", &n, &q);
	Disjointset d(n);
	for (int i = 0; i < q; ++i) {
		int com, x, y;
		scanf("%d %d %d", &com, &x, &y);
		if (com == 0) {
			d.unite(x, y);
		} else {
			if (d.isSame(x, y)) {
				cout << 1 << endl;
			} else {
				cout << 0 << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3324
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  while(cin >>a>>b>>c){
    long int x=c+b*100+a*10000;
    if(x<18680908) cout <<"pre-meiji"<<endl;
    else if(x<19120730) cout<<"meiji"<<" "<<a-1868+1<<" "<<b<<" "<<c<<endl;
    else if(x<19261225) cout<<"taisho"<<" "<<a-1912+1<<" "<<b<<" "<<c<<endl;
    else if(x<19890108) cout<<"showa"<<" "<<a-1926+1<<" "<<b<<" "<<c<<endl;
    else cout<<"heisei"<<" "<<a-1989+1<<" "<<b<<" "<<c<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  ll N,M;
  cin >> N >> M;
  vector<P> A(N);
  REP(i,N) cin >> A[i].first >> A[i].second;
  

  vector<vector<ll>> vec(M,vector<ll> ());
  REP(i,N){
    if(M-A[i].first>=0){
      vec[M-A[i].first].push_back(A[i].second);
    }
  }
  priority_queue<int> pq;
  ll ans = 0;
  REPR(i,M-1){
    REP(j,vec[i].size()){
      pq.push(vec[i][j]);
    }
    if(pq.size()!=0){
      ans+=pq.top();
      pq.pop();
    }
  }

  cout << ans << endl;
}

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

using namespace std;


string ans[6],s;
int k;
int main(){
        cin>>s>>k;
        for(int i=0;i<k;i++) ans[i]=string(1,'z'+1);

        int n=s.length();
        for(int st=0;st<n;st++){
                string cur;
                for(int en=st;en<n;en++){
                        cur.push_back(s[en]);
                        bool okay=1;
                        for(int i=0;i<k;i++) if (cur==ans[i]) okay=0;
                        if (!okay) continue;
                        if (cur<ans[k-1]) ans[k-1]=cur;
                        for(int i=k-1;i>=1;i--) if (ans[i]<ans[i-1])
                                swap(ans[i],ans[i-1]);
                }
        }
        cout<<ans[k-1];
}


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

public class Main {
  private static double solve(int n, int k, int[] ps) {
    double expSum = 0.0;
    for (int i = 0; i < k; i++) {
      expSum += (ps[i] + 1.0) / 2.0;
    }
    double maxExpSum = expSum;
    for (int i = k; i < n; i++) {
      expSum -= (ps[i - k] + 1.0) / 2.0;
      expSum += (ps[i] + 1.0) / 2.0;
      maxExpSum = Math.max(maxExpSum, expSum);
    }
    return maxExpSum;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    int[] ps = reader.nextInt(n);
    out.printf("%.20f\n", solve(n, k, ps));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i, m) cin >> x[i];
    sort(x.begin(), x.end());

    vector<ll> diffs;
    for (int i = 1; i < x.size(); ++i)
        diffs.push_back(x[i] - x[i - 1]);
    sort(diffs.begin(), diffs.end(), greater<ll>());

    ll res = x.back() - x[0];
    for (int i = 0; i < min((int)diffs.size(), n - 1); ++i)
        res -= diffs[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4616
# include <iostream>
# include <cstdio>
# include <cstring>
# include <iomanip>
# include <algorithm>
# include <cstdlib>
# include <cmath>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a > 0 && b > 0) cout << "Positive" << endl;
	if (a < 0 && b > 0) cout << "Zero" << endl;
	if (a < 0 && b < 0)
	{
		int c = 0;
		for (int i = a; i <= b; i++)
		{
			c++;
		}
		if (c % 2 == 0) cout << "Positive" << endl;
		else cout << "Negative"<< endl;
	}
	return 0;
}

Measured memory_bytes: 256