akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f p x y = (p,x+y)

main = do
    n <- getInt
    unless (n==0) $ map (apply3 f) <$> replicateM n getInts >>= putStrLn . tjoin . maximumBy (comparing snd) >> main 


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

int main() {
  int n, m; cin >> n >> m;
  map<int,int> fc;
  rep(i,n) {
    int ki; cin >> ki;
    rep(j,ki) {
      int aij; cin >> aij;
      fc[aij]++;
    }
  }
  int ans = 0;
  for (auto p : fc) {
    if (p.second >= n) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]){
        int maxv = -2000000000;
        int minv = 2000000000;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            int n = Integer.parseInt(br.readLine());
            int v;
            int saveBox[] = new int[n];
            for (int i=0; i<n ; i++) {
                v = Integer.parseInt(br.readLine());
                maxv = Math.max(maxv,v - minv);
                minv = Math.min(minv, v);
            }    
        } catch (Exception e) {
            //TODO: handle exception
        }
        
        System.out.println(maxv);
    }
}


Measured memory_bytes: 42324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x;
    cin>>n>>x;
    if(n<=x)
    {
        if(abs(n-x)<n)
            cout<<abs(n-x)<<endl;
        else
            cout<<n<<endl;
    }
    else if(n%x==0)
        cout<<0<<endl;
    else
    {
        ll temp=n/x;
        ll rem=n%x;
        if(abs(n-(temp*x))<abs(rem-x))
            cout<<abs(n-(temp*x))<<endl;
        else
            cout<<abs(rem-x)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int x, y;
  cin >> x >> y;

  vector<int> g(13, 0);
  rep(i, 13) {
    if (i == 2) g[i] = 2;
    else if (i == 4 || i == 6 || i == 9 || i == 11) g[i] = 1;
  }

  cout << (g[x] == g[y] ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <bits/stdc++.h>
#define   ff   first
#define   ss   second
using namespace std; 

string  s[1005];
int cost[1005][1005];
int  r, c, fx, fy, lx, ly ; 

inline void solve(){ 
    cin >> r >> c >> fx >> fy >> lx >> ly ; 
    fx--, fy--, lx--, ly-- ; 
    for ( int  i = 0 ; i < r ; i++ ) cin >> s[i] ; 

    for (int i=0;i<r;i++) 
        for (int j=0; j<c;j++) cost[i][j] = 1000000 ; 
    
    deque < pair<int, int> > q ; 
    q.push_back({fx, fy}) ; 
    cost[fx][fy] = 0 ; 

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

    while (!q.empty()) { 
        int  x = q.front().ff ; 
        int  y = q.front().ss ; 
        q.pop_front() ; 
        //move... 
        for (int t=0;t<4;t++) { 
            int i = x + dx[t] ; 
            int j = y + dy[t] ; 
            if (i>=0 and i<r and j>=0 and j<c and s[i][j]=='.' and (cost[i][j] > cost[x][y]) ) {  
                cost[i][j] = cost[x][y] ; 
                q.push_front({i, j}) ; 
            } 
        } 
        //jump... 
        for (int i=max(0,x-2);i<=(min(r,x+2));i++) { 
            for (int j=max(0,y-2);j<=min(c,y+2);j++) { 
                if (i<r and j<c and s[i][j]=='.' and (cost[i][j] > cost[x][y] + 1) ) { 
                    cost[i][j] = cost[x][y] + 1 ; 
                    q.push_back({i, j}) ; 
                } 
            } 
        } 
    } 
    if (cost[lx][ly] != 1000000) cout << (cost[lx][ly]) << endl ; 
    else cout << (-1) << endl ; 
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
} 


Measured memory_bytes: 8628
n = int(input())
a = list(map(int, input().split()))
a.reverse()

b = []

#1：購入、-1：売却、0：何もしない

before = 1

for i in range(1, n):
  if a[i - 1] > a[i]:
    if before == 1:
      b.append(-1)
      before = -1
    else:
      b.append(0)
  elif a[i - 1] < a[i]:
    if before == -1:
      b.append(1)
      before = 1
    else:
      b.append(0)
  else:
    b.append(0)
    
b.reverse()

for i in b:
  if i == 1:
    b.insert(0, 0)
    break
  elif i == -1:
    b.insert(0, 1)
    break

if len(b) != n:
  b.insert(0, 0)

a.reverse()
money = 1000
kabu = 0
    
for i in range(n):
  if b[i] == 1:
    kabu, money = divmod(money, a[i])
  if b[i] == -1:
    money = money + kabu * a[i]
    kabu = 0

print(money)


Measured memory_bytes: 9088
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
#include<set>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main() {
	int n,ans=0;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 1;i < n;i++) {
		vector<int> x(26), y(26);
		int cnt = 0;
		for (int j = 0;j < i;j++) x[s[j]-'a']=1;
		for (int j = i;j < n;j++) y[s[j] - 'a']=1;
		for (int j = 0;j < 26;j++) {
			if (x[j] == 1 && y[j] == 1) cnt++;
		}
		ans = max(ans,cnt);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}


template <typename T>
void vecOutPadding(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}

template <typename T>
void matOut(vector<vector<T>>& mat) {
	for (const auto& row : mat) {
		for (const T& col : row)
			cout << col << " ";
		cout << endl;
	}
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;

	ll ans = K % 2 == 0 ? A - B : B - A;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<bitset>
#include<algorithm>
#include<unordered_map>
 
#include<unordered_map>
#include<algorithm>
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
 
#define ii pair<long long,long long>
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
 
typedef long long ll;
typedef vector< int> vi;
 
const int MAX = 24;
const int maxn = 1 << 22;


ll n, ans;
int main (){
 
	cin >> n;
	ans =  n-1;
	vector <ll>  div;
	
	for(ll i = 2;i * i <= n ;i++){
		if ( n % i == 0 ){
			div.pb ( i);
			if ( n / i != i ){
				div.pb ( n / i);
			}
		}
	}
	
	for(int i = 0 ;i < (int)div.size();i++){
		ans = min ( ans ,  ( n / div[i] -1 ) +   ( div[i]-1) );
	}

	cout << ans << '\n';
	
	return 0;
}



Measured memory_bytes: 384
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

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

  int32_t N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  int32_t count = 0;
  int32_t rank_abroad = 0;

  const int32_t length = static_cast<int32_t>(S.length());
  for (int32_t i = 0; i < length; ++i) {
    switch (S.c_str()[i]) {
      case 'a':
        if (count < A + B) {
          cout << "Yes" << endl;
          ++count;
        } else {
          cout << "No" << endl;
        }
        break;
      case 'b':
        ++rank_abroad;
        if (count < A + B && rank_abroad <= B) {
          cout << "Yes" << endl;
          ++count;
        } else {
          cout << "No" << endl;
        }
        break;
      default:
        cout << "No" << endl;
        break;
    }
  }
  return 0;
}


Measured memory_bytes: 848
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char S[] = new char[14];
        char H[] = new char[14];
        char C[] = new char[14];
        char D[] = new char[14];
        int n = sc.nextInt();
        for(int i = 1; i <= 13; i++){
        	S[i] = 1;
        	H[i] = 1;
        	C[i] = 1;
        	D[i] = 1;
        }
        
        for(int i = 0; i < n; i++){
        	String a = sc.next();
        	int b = sc.nextInt();
        	
        	if(a.equals("S")){
        		S[b] = 0;
        	}
        	else if(a.equals("H")){
        		H[b] = 0;
        	}
        	else if(a.equals("C")){
        		C[b] = 0;
        	}
        	else if(a.equals("D")){
        		D[b] = 0;
        	}
        }
        for(int i = 1; i <= 13; i++){
        	if(S[i] == 1) System.out.println("S "+ i);
        }
        for(int i = 1; i <= 13; i++){
        	if(H[i] == 1) System.out.println("H "+ i);
        }
        for(int i = 1; i <= 13; i++){
        	if(C[i] == 1) System.out.println("C "+ i);
        }
        for(int i = 1; i <= 13; i++){
        	if(D[i] == 1) System.out.println("D "+ i);
        }
    }
}


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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    const ll MOD = 1000000007;
    auto Add = [&](ll& x, ll y) { x = ( x + y % MOD ) % MOD; };
    auto Mul = [&](ll& x, ll y) { x = ( x * y % MOD ) % MOD; };
    auto Pow = [&](ll x, ll n) -> ll {
        ll t = x % MOD, r = 1;
        while ( n > 0 ) {
            if ( n & 1 ) Mul(r, t);
        Mul(t, t);
        n >>= 1;
        }
        return r;
    };
    auto Inv = [&](ll a) -> ll {
        return Pow(a, MOD - 2);
    };

    vector<ll> n(3);
    n[0] = n[1] = n[2] = -1;
    ll dp = 1;
    for ( int i = 0; i < N; i++ ) {
        ll a = A[i];
        ll c = 0;
        for ( int i = 0; i < 3; i++ ) {
            if ( n[i] == a-1 ) c++;
        }
        Mul(dp, c);
        for ( int i = 0; i < 3; i++ ) {
            if ( n[i] == a-1 ) {
                n[i]++;
                break;
            }
        }
    }
    
    ll ans = dp;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
  
    const int x = 50;
    vector<int> a(x), b(x);
    for (int i=0; i<M; i++) {
        cin >> a.at(i) >> b.at(i);
    }
    vector<int> load(x, 0);
    for (int i=0; i<M; i++) {
        load.at(a.at(i)-1) += 1;
        load.at(b.at(i)-1) += 1;
    }
    for (int i=0; i<N; i++) {
        cout << load.at(i) << endl;
    }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> arr = new ArrayList<>();
		for (; sc.hasNext();) {
			arr.add(sc.nextInt());
		}
		int count = 0;
		int min = arr.get(0);
		for (int num : arr) {
			if (num <= min) {
				count++;
				min = num;
			}
		}
		System.out.println(count);
	}

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n), a(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    rep(i, n) a[i] = i + 1;
    map<vector<int>, int> mp;
    do
    {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(), a.end()));
    cout << abs(mp[p] - mp[q]) << endl;
    return 0;
}


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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;


struct MaxFlow {
	struct Edge {
		int to, cap, rev;
		Edge() {};
		Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {};
	};
	int V;
	vector<vector<Edge>> G;
	vector<int> used;

	MaxFlow(int V) : V(V), G(V, vector<Edge>()), used(V){}

	void add_edge(int from, int to, int cap) {
		G[from].push_back({to, cap, (int)G[to].size()});
		G[to].push_back({from, 0, (int)G[from].size() - 1});
	}

	int dfs(int v, int t, int f) {
		if (v == t) return f;
		used[v] = true;
		for (int i = 0; i < G[v].size(); i++) {
			Edge& e = G[v][i];
			if (!used[e.to] && e.cap > 0) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	int max_flow(int s, int t) {
		int flow = 0;
		while (1) {
			// memset(used, 0, sizeof(used));
			used = vector<int>(V, 0);
			int f = dfs(s, t, INF);
			if (f == 0) return flow;
			flow += f;
		}
	}
};


//エラトステネスの篩を使用
const int MAX_PRIME = 1e7 + 10;

vector<int> is_prime(MAX_PRIME, 1);

void calcPrime() {
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i < MAX_PRIME; i++) {
		if (is_prime[i] == 1) {
			for (int j = i + i; j < MAX_PRIME; j += i) is_prime[j] = 0;
		}
	}
}

int main() {
	calcPrime();
	int n;
	cin >> n;
	vi x(n);
	rep(i, n) cin >> x[i];
	map<int, int> mp;
	rep(i, n) {
		mp[x[i]] ^= 1;
		mp[x[i] + 1] ^= 1;
	}
	MaxFlow flow(3500);
	vi odd, even;
	for (auto& p : mp) if (p.se) (p.fi & 1 ? odd : even).pb(p.fi);
	rep(i, odd.size()) rep(j, even.size()) {
		if (is_prime[abs(odd[i] - even[j])]) flow.add_edge(1000 + i, 2000 + j, 1);
	}
	rep(i, odd.size()) flow.add_edge(0, 1000 + i, 1);
	rep(i, even.size()) flow.add_edge(2000 + i, 1, 1);
	int f = flow.max_flow(0, 1);
	int ans = f + (((int)odd.size() - f) / 2) * 2 + (((int)even.size() - f) / 2) * 2;
	if (((int)odd.size() - f) & 1) ans += 3;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 39680
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            String s = sc.next();
            long k = Long.parseLong(sc.next());

            int loopOne = 0;
            String notOne = "";

            for(int i = 0; i < s.length(); i++){
                String subS = s.substring(i, i + 1);
                if(!subS.equals("1")){
                    notOne = subS;
                    break;
                }
                loopOne++;
            }

            if(k <= loopOne) System.out.println(1);
            else System.out.println(notOne);
 
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int n,a[10],b[10];
	cin >> n;
	rep(i,n) {cin>>a[i];a[i]--;}
	rep(i,n) {cin>>b[i];b[i]--;}
	bool zan[10]={};
	memset(zan,0,sizeof(zan));
	int ans=0,ans2=0;
	
	rep(i,n){
		int cnt = 0;
		rep(j,a[i]){
			if(zan[j] == false) cnt++;
		}
		repn(j,n-i-1) cnt *= j;
		ans += cnt;
		zan[a[i]] = 1;
	}
	memset(zan,0,sizeof(zan));
	rep(i,n){
		int cnt = 0;
		rep(j,b[i]){
			if(zan[j] == false) cnt++;
		}
		repn(j,n-i-1) cnt *= j;
		ans2 += cnt;
		zan[b[i]] = 1;
	}
	
	cout << abs(ans-ans2) << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			List<Integer> list = IntStream.range(0, 5).mapToObj(i -> {
				int number = scanner.nextInt();
				scanner.nextLine();
				return number;
			}).collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
			list.sort((x, y) -> {
				int xremain = x % 10;
				int yremain = y % 10;
				return ((yremain == 0) ? 10 : yremain) - ((xremain == 0) ? 10 : xremain);
			});
			int sum = list.stream().limit(list.size() - 1).mapToInt(i -> ceiling(i)).sum();
			sum += list.get(list.size() - 1);
			System.out.println(sum);
		}
	}

	private static int ceiling(int integer) {
		int remain = integer % 10;
		if (remain == 0) {
			return integer;
		} else {
			return integer + 10 - remain;
		}
	}
}


Measured memory_bytes: 26964
#include <stdio.h>

int main(void)
{
	int num[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	int i = 0;
	int j = 0;
	int max = 0;
	int max_i = 0;
	
	for (i = 0; i < 10; i++) {
		scanf("%d", &num[i]);
	}
	
	for (j = 0; j < 3; j++) {
		max = 0;
		max_i = 0;
		for (i = 0; i < 10; i++) {
			if (num[i] > max) {
				max = num[i];
				max_i = i;
			}
		}
		printf("%d\n", max);
		num[max_i] = 0;
	}

	return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var ans = "Yes";
            var before_positionX = 0;
            var before_positionY = 0;
            var before_time = 0;

            for (int i = 0; i < n; i++)
            {
                var txy = ReadInts();
                var T = txy[0];
                var X = txy[1];
                var Y = txy[2];

                var need = Abs(X - before_positionX) + Abs(Y - before_positionY);

                if (need <= T)
                {
                    var tmp = Abs(T - before_time) - need;
                    if (tmp % 2 != 0)
                    {
                        ans = "No";
                        break;
                    }
                }
                else
                {
                    ans = "No";
                    break;
                }

                before_positionX = X;
                before_positionY = Y;
                before_time = T;
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main(){
  int n;
  cin>>n;
  int kazu1=n%10;
  n/=10;
  int kazu2=n%10;
  n/=10;
  int kazu3=n%10;
  int kazu4=n/10;
  if(kazu4+kazu3+kazu2+kazu1==7){
    cout<<kazu4<<"+"<<kazu3<<"+"<<kazu2<<"+"<<kazu1<<"=7"<<endl;
  }else if(kazu4+kazu3+kazu2-kazu1==7){
    cout<<kazu4<<"+"<<kazu3<<"+"<<kazu2<<"-"<<kazu1<<"=7"<<endl;
  }else if(kazu4+kazu3-kazu2+kazu1==7){
    cout<<kazu4<<"+"<<kazu3<<"-"<<kazu2<<"+"<<kazu1<<"=7"<<endl;
  }else if(kazu4-kazu3+kazu2+kazu1==7){
    cout<<kazu4<<"-"<<kazu3<<"+"<<kazu2<<"+"<<kazu1<<"=7"<<endl;
  }else if(kazu4-kazu3-kazu2+kazu1==7){
    cout<<kazu4<<"-"<<kazu3<<"-"<<kazu2<<"+"<<kazu1<<"=7"<<endl;
  }else if(kazu4+kazu3-kazu2-kazu1==7){
    cout<<kazu4<<"+"<<kazu3<<"-"<<kazu2<<"-"<<kazu1<<"=7"<<endl;
  }else if(kazu4-kazu3+kazu2-kazu1==7){
    cout<<kazu4<<"-"<<kazu3<<"+"<<kazu2<<"-"<<kazu1<<"=7"<<endl;
  }else if(kazu4-kazu3-kazu2-kazu1==7){
    cout<<kazu4<<"-"<<kazu3<<"-"<<kazu2<<"-"<<kazu1<<"=7"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main(){
    vector<char> v{'a', 'i', 'u', 'e', 'o'};
    char c; cin >> c;
    if(find(all(v),c) != v.end())cout << "vowel" << ln;
    else cout << "consonant" << ln;
}


Measured memory_bytes: 3548
def calc(A, N, i):
    ans = 0
    ai = A[i]
    for i in range(i, N - 1):
        aj = A[i + 1]
        ans += ai * aj
    return (ans)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod_v = 10**9 + 7
    ans = [0] * (N + 1)
    for i in range(0, N - 1):
        if A[i] != 0:
            ans[i] = calc(A, N, i)
            break
    for j in range(i + 1, N - 1):
        if A[j] != 0:
            ans[j] = (ans[j - 1] - A[j - 1] * A[j]) // A[j - 1] * A[j]
        else:
            ans[j] = 0
    ret = 0
    for k in range(0, N):
        ret += ans[k]
    ret = ret % mod_v
    print(ret)


if __name__ == '__main__':
    main()

Measured memory_bytes: 30928
#include "bits/stdc++.h"
using namespace std;
int main()
{
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);;
        cout<<setprecision(12)<<fixed;
        long double num;
        cin >> num;
        cout<<num*num*num/27<<"\n";
return 0;
}


Measured memory_bytes: 256
N, M = [int(_) for _ in input().split()]
AB = [[int(_) for _ in input().split()] for i in range(M)]

from collections import defaultdict
from heapq import *

def solve(N, M, AB):
    rs = defaultdict(set)
    for a, b in AB:
        rs[a].add(b)
        rs[b].add(a)
    h = []
    t = {1: 0}
    heappush(h, (0, 1))
    while h:
        d, x = heappop(h)
        for dx in rs[x]:
            if dx not in t:
                t[dx] = x
                heappush(h, (d + 1, dx))
    return t

result = solve(N, M, AB)

print("Yes")
for i in range(2, N + 1):
    print(result[i])


Measured memory_bytes: 98348
#include<bits/stdc++.h>
using namespace std;
long long int dp[100005][13];
string a;

long long int get(int pos , int &n, long long int rem)
{
//	cout<<"Hari";
	if(pos>=n) {
		
		if(rem==5) return 1;
		
		return 0;
	}
	
	if(dp[pos][rem] != -1) return dp[pos][rem];
	if(a[pos]!='?') return dp[pos][rem]=get(pos+1,n,(10*rem+(a[pos]-'0'))%13)%1000000007;
	
	long long int res = 0;	
	
	for(int i=0;i<=9;++i)
	{
		res=(res+get(pos+1,n,(10*rem+i)%13))%1000000007;
//		cout<<rem<<"\n"<<" i = "<<i<<"\n";
	}
	
	return dp[pos][rem] = res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>a;
	long long int L;
	memset(dp , -1 , sizeof dp);
	int n=a.size();
	L = get(0 ,n, 0);
	cout<<L<<"\n";
}


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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;
struct edge{
    int flow,to,rev;
};
typedef vector<edge> E;
typedef vector<E> FlowGraph;

void addedge(FlowGraph &g,int from,int to,int f){
    int a=g[from].size();
    int b=g[to].size();
    g[from].push_back(edge{f,to,b});
    g[to].push_back(edge{0,from,a});
}
typedef vector<LL> V;
typedef vector<V> VV;

const LL INF=1e15;

V bfs(FlowGraph &g,int s){
    int n=g.size();
    queue<int> que;
    V dist(n,-1);
    dist[s]=0;
    que.push(s);
    for(;que.size();que.pop()){
        auto v=que.front();
        for(auto &e:g[v]){
            if(e.flow>0&&dist[e.to]==-1){
                dist[e.to]=dist[v]+1;
                que.push(e.to);
            }
        }
    }
    return dist;
}
int maxflow(FlowGraph &g,int s,int t){
    int res=0,n=g.size();
    while(true){
        auto dist=bfs(g,s);
        if(dist[t]<0)break;
        vector<unsigned> iter(n,0);
        std::function<int(int,int)> dfs=[&](int v,int f){
            if(v==s)return f;
            for(auto &i=iter[v];i<g[v].size();i++){
                edge &e=g[v][i];
                edge &re=g[e.to][e.rev];
                if(re.flow>0&&dist[v]>dist[e.to]){
                    int d=dfs(e.to,min(f,re.flow));
                    if(d>0){e.flow+=d;re.flow-=d;return d;}
                }
            }
            return 0;
        };
        int f;
        while((f=dfs(t,114514))>0)res+=f;
    }
    return res;
}

int main(){
    for(int N,M,L;cin>>N>>M>>L,N+M+L;){
        VV g(N,V(N,INF));
        for(int i=0;i<M;i++){
            int u,v,d;
            cin>>u>>v>>d;
            g[u][v]=g[v][u]=d;
        }
        for(int i=0;i<N;i++)g[i][i]=0;
        for(int k=0;k<N;k++)
            for(int i=0;i<N;i++)
                for(int j=0;j<N;j++)
                    g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
        using P=tuple<int,int>;
        vector<P> pt(L);
        for(int i=0;i<L;i++){
            int p,t;
            cin>>p>>t;
            pt[i]=P(t ,p);
        }
        sort(pt.begin(),pt.end());
        FlowGraph fg(2*L+2);
        int id=0;
        int S=id++;
        int T=id++;
        vector<int> bg(L),ed(L);
        for(int i=0;i<L;i++){
            bg[i]=id++;ed[i]=id++;
            addedge(fg,S,ed[i],1);
            addedge(fg,bg[i],T,1);
            int pv,tv,pu,tu;
            tie(tv,pv)=pt[i];
            for(int j=0;j<i;j++){
                tie(tu,pu)=pt[j];
                if(g[pv][pu]<=abs(tv-tu))
                    addedge(fg,ed[j],bg[i],1);                   
            }
        }
        cout<<L-maxflow(fg,S,T)<<endl;
    }


    return 0;
}

Measured memory_bytes: 18280
import qualified Data.IntSet as S
  
main :: IO ()
main = do
  getLine
  as <- map read . words <$> getLine
  putStrLn $ if (solve as) then "YES" else "NO"

solve :: [Int] -> Bool
solve as = go S.empty as
  where
    go _ [] = True
    go s (a:as)
      | a `S.member` s = False
      | otherwise      = go (S.insert a s) as

Measured memory_bytes: 105852
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int N, K;
	int ans = 1;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			ans = ans * K;
		}
		else {
			ans *= K - 1;
		}
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long n;
void solve()
{
    long long i,tmp,ans=0;
    vector < long long > a(n+1);
    for (i=0;i<n;i++)
        cin>>a[i];
    a[n]=a[n-1]+1;
    tmp=a[0];
    for (i=1;i<n;i++)
        if (a[i]<tmp) ans+=tmp-a[i];
        else tmp=a[i];
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b==c+d) cout << "Balanced" << endl;
  else if (a+b<c+d) cout << "Right" << endl;
  else cout << "Left" << endl;
}

Measured memory_bytes: 256
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]

    member public __.Tuple2List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]]
    
    member public __.Tuple3List n (f : int -> 'a list) =
        [for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]]

end

[<EntryPoint>]
let main _ =
    let scanner = Scanner()
    let n = scanner.NextI32()
    let t = scanner.NextF64()
    let a = scanner.NextF64()
    let hArr = scanner.ArrayF64(n)

    let temper x = t - x * 0.006
    let answer x =
        let p = a - (temper x)
        if p < 0.0 then p * -1.0 else p
    let arr = [|for item in hArr -> answer item|]

    let (_, _, ans) = Array.fold (fun (len, minv, ind) x -> if x < minv then len + 1, x, len + 1 else len + 1, minv, ind) (0, 10000.0, 0) arr

    printfn "%i" ans

    0


Measured memory_bytes: 14300
#include<iostream>
using namespace std;
int main()
{
       string t; unsigned long long int a=0;
      cin >> t ;
    for(unsigned long long int i=0; i<t.size(); i++)
    {
      
      
      
      
      
      
       a=a+((unsigned long long int)t[i])-48;
      }
        if(a%9==0)
        {
            cout << "Yes" << "\n" ;
        }
   else
   {
     cout << "No" << "\n" ; 
   }
     
}

Measured memory_bytes: 3688
#include<iostream>

using namespace std;

int main(){
  int d, n;
  cin >> d >> n;
  int ans = 1;
  for(int i=0;i<d;i++){
    ans*=100;
  }
  if(n==100){
    cout << (n+1) * ans << endl;
  }
  else{
    cout << n * ans << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<string.h>

using namespace std;

int main() {
	double W, H, x, y,TF;
    double rectangle;
	cin >> W >> H >> x >> y;
	if (W / 2 == x && H / 2 == y)TF = 1;
	else {
		TF = 0;
	}		
	printf("%f",W * H / 2);
	cout <<" "<< TF <<endl;
		return 0;
}


Measured memory_bytes: 256
/*
 ***
 Question Name:
 ***
 Question Link:
 
 ***
 Idea:
 */

#include <memory.h>
#include <iomanip>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <numeric>
#include <sstream>
#include <fstream>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))

using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef unordered_set<int> ui;
typedef pair<LL,LL> pLL;



class YoungMaids{
    vector<vector<ii>> seg;
    vi P,C;
    vector<vi> E;
    int N,n;
    void init(){
        cin>>n;
        P.resize(n);
        E.resize(n+1);
        C.resize(n+1);
        for(int i=0;i<n;++i) cin>>P[i];
        N = 1;
        while(N<n/2) N*=2;
        seg = vector<vector<ii>>(2,vector<ii>(2*N-1,ii(n+1,-1)));
        int j = N-1;
        for(int i=0;i<n;++i) seg[i%2][j+i/2] = ii(P[i],i);
        while(j){
            for(int i=j/2;i<j;++i) for(int k=0;k<2;++k) seg[k][i] = min(seg[k][2*i+1], seg[k][2*i+2]);
            j /= 2;
        }
    }
    ii findMin(int l,int r,int a,int b,int k,int t){
        if(r<=a || b<=l) return ii(n+1,-1);
        if(a<=l && b>=r) return seg[t][k];
        ii vl = findMin(l, (l+r)/2, a, b, 2*k+1, t);
        ii vr = findMin((l+r)/2, r, a, b, 2*k+2, t);
        return min(vl, vr);
    }
    int findPair(int l,int r){
        if(l==r-2){
            C[P[l]] = P[l+1];
            return P[l];
        }
        auto x1 = findMin(0, N, l/2, r/2, 0, l%2);
        int ie = x1.second;
        auto x2 = findMin(0, N, (ie+1)/2, (r+1)/2, 0, (l+1)%2);
        int io = x2.second;
        C[x1.first] = x2.first;
        if(ie > l) E[x1.first].push_back(findPair(l, ie));
        if(io>ie+1) E[x1.first].push_back(findPair(ie+1, io));
        if(r>io+1) E[x1.first].push_back(findPair(io+1, r));
        return x1.first;
    }
public:
    void solve(){
        init();
        priority_queue<int,vector<int>,greater<int>> que;
        que.push(findPair(0, n));
        while(!que.empty()){
            int k = que.top();
            cout<<k<<' '<<C[k]<<' ';
            que.pop();
            for(int j:E[k]) que.push(j);
        }
    }
};

int main(){
    YoungMaids().solve();
    return 0;
}

Measured memory_bytes: 44668
from math import log
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(lambda x : log(int(x)), input().split()))
s = 0
for i in range(K):
    s += A[i]
for i in range(K, N):
    t = s - A[i-K] + A[i]
    if t > s:
        print('Yes')
    else:
        print('No')
    s = t


Measured memory_bytes: 92204
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	string S, T;
	cin >> S >> T;

	for (int i = 0; i < S.size(); i++) {
		S = S.back() + S.substr(0, S.size() - 1);
		if (S == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

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

}


Measured memory_bytes: 3080
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	if(N%K == 0){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
Program Grid1;
const max=1000000007;
var A:array[0..1005,0..1005] of char;
    L:array[0..1005,0..1005] of int64;
    //Qx,Qy:array[1..10000000] of longint;
    i,f,r,n,m,j,x,y,u,v :longint;
    fi,fo:text;
//------------------------------------------
begin
//assign(Fi,'Grid1.inp');reset(fi);
readln(n,m);
for i:=1 to n do begin
                 for j:=1 to m do begin
                                  Read(A[i,j]);
                                  end;
                 readln;
                 end;
L[1,1]:=1;
for i:=1 to n do begin
                 for j:=1 to m do begin
                                  if A[i,j]='.' then L[i,j]:=(L[i,j]+L[i-1,j]+L[i,j-1]) mod max;
                                  end;
                 end;
Writeln(L[n,m]);
//readln;
end.



Measured memory_bytes: 8960
#include <iostream>
#define int long long
using namespace std;
int n,x;
int c[63];
const int mod = 1e9+7;
signed main() {
    cin >> n;
    for( int i = 0 ; i < n ; i++ ) {
    	cin >> x;
        for( int j = 0 ; j <= 60 ; j++ ) if( x & (1ll << j) ) c[j]++;
    }    
    long long res = 0;
    for( int i = 0 ; i <= 60 ; i++ ) {
        res = (res+(long long)( n - c[i])%mod* c[i]%mod * (( 1ll << i )%mod)%mod);
	}
    cout << res%mod << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int o0=0,e0=0,o1=0,e1=0;
  for(int i=0;i<s.length();i++)
  {
  	if(i%2==0)
    {
      if(s[i]=='1') e1++;
      else e0++;
    }
    else
    {
      if(s[i]=='1') o1++;
      else o0++;
    }
  }
  cout<<min(e1+o0,e0+o1);
  return 0;
}

Measured memory_bytes: 512
/**
 * @Author:      WeakestRookie
 * @Email:       1311053296@qq.com
 * @DateTime:    2019-05-19 19:24:31
 * @Description: Description 
 */
#include<bits/stdc++.h>
using namespace std;

#define rep(x, y, z) for(int x = y; x < z; ++x)
#define dwn(x, y, z) for(int x = y; x >= z;--x)
#define mst(a, b) memset(a, b, sizeof(a));
#define clr(a) mst(a, 0);
#define lbit(x) (x & (-x))
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int MOD = 1e9+7;
const int MAXN = 1e5+10;

int n,k;
string str;

int main(int argc, char const *argv[]) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    cin >> str;
    str[k-1]= str[k-1] - 'A' + 'a';
    cout << str << endl;
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main() {
  int n,x[1000]={},y[1000]={};
  double D2,D3,d1=0,d2=0,d3=0,max=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>x[i];
  for(int i=0;i<n;i++)cin>>y[i];
  for(int i=0;i<n;i++){
    d1+=fabs(x[i]-y[i]);
    d2+=fabs(x[i]-y[i])*fabs(x[i]-y[i]);
    d3+=pow(fabs(x[i]-y[i]),3);
    if(max<fabs(x[i]-y[i]))max=fabs(x[i]-y[i]);
  }
  D2=sqrt(d2);
  D3=pow(d3,1.0/3.0);
  printf("%.8lf\n%.8lf\n%.8lf\n%.8lf\n",d1,D2,D3,max);
  return 0;
}

Measured memory_bytes: 1264
a,b,c,x,y = gets.chomp.split.map(&:to_i)

n = x > y ? x : y

min = 1000000000
(0..n).each do |i|
  k = i*2*c + a*[0,x-i].max + b*[0,y-i].max
    min = k if k < min
end
puts min

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000005 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
    ll N;
    cin>>N;
    vector<int> A(N);
    rep(i,N){ 
        int k;
        cin>>k;
        k--;
        A[k]=i+1;
    }
    rep(i,N)cout<<A[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3688
def main():
  N = int(input())
  a = list(map(lambda i: int(i), input().split(' ')))
  a.sort()
  a.reverse()
  max_point = 0
  for i in range(0, 2 * N):
    if i % 2 == 1:
      max_point += a[i]
  print(max_point)

main()


Measured memory_bytes: 37084
#!/usr/bin/env python3
from collections import deque


def Topological_sorting(E):
    N = len(E)
    in_deg = [0]*N
    for i in range(N):        # ２重ループでO(E)
        for to_ in E[i]:
            in_deg[to_] += 1

    ans = [v for v in range(N) if in_deg[v] == 0]
    deq = deque(ans)

    while deq:                  # O(V+E)
        v = deq.popleft()
        for t in E[v]:
            in_deg[t] -= 1
            if in_deg[t] == 0:
                ans.append(t)
                deq.append(t)
    if len(ans) != N:
        return False
    return ans


def main():
    N = int(input())
    A = [None]*N
    for i in range(N):
        A[i] = list(map(lambda x: int(x)-1, input().split()))

    # 0<=i<j<Nを満たすi,jの組を整数へ対応付ける
    MP = [[0]*N for _ in range(N)]
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            MP[i][j] = cnt
            MP[j][i] = cnt
            cnt += 1

    out = [[] for _ in range(N*(N-1)//2)]
    # 対戦カードをノードとみなし、閉路検出と最長パス探索を行う
    for i in range(N):
        for j in range(N-2):
            out[MP[i][A[i][j]]].append(MP[i][A[i][j+1]])

    # 閉路検出
    M = N*(N-1)//2

    order = Topological_sorting(out)
    if order is False:
        print(-1)
        return

    # 最長パスを得る
    # 枝の格納方法から、パスは自分の下位の情報から作る。
    # post_order-likeに見る
    depth = [1]*M
    longest = 1
    for i in reversed(order):
        for u in out[i]:
            depth[i] = max(depth[i], 1+depth[u])
        longest = max(depth[i], longest)
    print(longest)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 141916
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] nk = br.readLine().split(" ");
		int n = Integer.parseInt(nk[0]);
		int k = Integer.parseInt(nk[1]);
		int[] a = new int[n];
		
		String[] input = br.readLine().split(" ");
		
		for (int i = 0; i < input.length; i++) {
			a[i] = Integer.parseInt(input[i]);
		}
		
		int ans = solve(a,k);
		
		System.out.println(ans);
	}

	private static int solve(int[] a, int k) {
		
		int[] dp = new int[a.length];
		
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0] = 0;
		
		for (int i = 0; i < dp.length; i++) {
			
			for (int j = i+1; j < Math.min(dp.length, i+k+1); j++) {
				dp[j] = Math.min(dp[j], dp[i]+Math.abs(a[i]-a[j]));
			}
			
		}
		
		return dp[a.length-1];
	}
}

Measured memory_bytes: 36128
D = gets.to_i
c = gets.split.map(&:to_i)
s = Array.new D
D.times do |i|
  s[i] = gets.split.map(&:to_i)
end

t = Array.new D
D.times do |i|
  t[i] = gets.to_i
end

score = 0
last = Array.new 26, 0
D.times do |i|
  _t = t[i] - 1
  score +=  s[i][_t]
  last[_t] = i + 1
  26.times do |j|
    score -= (i + 1 - last[j]) * c[j]
  end
  puts score
end

Measured memory_bytes: 14408