akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>

using namespace std;

#define LL long long

LL n,a,b,ans;

int main() {
	cin >> n >> a >> b;
	if((b-a)%2ll==0ll)ans=(b-a)/2;
	else {
		ans=min(b-1ll,(a+b-1ll)/2ll);
		ans=min({ans, n-a, (((n-b)*2ll+1ll+b-a)/2l)});
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
sum = 0
min_x = 0
min_x1 = 0
for i in x:
    sum += i
ave = sum // n
ave1 = ave + 1
for i in x:
    min_x += (ave - i) * (ave - i)
for i in x:
    min_x1 += (ave1 - i) * (ave1 - i)
if min_x1 >= min_x:
    print(min_x)
else:
    print(min_x1)

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

int main(void) {
    string s;
    cin >> s;

    long long n = s.size();
    long long c = 0;
    long long numblacks = 0;

    rep(i, n) {
        if (s[i] == 'B') numblacks++;
        else c += numblacks;
    }

    cout << c << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int amount = sc.nextInt();
        
        // dp[i] = i円引き出すときの最小回数
        int[] dp = new int[100001];
        
        dp[0] = 0;
        for (int i = 1; i <= amount; i++) {
            dp[i] = dp[i - 1] + 1;
            
            for (int j = 1; j <= 6; j++) {
                int pow = (int)Math.pow(6, j);
                if (pow > i) break;
                
                dp[i] = Math.min(dp[i], dp[i - pow] + 1);
            }
            
            for (int j = 1; j <= 5; j++) {
                int pow = (int)Math.pow(9, j);
                if (pow > i) break;
                
                dp[i] = Math.min(dp[i], dp[i - pow] + 1);
            }
        }
        
        System.out.println(dp[amount]);
    }
}


Measured memory_bytes: 22484
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

struct S{
	int x1,x2,y1,y2,c;
	string name;
	bool contain(int x,int y)
	{
		return x1<=x&&x<=x2&&y1<=y&&y<=y2;
	}
};
S pnl[1000];
int n,m;
string in;

int eval(int s,int t)
{
	if(s>=t)return 0;
	assert(in[s]=='<');
	
	int id=m,bt=in.find('>',s),ns=in.find('<',bt+1);
	m++;
	pnl[id].name=in.substr(s+1,bt-s-1);
	
	string tmp=in.substr(bt+1,ns-bt-1);
	fr(i,tmp)if(*i==',')*i=' ';
	stringstream ss(tmp);
	ss>>pnl[id].x1>>pnl[id].y1>>pnl[id].x2>>pnl[id].y2;
	
	tmp="</"+pnl[id].name+">";
	int es=in.find(tmp,bt),et=es+pnl[id].name.size()+3; assert(s<=es&&es<=t);
	
	int ret=1;
	pnl[id].c=eval(ns,es);
	if(et!=t)ret+=eval(et,t);
	return ret;
}
int main()
{
	while(cin>>n,n)
	{
		cin>>in;
		m=0;
		eval(0,in.size());
		
		rep(i,n)
		{
			int x,y,id=m-1; cin>>x>>y;
			for(;id>=0;id--)if(pnl[id].contain(x,y))break;
			
			if(id<0)cout<<"OUT OF MAIN PANEL 1"<<endl;
			else cout<<pnl[id].name<<" "<<pnl[id].c<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

      
from collections import Counter
n, m = map(int, input().split())

uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a-1,b-1)

print(abs(min((uf.parents))))

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

using namespace std;

using ll = long long;

const ll INF = 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<int> b(m);
    vector<int> c(m, 0);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        
        for (int j = 0; j < b[i]; j++) {
            int hoge;
            cin >> hoge;
            hoge--;
            c[i] |= (1 << hoge);
        }
    }

    vector<ll> dp(1 << n, INF);
    dp[0] = 0;
    for (int i = 0; i < m; i++) {
        vector<ll> ndp = dp;
        for (int j = 0; j < (1 << n) - 1; j++) {
            ndp[j | c[i]] = min(ndp[j | c[i]], dp[j] + a[i]);
        }
        dp = move(ndp);
    }

    cout << (dp[(1 << n) - 1] >= INF ? -1 : dp[(1 << n) - 1]) << "\n";
    return 0;
}

Measured memory_bytes: 384
grid = list()
for i in range(3):
    grid.append([int(k) for k in input().split(" ")])


def check_vert():
    for i in range(2):
        diffs = [grid[k][i] - grid[k][i+1]for k in range(3)]
        if not len(set(diffs)) == 1:
            return False
    else:
        return True


def check_hor():
    for i in range(2):
        diffs = [grid[i][k] - grid[i+1][k] for k in range(3)]
        if not len(set(diffs)) == 1:
            return False
    else:
        return True


if check_hor() and check_vert():
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
program fm
    implicit none
    integer(16)::N,m
    integer::cnt=2
    integer(16)::i,j
    read*,N
    do i=2,int(sqrt(real(N)))
      if(mod(N,i)==0)then
        m=N/i
        do while(mod(m,i)==0)
          m=m/i
        end do
        if(mod(m,i)==1)cnt=cnt+1
      endif
    end do
    do i=2,int(sqrt(real(N-1)))
      if(mod(N-1,i)==0)cnt=cnt+1+merge(0,1,i==(N-1)/i)
    end do
    print"(I0)",cnt-merge(1,0,N==2)
end program fm

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=2e5+10;
struct dot
{
    int num,x,y;
}dots[maxn];
struct node
{
    int u,v;
    ll w;
    bool operator<(const node &b)const
    {
        return w<b.w;
    }
};
vector<node>edge;
int p[maxn];
void init(int n)
{
    for(int i=0; i<=n; i++) p[i]=i;
}
int Find(int x)
{
    if(x==p[x]) return p[x];
    int y=Find(p[x]);
    return p[x]=y;
}
int Union(int x,int y)
{
    int x1=Find(x);
    int y1=Find(y);
    if(x1==y1) return 0;
    p[x1]=y1;
    return 1;
}
void kruskal(int n)
{
    ll sum=0;
    int num=0;
    init(n);
    sort(edge.begin(),edge.end());
    for(int i=0; i<edge.size(); i++)
    {
        int u=edge[i].u;
        int v=edge[i].v;
        ll w=edge[i].w;
        if(Union(u,v))
        {
            num++;
            sum+=w;
        }
        if(num==n-1) break;
    }
    cout<<sum<<endl;
}
int cmpx(dot a,dot b)
{
    return a.x<b.x;
}
int cmpy(dot a,dot b)
{
    return a.y<b.y;
}
int main()
{
    int N;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>dots[i].x>>dots[i].y;
        dots[i].num=i;
    }node tmp;
    sort(dots,dots+N,cmpx);
    for(int i=1;i<N;i++)
    {
        tmp.u=dots[i-1].num;
        tmp.v=dots[i].num;
        tmp.w=abs(dots[i-1].x-dots[i].x);
        edge.push_back(tmp);
    }
    sort(dots,dots+N,cmpy);
    for(int i=1;i<N;i++)
    {
        tmp.u=dots[i-1].num;
        tmp.v=dots[i].num;
        tmp.w=abs(dots[i-1].y-dots[i].y);
        edge.push_back(tmp);
    }
    kruskal(N);


    return 0;
}


Measured memory_bytes: 7664
//***Because people who are crazy enough to think that they can change the world are the ones who do it***
//Think different
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	ll a=0,b=0,c=0,d=0;
	ll n;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		if(s=="AC") a++;
		if(s=="WA") b++;
		if(s=="TLE") c++;
		if(s=="RE") d++;
	}
	cout<<"AC x "<<a<<endl;
		cout<<"WA x "<<b<<endl;
			cout<<"TLE x "<<c<<endl;
				cout<<"RE x "<<d<<endl;
}

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

using namespace std;

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    for(int i=0; i<k; i++) {
        if(i%2==0) {
            b+=a/2;
            a/=2;
        }
        else {
            a+=b/2;
            b/=2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

constexpr lli MOD = (lli)1e9 + 7;
constexpr lli LIMIT = 1000000000000000000 * 5;
constexpr int tenfive = 100000;


int main() {
	string s;
	cin >> s;
	lli ans = 0;
	if (s.size() == 1) {
		cout << s << endl;
		return 0;
	}
	for (size_t bsn = 0; bsn < (1ULL << (s.size()-1)); bsn++) {
		bitset<10>bs(bsn);
		lli bp = 0;
		lli sum = 0;
		for (int i = 0; i < s.size() - 1; i++) {
			if (bs[i]) {
				sum += stoi(s.substr(bp, i - bp+1));
				bp = i+1;
			}
		}
		sum += stoll(s.substr(bp));
		ans += sum;
	}
	cout << ans << endl;
	return 0;
}


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

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

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

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	int M = 2;
	rep(i, 1, N)M *= 2;
	dump(M);
	vector<int> S(M); rep(i, 0, M) {
		cin >> S[i];
	}
	sort(all(S));
	reverse(all(S));
	dump(S);


	map<int, int> mp;
	rep(i, 1, M) {
		mp[S[i]]++;
	}
	dump(mp);

	bool f = true;
	vector<int> v = { S.front() };
	rep(i, 0, N) {
		vector<int> w;
		rep(j, 0, v.size()) {
			auto p = mp.lower_bound(v[j]);
			if (p == mp.begin()) {
				f = false;
				break;
			}
			p = prev(p);
			p->second--;
			w.push_back(p->first);
			if (p->second == 0)mp.erase(p->first);
		}
		if (!f)break;
		v.insert(v.end(), all(w));
		sort(all(v));
		reverse(all(v));
		dump(v, mp);
	}

	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;
}

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

int n, k;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    vector<ll> a(n);
    for (auto& i : a) cin >> i;
    sort(a.begin(), a.end());

    if (k > a[n - 1]) {
        cout << "IMPOSSIBLE";
        return 0;
    }
    
    ll gcd = a[0];
    for (int i = 1; i < n; ++i) {
        gcd = __gcd(gcd, a[i]);
        gcd = __gcd(gcd, a[i] - a[i - 1]);
    }

    if (k % gcd) {
        cout << "IMPOSSIBLE";
    } else {
        cout << "POSSIBLE";
    }
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>

using namespace std;
typedef long long ll;

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	int k; cin >> k;
	string s; cin >> s;
	if (s.size() <= k) {
		cout << s << '\n';
	}
	else {
		for (int i = 0; i < s.size(); i++) {
			if (i + 1 <= k) {
				cout << s[i];
			}
			else break;
		}
		cout << "...";
	}






} 

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

int main()
{
  int h,w;
  while(1){
    cin>>h>>w;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cout<<'#';
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
n,m = map(int, input().split())
qp = [tuple(map(int, input().split())) for _ in range(m)]

qp.sort(key=lambda x:x[1])

ans = 0
pre = 0

while qp:
    a,b = qp.pop(0)
    if pre<a:
        ans += 1
        pre = b-1
print(ans)

Measured memory_bytes: 18596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;  
#define min_heap(t) priority_queue<t,vector<t>,greater<t>>
#define max_heap(t) priority_queue<t>
#define ordered_set(x) tree<x, null_type, less<x>, rb_tree_tag, tree_order_statistics_node_update>
#define orderKey order_of_key
#define findOrder find_by_order
#define F first
#define S second
#define pb emplace_back 
#define mp make_pair
#define f(i,x,y) for(i=x;i<y;i++) 
#define fo(i,x,y) for(i=x;i>=y;i--)
#define all(v) v.begin(),v.end()
#define ss(v) stable_sort(all(v))
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n' 
#define pi  3.14159265358
long long po(long long int m,long long int n){
long long i=1; 
while(n>0)
{
    if(n%2==1)
      i=(i*m);
    n=n/2;
    m=(m*m);
}
return(i);
}
void solve(void){  
    ll n,i;
    cin>>n;
    vector<ll>v(n),dp(n,0);
    for(auto &x:v){
        cin>>x;
    }  
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(i=2;i<n;i++){
        dp[i]=min(dp[i-2]+abs(v[i]-v[i-2]),dp[i-1]+abs(v[i]-v[i-1]));
    } 
    cout<<dp[n-1];
}
int main(void){
    fastio
    ll __=1;
    //cin>> __;
    while(__--){
        solve();
    }
    return 0;
}

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

int main(){
	int H,W,i,j;
	while(1){
		cin>>H>>W;
			if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			for(j = 0;j < W;j++){
				if((i+j+2)%2==0)cout<<"#";
				else if((i+j+2)%2==1)cout<<".";
			}
		cout<<endl;
		}
	cout<<endl;
	}
return 0;
}



Measured memory_bytes: 3072
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
y = []
c = []
for i in range(M):
    X, Y, C= map(int, input().split())
    x.append(X-1)
    y.append(Y-1)
    c.append(C)

value = []
for i in range(M):
    v = a[x[i]] + b[y[i]] - c[i]
    value.append(v)

mindefalt = min(a) + min(b)
minvalue = min(value)

if mindefalt > minvalue:
    print(minvalue)
else:
    print(mindefalt)

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

ll n, h[105];

ll solve(ll left, ll right) {
  ll ret = 0;
  
  if(left < 0 or right < 0 or left >= n or right > n) return 0;
  if(left+1 > right) {
    if(h[left] == 0) return 0;
    else { 
      h[left] = 0;  
      return 1;
    }
  }
  
  ll mini = h[left];
  rep(i, left, right) mini = min(mini, h[i]);
  rep(i, left, right) h[i] -= mini;
  ret += mini;
  
  ll zero = right-1;
  rep(i, left, right) {
    if(h[i] == 0) zero = i;
  }
  ret += solve(left, zero) + solve(zero+1, right);
  return ret;
}  

int main() {
  cin >> n;
  rep(i, 0, n) cin >> h[i];
  cout << solve(0, n) << "\n";
}

Measured memory_bytes: 256
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

T.sort()


def gcd(a, b):
    while (b != 0):
        tmp = a
        a = b
        b = tmp % b

    return a


def lcm(a, b):
    return (a*b)//gcd(a, b)


ans = T[0]
for t in T[1:]:
    ans = lcm(ans, t)
    # print(ans)

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	while(1){
		//入力
		int n;
		scanf("%d", &n);
		if(!n)  break;

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

		//処理
		int ans = 5000000;//とりあえず大きい数字で初期化
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				int tmp;
				if(a[i] < a[j]){
					tmp = a[j] - a[i];
				} else{
					tmp = a[i] - a[j];
				}
				if(tmp < ans){
					ans = tmp;
				}
			}
		}

		//出力(改行を忘れないように)
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2040
import sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

m = {}
def f(n):
    if m.get(n) != None:
        return m[n]
    if n == 0:
        m[n] = (1, 1)
    else:
        b = f(n - 1)
        m[n] = (b[0] * 2 + 3, b[1] * 2 + 1)
    return m[n]

f(N)

def ff(n, t):
    if n == 0:
        return 0 if t <= 0 else 1
    elif t <= 1 + m[n - 1][0]:
        return ff(n - 1, t - 1)
    else:
        return m[n - 1][1] + 1 + ff(n - 1, t - 2 - m[n - 1][0])

print(ff(N, M))

Measured memory_bytes: 3444
import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scanner = new Scanner(System.in);
                int N = Integer.parseInt(scanner.nextLine());
                int[] costs = new int[N];
                int[] cache = new int[N];
                String[] c = scanner.nextLine().split(" ");
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = Integer.parseInt(c[i]);
                        cache[i] = 1000000;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[0]-costs[1]);
                System.out.println(jump(costs, 2, cache));
                return;
        }

        private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    cache[i] = Math.min(cache[i-1]+(Math.abs(costs[i] - costs[i-1])), cache[i-2]+Math.abs(costs[i] - costs[i-2]));                        //System.out.println(Arrays.toString(cache));
                }
                return cache[costs.length-1];
        }
}

Measured memory_bytes: 35964
import math

a, b, h, m = map(int, input().split())

hrad = math.radians(90 - 30 * h - m / 2)
mrad = math.radians(90 - 6 * m)

ax = a * math.sin(hrad)
ay = a * math.cos(hrad)

bx = b * math.sin(mrad)
by = b * math.cos(mrad)

ret = math.sqrt((ax - bx) ** 2 + (ay - by) ** 2)

print(ret)


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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)1e5 + 7;

int a,b,c;
int dp[102][102][102];
int mn = 0x3f3f3f3f;

int main () {
      cin >> a >> b >> c;

      memset(dp,0x3f3f3f3f,sizeof(dp));

      dp[a][b][c] = 0;;

      for (int i = a; i <= 100; i ++) {
            for (int j = b; j <= 100; j ++) {
                  for (int k = c; k <= 100; k ++) {
                        if (i > 0 && j > 0)
                              dp[i][j][k] = min(dp[i][j][k],dp[i - 1][j - 1][k] + 1);
                        if (i > 0 && k > 0)
                              dp[i][j][k] = min(dp[i][j][k],dp[i - 1][j][k - 1] + 1);
                        if (k > 0 && j > 0)
                              dp[i][j][k] = min(dp[i][j][k],dp[i][j - 1][k - 1] + 1);
                        if (i > 1)
                              dp[i][j][k] = min(dp[i][j][k],dp[i - 2][j][k] + 1);
                        if (j > 1)
                              dp[i][j][k] = min(dp[i][j][k],dp[i][j - 2][k] + 1);
                        if (k > 1)
                              dp[i][j][k] = min(dp[i][j][k],dp[i][j][k - 2] + 1);
                        if (i == j && j == k)
                              mn = min(mn,dp[i][j][k]);
                  }
            }
      }
      cout << mn << endl;
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	string s;
	cin >> s;
	int n = s.size();
	bool can = true;
	int cnt = 0;
	while (can) {
		can = false;
		for (int i = 1; i < n; ++i) {
			if (s[i] == '0'&& s[i] == s[i - 1]) {
				s[i] = '1';
				can = true;
				cnt++;
			}
			else if (s[i] == '1'&& s[i] == s[i - 1]) {
				s[i] = '0';
				can = true;
				cnt++;
				
			}
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
  int k,x,s,e,i;
  scanf("%d%d",&k,&x);
  s=x-k+1<-1000000 ? -1000000 : x-k+1;
  e=x+k-1>1000000 ? 1000000 : x+k-1;
  
  for (i=s;i<=e;i++){
    printf("%d ",i);
  }
    
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
typedef long long ll;
const int maxn=2e3+7;
int a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, y, ans;
    cin>>n>>x>>y;
    for(int i=1; i<=n; i++)
        for(int j=i+1; j<=n; j++)
        {
            ans=j-i;
            ans=min(ans, abs(x-i)+1+abs(y-j));
            a[ans]++;
        }
    for(int i=1; i<n; i++) cout<<a[i]<<"\n";
    return 0;
}


Measured memory_bytes: 256
// AOJ 1533: Caterpillar
// 2019.2.28 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

// 数値のハッシュ関数
#define HASHSIZ 499979
long long hash[HASHSIZ + 5], *hashend = hash + HASHSIZ;

// 数値をハッシュテーブルに登録。成功からリターン値が1。
int insert(long long n)
{
	long long *p = hash + (int)(n % HASHSIZ);
	while (*p) {
		if (*p == n) return 0;
		if (++p == hashend) p = hash;
	}
	*p = n;
	return 1;
}

#define QMAX 1000000
typedef struct { long long p; int s, lv; } Q;
Q q[QMAX + 2]; int top, end;
int mv[4][2] = { {-1,0},{1,0},{0,-1},{0,1} };

int H, W, N;
char map[15][15];

long long next(int nr, int nc, long long p)
{
	int i, j, r[6], c[6];
	r[0] = nr, c[0] = nc;                                    // Sの位置
	r[1] = ((p >> 40) >> 4) & 0xf, c[1] = (p >> 40) & 0xf;   // aの位置
	r[2] = ((p >> 32) >> 4) & 0xf, c[2] = (p >> 32) & 0xf;   // bの位置
	r[3] = ((p >> 24) >> 4) & 0xf, c[3] = (p >> 24) & 0xf;   // cの位置
	r[4] = ((p >> 16) >> 4) & 0xf, c[4] = (p >> 16) & 0xf;   // dの位置
	r[5] = ((p >>  8) >> 4) & 0xf, c[5] = (p >>  8) & 0xf;   // eの位置

	for (i = 0; i < 5; i++) for (j = i + 1; j < 6; j++) {
		if (r[i] == r[j] && c[i] == c[j]) return 0;
	}

	return ((long long)((r[0] << 4) | c[0]) << 40) |
		   ((long long)((r[1] << 4) | c[1]) << 32) |
		   ((long long)((r[2] << 4) | c[2]) << 24) |
		   ((long long)((r[3] << 4) | c[3]) << 16) |
		   ((long long)((r[4] << 4) | c[4]) << 8 ) |
		   ((long long)((r[5] << 4) | c[5]));
}

int bfs(long long p)
{
	int i, r, c, rr, cc, s, lv;
	long long pp;

	q[0].p = p, q[0].s = 0, q[0].lv = 1;
	top = 0, end = 1;
	while (top != end) {
		p = q[top].p, s = q[top].s, lv = q[top].lv;
		if (++top == QMAX) top = 0;

		r = ((p >> 40) >> 4) & 0xf, c = (p >> 40) & 0xf;   // 頭の位置
//		printf("(%d,%d) s=%d, level=%d\n", r, c, s, lv);
		if (map[r][c] == lv+'0') lv++;
		if (lv > N) return s;
		if (!insert(p | ((long long)lv << 48))) continue;

		s++;
		for (i = 0; i < 4; i++) {
			rr = r + mv[i][0], cc = c + mv[i][1];
			if (rr < 0 || rr >= H || cc < 0 || cc >= W || map[rr][cc] == '#') continue;
			pp = next(rr, cc, p);
			if (pp == 0) continue;
			q[end].p = pp, q[end].s = s, q[end].lv = lv;
			if (++end == QMAX) end = 0;
		}
	}
	return -1;
}

int main()
{
	int r, c;
	long long p;

	scanf("%d%d%d", &H, &W, &N);
	p = 0; for (r = 0; r < H; r++) {
		scanf("%s", map[r]);
		for (c = 0; c < W; c++) {
			switch (map[r][c]) {
			case 'S': p |= ((long long)((r << 4) | c) << 40); break;
			case 'a': p |= ((long long)((r << 4) | c) << 32); break;
			case 'b': p |= ((long long)((r << 4) | c) << 24); break;
			case 'c': p |= ((long long)((r << 4) | c) << 16); break;
			case 'd': p |= ((long long)((r << 4) | c) <<  8); break;
			case 'e': p |= ((long long)((r << 4) | c)      ); break;
			}
			if (isalpha(map[r][c])) map[r][c] = '.';
		}
	}
	printf("%d\n", bfs(p));
	return 0;
}


Measured memory_bytes: 6660
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++)
        {
            arr[i] = sc.nextInt();
        }
        int count = 0;
        for(int p: arr)
        {
            if(isPrime(p)) count++;
        }
        System.out.println(count);
    }
    public static boolean isPrime(int N) {
        if(N == 1) return false;
        for(long i = 2; i * i <= N; i++) {
            if(N % i == 0) return false;
        }
        return true;
    }
}



Measured memory_bytes: 40860
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int a[N];

int main () {
    to_pray();

    int n;
    cin >> n;
    
    int cnt = 0;
    
    fr(i, 1, n)
    	cin >> a[i];
    sort(a + 1, a + 1 + n);
    
    fr(i, 1, n)
    	fr(j, i + 1, n)
    		fr(k, j + 1, n)
    			if (a[i] < a[j] + a[k] and a[j] < a[k] + a[i] and a[k] < a[j] + a[i])
    				++cnt;
    				
   	cout << cnt;
    
    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);
    cout << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>

using namespace std;

int main() {

	int n;
	cin>>n;
	const int size=100003;
	int counter[size];
	for(int i=0;i<size;i++){
		counter[i]=0;
	}
	for(int i=0;i<n;i++){
		int num;
		cin>>num;
		counter[num]++;
		counter[num+1]++;
		counter[num+2]++;
	}

	int max_num=-1;
	for(int i=0;i<size;i++){
		if(counter[i]>max_num){
			max_num=counter[i];
		}
	}
	cout<<max_num<<endl;



	return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h.at(i);
  int cnt = 0, low = 0;
  vector<int> ans(0);
  while (ans.size() < 2 || ans.at(ans.size() - 1) != ans.at(ans.size() - 2)) {
    for (int i = 0; i < n; i++) {
      if (i == n - 1) {
        if (h.at(i) > low) cnt++;
      }
      else {
        if (h.at(i) > low && h.at(i + 1) <= low) cnt++;
      }
    }
    low++;
    ans.push_back(cnt);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	first := 0
	finish := 0

	for i := 0; i < len(s); i++ {
		if s[i] == 'A' {
			first = i
			break
		}
	}

	for i := len(s) - 1; 0 <= i; i-- {
		if s[i] == 'Z' {
			finish = i + 1
			break
		}
	}

	fmt.Println(finish - first)
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    vector<int> v;
    int N;
    std::cin >> N;

    v.resize(N);
    for(int i=0;i<N;++i){
        std::cin >> v[i];
    }

    sort(v.begin(), v.end());

    std::cout << (v[N-1] - v[0]) << std::endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<int32_t mod>
struct ModInt{
	int32_t a;
	inline int32_t normalize(int64_t x){
		x%=mod;
		if(x<0)x+=mod;
		return x;
	}
	ModInt(const int64_t a=0):a(normalize(a)){}

	ModInt& operator+=(const ModInt &x){
		a+=x.a;
		if(a>=mod)a-=mod;
		return *this;
	}
	ModInt& operator-=(const ModInt &x){
		a-=x.a;
		if(a<0)a+=mod;
		return *this;
	}
	ModInt& operator*=(const ModInt &x){
		a=(int64_t)a*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt x){return ModInt(*this)+=x;}
	ModInt operator-(const ModInt x){return ModInt(*this)-=x;}
	ModInt operator*(const ModInt x){return ModInt(*this)*=x;}
	ModInt operator/(const ModInt x){return ModInt(*this)/=x;}
	bool operator==(const ModInt x){return a==x.a;}
	bool operator!=(const ModInt x){return a!=x.a;}

	ModInt operator-(){return ModInt(0)-ModInt(*this);}
	ModInt pow(int64_t ex)const{
		int64_t x=a;
		int64_t res=1;
		while(ex){
			if(ex&1)res=res*x%mod;
			x=x*x%mod;
			ex>>=1;
		}
		return ModInt(res);
	}
	ModInt inv()const{return pow(mod-2);}
};

template<int32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<int32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}


template<class M>
vector<M>gcd_convolution(vector<M>A,vector<M>B){
	int m=max(A.size(),B.size());
	A.resize(m);
	B.resize(m);
	
	for(int i=1;i<m;i++){
		A[i]+=A[0];
		B[i]+=B[0];
		for(int j=i+i;j<m;j+=i){
			A[i]+=A[j];
			B[i]+=B[j];
		}
	}

	for(int i=0;i<m;i++)A[i]*=B[i];

	for(int i=m-1;i>0;i--){
		A[i]-=A[0];
		for(int j=i+i;j<m;j+=i){
			A[i]-=A[j];
		}
	}
	return A;
}

using mint=ModInt<998244353>;

int N;
int A[222222];

signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];

	vector<mint>X(1000001);
	rep(i,N)X[A[i]]+=A[i];

	X=gcd_convolution(X,X);
	mint ans=0;
	for(int i=1;i<=1000000;i++){
		ans+=X[i]/i;
	}

	rep(i,N)ans-=A[i];
	ans/=2;
	cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 13568
#include <stdio.h>

int main(){
    int A, B;

    do{
        scanf("%d%d", &A, &B);
    } while (A > 16 || B > 16 );

    if(A > 8 || B > 8){
        printf(":(\n");
    } else {
        printf("Yay!\n");
    }

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
   int a,b,q;cin>>a>>b>>q;
   vl s(a),t(b);
   rep(i,a)cin>>s[i];
   rep(i,b)cin>>t[i];
   s.push_back(-INFL);s.push_back(INFL);
   t.push_back(-INFL);t.push_back(INFL);
   sort(been(s));
   sort(been(t));
   ll Q[q];
   rep(i,q)cin>>Q[i]; 
   //cout<<s[0]<<endl;
   rep(_,q){
      ll x=Q[_];//cin>>x;
      int itr_s=lower_bound(been(s),x)-s.begin();
      int itr_t=lower_bound(been(t),x)-t.begin();
      ll ans =INFL;
      rep2(i,itr_s-1,itr_s+1){
          rep2(j,itr_t-1,itr_t+1){
              ll now=min(abs(s[i]-x)+abs(s[i]-t[j]),abs(t[j]-x)+abs(t[j]-s[i]));
              ans=min(ans,now);
          }
      }
      cout<<ans<<endl;
   }
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);

    for (int i = 0; i < H; i++){
        cin >> a.at(i);
    }

    for (int i = 0; i < W + 2; i++){
        cout << '#';
    } cout << endl;

    for (int i = 0; i < H; i++){
        cout << '#' << a.at(i) << '#' << endl;
    }

    for (int i = 0; i < W + 2; i++){
        cout << '#';
    } cout << endl;    
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b) for(int a=0;a<b;a++)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int n,k,m;
int memo[10]={1,1,1,1,1,1,1,1,1,1};
///moudame
signed main(){
  //  fill(memo,memo+10,1);
    cin >> n >>k;
    rep(i,k){
        cin >> m;
        memo[m]=0;
    }
    int y=0;

    for(int i=n;;i++){
        y=i;
        bool no=false;
        while(1){
            if((y/10)<=0){
               // cout << "a";
                if(memo[(int)(y%10)]){cout << i << endl;no=true;}
                break;
            }else{
                if(memo[y%10]){y/=10;}
                else break;
            }
        }
        if(no)break;
    }
return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    while(true){
        int H,W;
        cin>>H>>W;
        if(H==0&&W==0){
            break;
        }
        for(int y=0;y<H;++y){
            for(int x=0;x<W;++x){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (ll)1000000007
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
class Dice {
	int num[6];
public:
	Dice(int a,int b,int c,int d,int e,int f) {
		num[0] = a; num[1] = b; num[2] = c;
		num[3] = d; num[4] = e; num[5] = f;
	}

	void rotate(char c) {
		assert(c == 'N' || c == 'S' || c == 'E' || c == 'W');
		int memo = num[0];
		if (c == 'N') {
			num[0] = num[1];
			num[1] = num[5];
			num[5] = num[4];
			num[4] = memo;
		}
		else if (c == 'S') {
			num[0] = num[4];
			num[4] = num[5];
			num[5] = num[1];
			num[1] = memo;
		}
		else if (c == 'E') {
			num[0] = num[3];
			num[3] = num[5];
			num[5] = num[2];
			num[2] = memo;
		}
		else {
			num[0] = num[2];
			num[2] = num[5];
			num[5] = num[3];
			num[3] = memo;
		}
	}

	int getNum(int index) { return num[index]; }

	void operator=(const Dice& dice) {
		copy(dice.num, dice.num + 6, num);
	}

	bool operator==(const Dice& dice) {
		rep(i, 6) {
			if (num[i] != dice.num[i])return false;
		}
		return true;
	}
};
int n, a[6];
vector<Dice> vec;
signed main() {
	cin >> n;
	srand((unsigned)time(NULL));
	rep(i, n) {
		rep(j, 6)cin >> a[j];
		vec.push_back(Dice(a[0], a[1], a[2], a[3], a[4], a[5]));
	}
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			rep(k, 10000) {
				int m = rand() % 2;
				if (m == 0)vec[i].rotate('N');
				else vec[i].rotate('E');
				if (vec[i] == vec[j]) {
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
 
#define rep(i,m,n) for(unsigned long long int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007
 
using namespace std;
 
using ll =long long int;
using std::swap;
 
vector<long long int> v;
vector<long long int> w;
 
 
int main() {
			int a, b;
			cin >> a >> b;
			int ans = 0;
			if (b == 1);
			else {
				b -= a;	ans++;
				while (b > 0) {
					b -= a - 1;
					++ans;
				}
			}	 
    cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
L=sorted(L,key=lambda x : x[1])
#last=L[0][1]
cnt=0
for i in range(N):
  cnt+=L[i][0]
  if L[i][1]<cnt:
    print('No')
    exit()
  #else:
    #last=L[i][1]
print('Yes')

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

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()

using namespace std;

typedef long long ll;

class BIT {
  public:
  int n;
  vector<int> bit;

  BIT(int n) {
    this->n = n;
    bit.resize(n);
    fill(bit.begin(), bit.end(), 0);
  }

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

  int sum(int end) {
    int ret = 0;
    for(int i=end;i>=1;i-=i&-i) ret += bit[i];
    return ret;
  }
};

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n+1, 0);
  for(int i=1;i<=n;++i) {
    cin >> a[i];
    a[i] += (i?a[i-1]:0LL) - k;
  }

  vector<ll> sorted_a(a);
  sort(sorted_a.begin(), sorted_a.end());

  ll ans = 0;
  BIT tree = BIT(n+2);
  for(int i=n;i>=0;--i) {
    int idx = int(lower_bound(all(sorted_a), a[i]) - sorted_a.begin()) + 1;
    if(i != n) ans += ll(n-i - tree.sum(idx - 1));
    tree.add(idx, 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4096
n = int(input())
def dfs(sss):
  if(int(sss) > n):
    return 0
  r = 1 if(all(sss.count(c) > 0 for c in '753')) else 0
  for c in '357':
    r += dfs(sss+c)
  return r
print(dfs('0'))

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>

int main(){
    int N;
    char a[20];
    int i,j,k;
    int len;
    int multi = 1;
    int sum = 0;
    int inp;
 
    scanf("%d", &N);
    sprintf(a, "%d", N);
    len = strlen(a);
    inp = N;

    for(i=0; i<len; i++){
        sum += inp%10;
        inp = inp /10;
    }
    
    if((N%sum)==0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>

int N,K;

int main()
{
    long long n,l,ans;

    scanf(" %d %d", &N, &K );

    if ( K%2 == 0 ) {
        n = N / K;
        l = ( N + K / 2 ) / K;
        ans = n*n*n + l*l*l;
    } else {
        n = N/K;
        ans = n*n*n;
    }

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


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

const double pi = acos(-1);

int main() {
  in(double, a, b, x);
  cout << setprecision(20);
  double half = a * a * b / 2;
  if (x < half) {
    double y = x / (a * b / 2);
    out(90 - atan(y / b) / pi * 180);
  } else {
    double y = (x - half) / (a * a / 2);
    out(atan((b - y) / a) / pi * 180);
  }
}


Measured memory_bytes: 384
#include <stdio.h>

#define INF 999999999

int N;
int M;
int a[2000];
int valid[2000];

int memo[2000][1 << 12];

int toyosakiaki(int kagi, int aiteru) {
	int c1, c2;
	if (kagi >= M) {
		return aiteru == (1 << N) - 1 ?  0 : INF;
	}
	if (memo[kagi][aiteru]) return ~memo[kagi][aiteru];
	/* スルー */
	c1 = toyosakiaki(kagi + 1, aiteru);
	/* 使う */
	c2 = toyosakiaki(kagi + 1, aiteru | valid[kagi]) + a[kagi];

	return ~(memo[kagi][aiteru] = ~(c1 < c2 ? c1 : c2));
}

int main(void) {
	int i;
	int hayamisaori;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		int b, c;
		int v = 0;
		int j;
		if (scanf("%d%d", &a[i], &b) != 2) return 1;
		for (j = 0; j < b; j++) {
			if (scanf("%d", &c) != 1) return 1;
			v |= (1 << (c - 1));
		}
		valid[i] = v;
	}
	hayamisaori = toyosakiaki(0, 0);
	printf("%d\n", hayamisaori >= INF ? -1 : hayamisaori);
	return 0;
}


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

#define int long long

using namespace std;

string s[10010];

int a[100010];
int dp1[100010],dp2[100010];

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

    int mi,mx;
    mi = INT_MAX;
    mx = INT_MIN;

    for(int i=0;i<n;i++)
    {
        cin >> a[i];

        if(a[i] == 0)
        {
            k--;
            i--;
            n--;
        }

        //mi = min(mi,a[i]);
        //mx = max(mx,a[i]);
    }

    /*if(mi >= 0)
    {
        cout << a[k-1] << endl;
        return 0;
    }
    else if(mx <= 0)
    {
        cout << a[n-k] << endl;
        return 0;
    }*/

    for(int i=0;i<100010;i++)
        dp1[i] = dp2[i] = 1000000007;

    dp1[0] = dp2[0] = 0;

    int st = upper_bound(a,a+n,0) - a;

    for(int i=1;i<=k && st<n;i++)
    {
        dp1[i] = a[st];
        st++;
    }

    st = upper_bound(a,a+n,0) - a;

    for(int i=1;i<=k && st>0;i++)
    {
        st--;
        dp2[i] = abs(a[st]);
    }

    /*for(int i=0;i<=k;i++)
        cout << dp1[i] << " ";
    cout << endl;
    
    for(int i=0;i<=k;i++)
        cout << dp2[i] << " ";
    cout << endl;*/

    int ans = INT_MAX;

    for(int i=0;i<=k;i++)
        ans = min(ans,min(dp1[i],dp2[k-i])+dp1[i]+dp2[k-i]);

    cout << ans << endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
struct X{
	LL w;
	LL b;
	X(LL W,LL B){
		w=W;
		b=B;
	}

};
int N,P;
bool Greater(X &l,X &r){
	return (100-P)*l.w+P*l.b>(100-P)*r.w+P*r.b;
}
int main(int argc, char* argv[])
{
	cin>>N>>P;
	if (N==1){
		cout<<1<<endl;
		return 0;
	}
	vector<X> x;
	int i;
	LL w,b;
	for (i=0;i<N;i++){
		cin>>w>>b;
		x.push_back(X(w,b));
	}
	sort(x.begin(),x.end(),Greater);
	w=0;
	b=0;
	int aw=0;
	for (i=0;i<x.size();i++){
		b+=x[i].b;
	}
	for (i=0;i<x.size();i++){
		aw=i+1;
		w+=x[i].w;
		b-=x[i].b;
		if ((w*100)>=P*(w+b)){
			cout<<aw<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2420
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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;}

string n;

int rec(int k=0,bool tight=true){
    if(k==n.size()){
        return 0;
    }
    int x=n[k]-'0';
    int r;
    if(tight){
        if(x){
            int k1 = rec(k+1,true)+x;
            int k2 = rec(k+1,false)+x-1;
            return max(k1,k2);
        }else{
            return rec(k+1,true)+x;
        }
    }else{
        return (n.size()-k)*9;
    }
}

int main(){
    cin >> n;
    put(rec());
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    for(int i=0;i<n;i++)
    {
        cout<<s1[i]<<s2[i];
    }
   cout<<endl;

    return 0;
}


Measured memory_bytes: 256