akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  import Partition.partition

  val n  = readInt()
  val xs = readLine().split(' ').map { _.toInt }

  val q = partition(xs)

  val ys = xs.iterator.zipWithIndex.map {
    case (x, i) => if (i == q) s"[$x]" else x.toString
  }

  println(ys.mkString(" "))
}

object Partition {
  def partition(xs: Array[Int]): Int = {
    def run(xs: Array[Int], p: Int, r: Int): Int = {
      val x = xs(r)
      var i = p - 1
      var j = p
      while (j < r) {
        if (xs(j) <= x) {
          i += 1
          swap(xs, i, j)
        }
        j += 1
      }

      val q = i + 1
      swap(xs, q, r)
      q
    }

    run(xs, 0, xs.length - 1)
  }

  private def swap(xs: Array[Int], a: Int, b: Int): Unit = {
    val temp = xs(a)
    xs(a) = xs(b)
    xs(b) = temp
  }
}



Measured memory_bytes: 73304
#include <cstdio>
#include <iostream>
inline int Get() {
	char ch;
	int Num, Sign = 0;
	while ((ch = getchar()) < '0' || ch > '9')
		if (ch == '-') Sign ^= 1;
	Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Sign ? -Num : Num;
}
const int N = 2e5 + 5;
int n, m, pos[N], a[20], len, toL[20][N], toR[20][N];
int all, preL[1 << 20], preR[1 << 20], flag[N];
inline int queryL(int x) {
	int l = 1, r = n, res = 1;
	while (l <= r) {
		int mid = l + r >> 1;
		if (toL[len][mid] <= x) res = mid, l = mid + 1;
		else r = mid - 1;
	}
	return res;
}
inline int queryR(int x) {
	int l = 1, r = n, res = 1;
	while (l <= r) {
		int mid = l + r >> 1;
		if (toR[len][mid] >= x) res = mid, r = mid - 1;
		else l = mid + 1;
	}
	return res;
}
int main() {
	n = Get(), m = Get();
	for (int i = 1; i <= n; ++i) pos[i] = Get();
	
	for (int x = m; x; x >>= 1) a[len++] = x >> 1; a[len] = m;
	
	for (int k = 0; k <= len; ++k) {
		toL[k][1] = 1; 
		for (int i = 2; i <= n; ++i) toL[k][i] = (pos[i] - pos[i - 1] <= a[k]) ? toL[k][i - 1] : i;
		
		toR[k][n] = n; 
		for (int i = n - 1; i; --i) toR[k][i] = (pos[i + 1] - pos[i] <= a[k]) ? toR[k][i + 1] : i;
	}
	
	all = 1 << len;
	for (int opt = 0; opt < all; ++opt) preL[opt] = 0;
	for (int opt = 1; opt < all; ++opt) 
		for (int k = 0; k < len; ++k)
			if (opt & (1 << k)) {
				int nxt = opt ^ (1 << k);
				preL[opt] = std :: max(preL[opt], preL[nxt]);
				if (preL[nxt] < n) preL[opt] = std :: max(preL[opt], toR[k][preL[nxt] + 1]);
			}
			
	for (int opt = 0; opt < all; ++opt) preR[opt] = n + 1;
	for (int opt = 1; opt < all; ++opt) 
		for (int k = 0; k < len; ++k)
			if (opt & (1 << k)) {
				int nxt = opt ^ (1 << k);
				preR[opt] = std :: min(preR[opt], preR[nxt]);
				if (preR[nxt] > 1) preR[opt] = std :: min(preR[opt], toL[k][preR[nxt] - 1]);
			}
	
	for (int opt = 0; opt < all; ++opt) {
		int x = queryR(preR[(all - 1) ^ opt] - 1), y = queryL(preL[opt] + 1);
		if (x <= y) ++flag[x], --flag[y + 1];
	}
	
	for (int i = 1; i <= n; ++i) 
		flag[i] += flag[i - 1], puts(flag[i] ? "Possible" : "Impossible");
}

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

int main() {
  int n, T;
  cin >> n >> T;
  int limit = 0;
  int notWorking = 0;

  for(int i=0;i<n;i++) {
    int t;
    cin >> t;
    if(limit < t) {
      notWorking += t - limit;
    }

    limit = t + T;
  }

  cout << limit - notWorking << endl;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

const ll MOD = 1e9 + 7;

ll pow_mod(ll x, ll y)
{
    ll res=1;
    for (; y>0; y>>=1, x=(x*x) % MOD) {
        if (y&1) res = (res*x) % MOD;
    }
    return res;
}

vector<ll> fact, fact_inv;
void comb_init(int max_n)
{
    fact.resize(max_n + 1), fact_inv.resize(max_n + 1);
    fact[0] = fact_inv[0] = 1;
    for (int i=1; i <= max_n; i++) {
        fact[i] = fact[i-1] * i % MOD;
        fact_inv[i] = fact_inv[i-1] * pow_mod(i, MOD-2) % MOD;
    }
}

ll comb(int n, int r)
{
    if (n < r) return 0;
    return fact[n] * fact_inv[r] % MOD * fact_inv[n-r] % MOD;
}

int main()
{
    ios::sync_with_stdio(false);

    ll N; cin >> N;
    ll NN = N + 1;
    vector<int> appear(N+1, -1);

    ll a, b;

    rep(i, NN) {
        int A; cin >> A;

        if (appear[A] >= 0) {
            a = appear[A];
            b = N - i;
        } else {
            appear[A] = i;
        }
    }

    ll all = NN, sum = 1;
    comb_init(NN);

    cout << N << endl;
    for (int k = 2; k <= NN; k++) {
        if (a + b >= k-1) {
            sum = comb(a+b, k-1);
        } else {
            sum = 0;
        }
        all = comb(NN, k);
        cout << (all - sum + MOD) % MOD << endl;
    }
}

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

int main()
{
  int N, M, temp;
  cin >> N >> M;

  vector<int> count(N, 0);
  for (int i = 0; i < 2 * M; i++)
  {
    cin >> temp;
    count[temp - 1]++;
  }
  for (int i = 0; i < N; i++)
    cout << count[i] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b;
    while(scanf("%d",&n)!=EOF)
    {
        a=n/100;
        b=n%10;
        if(a==b)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    double pi = 3.1415926535;
    double r; cin >> r;
    printf("%.10f\n", 2*pi*r);
}


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

int breakblock(int &N, vector<int>S){
    int block = -1; //最終的に砕くレンガの数
    int block_num = 1; //今探している整数
    int br = 0; //前回の整数から砕いたレンガの数
    int i = 0; //今見ているレンガのインデックス
    while(i < N){
        //見ているレンガの整数が探している整数でない
        if(S.at(i) != block_num){
            br++;
            //見ているレンガが最後の場合
            if(i == N-1){
                if(block != -1){
                    block += br;
                    br = 0; 
                }
            }
            //インデックスを進める
            i++;
        }
        //見ているレンガの整数が探している整数の場合
        else{
            //最初の数の場合
            if(block == -1){
                block = br;
            }
            //既に砕いている場合
            else{
                block += br;
            }
            br = 0;
            block_num++;
            i++;
        }
    }

    return block;
}

int main() {
    int N;
    //配列の初期化
    cin >> N;
    vector<int> S(N);
    for(int i = 0; i < N; i++){
        cin >> S.at(i);
    }

    int block = breakblock(N, S);

    cout << block << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    string s;
    cin >> s;
    REP(i, s.size()){
        if(s.at(i) == '?'){ s.at(i) = 'D'; }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3752
fun main(args: Array<String>) {
    val (n, a, b, c, d) = readLine()!!.split(" ").map(String::toLong)
    for (minusTimes in 0 until n) {
        val plusTimes = (n - 1 - minusTimes)
        val max = a - c * minusTimes + d * plusTimes //minusTimes回引き算を行う場合の最大値
        val min = a - d * minusTimes + c * plusTimes
        if (b in min..max) {
            println("YES")
            return
        }
    }
    println("NO")
}

Measured memory_bytes: 40508
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop
import numpy as np

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
D = [int(input()) for _ in range(N)]
"""
N = int(input())
A = np.array(input().split(), dtype=np.float64)
print(1 / sum(1 / A))




# def main():


# if __name__ == '__main__':
#     main()


Measured memory_bytes: 14056
/*input
8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<ll,ll>
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const int maxn=10+5;
const int maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return (a*b)%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int cst[maxn];
int inc[maxn][maxn];
int lvl[maxn];
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    REP(i,n){
        cin>>cst[i];
        REP(j,m) cin>>inc[i][j];
    }
    int anss=INF;
    REP(i,(1<<n)){
        int ans=0;
        REP(j,m) lvl[j]=0;
        REP(j,n){
            if(i&(1<<j)){
                ans+=cst[j];
                REP(k,m){
                    lvl[k]+=inc[j][k];
                }
            }
        }
        bool wk=1;
        REP(j,m){
            if(lvl[j]<x) wk=0;
        }
        if(wk){
            MNTO(anss,ans);
        }
    }
    if(anss==INF) cout<<-1;
    else cout<<anss;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main()
 {
     int A,B,C,D;
     scanf("%d %d %d %d",&A,&B,&C,&D);



       if((A+B)>(C+D))
        printf("Left");

        else if ((A+B)<(C+D))
        printf("Right");

        else if((A+B)==(C+D))
        printf("Balanced");

    return 0;
 }


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

int main() {
    int64_t h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (auto& e : s) cin >> e;

    vector<int64_t> dxy { 0, 1, 0, -1, 0 };
    vector<vector<int64_t>> dist(h*w, vector<int64_t>(h*w, INT32_MAX));
    for (int i = 0; i < h*w; i++) dist[i][i] = 0;

    for (int hi = 0; hi < h; hi++) {
        for (int wi = 0; wi < w; wi++) {
            for (int d = 0; d < 4; d++) {
                int nhi = hi + dxy[d], nwi = wi + dxy[d+1];
                if (nhi < 0 || h <= nhi || nwi < 0 || w <= nwi) continue;
                if (s[hi][wi] != '.' || s[nhi][nwi] != '.') continue;
                dist[w*hi+wi][w*nhi+nwi] = 1;
            }
        }
    }

    for (int i = 0; i < h*w; i++) {
        for (int j = 0; j < h*w; j++) {
            for (int k = 0; k < h*w; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    int64_t ans = 0;
    for (int hi1 = 0; hi1 < h; hi1++) {
        for (int wi1 = 0; wi1 < w; wi1++) {
            for (int hi2 = 0; hi2 < h; hi2++) {
                for (int wi2 = 0; wi2 < w; wi2++) {
                    if (s[hi1][wi1] != '.' || s[hi2][wi2] != '.') continue;
                    if (dist[w*hi1+wi1][w*hi2+wi2] == INT32_MAX) continue;
                    ans = max(ans, dist[w*hi1+wi1][w*hi2+wi2]);
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 1536
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct node
{
    int x,y;
    node operator -(const node &nd)const
    {
        return {x-nd.x,y-nd.y};
    }
    ll operator *(const node &nd)const
    {
        return 1LL*x*nd.x+1LL*y*nd.y;
    }
    ll mo()
    {
        return 1LL*x*x+1LL*y*y;
    }
};
ll X(node aa,node bb)
{
    return 1LL*aa.x*bb.y-1LL*aa.y*bb.x;
}
int main()
{
    node p0,p1;
    while(~scanf("%d%d%d%d",&p0.x,&p0.y,&p1.x,&p1.y))
    {
        int q;
        scanf("%d",&q);
        node p2;
        node xx=p1-p0;
        while(q--)
        {
            scanf("%d%d",&p2.x,&p2.y);
            node yy=p2-p0;
            ll t=X(xx,yy);
            if(t>0)
            {
                puts("COUNTER_CLOCKWISE");
            }
            else if (t<0)
            {
                puts("CLOCKWISE");
            }
            else
            {
                ll f=xx*yy;
                if(f<0)
                {
                    puts("ONLINE_BACK");
                }
                else
                {
                    if(xx.mo() < yy.mo())
                    {
                        puts("ONLINE_FRONT");
                    }
                    else
                    {
                        puts("ON_SEGMENT");
                    }

                }

            }
        }



    }


    return 0;
}




Measured memory_bytes: 3156
n = int(input())
alp = "abcdefghijklmnopqrstuvwxyz"
ans = []


def dfs(s):
    if len(s) == n:
        ans.append(s)
        return 0
    se = len(set(s))
    for i in range(se+1):
        dfs(s+alp[i])


dfs('a')
print(*ans, sep='\n')


Measured memory_bytes: 14496
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=500010;
int n, x, num;
int cnt[maxn], tree[maxn], pos[26][maxn];
ll ans;
char s[maxn];
bool v[maxn];
inline void add(int x, int delta){for(;x<=n;x+=x&-x) tree[x]+=delta;}
inline int query(int x){int sum=0; for(;x;x-=x&-x) sum+=tree[x]; return sum;}
int main()
{
    scanf("%s", s+1); n=strlen(s+1);
    for(int i=1;i<=n;i++) cnt[x=s[i]-'a']++, pos[x][++pos[x][0]]=i, tree[i]=i&-i;
    for(int i=0;i<26;i++) if(cnt[i]&1) num++;
    if(num>1) return puts("-1"), 0;
    for(int i=1;i<=n;i++)
    if(!v[i])
    {
        int x=s[i]-'a', nxt=pos[x][pos[x][0]--];
        if(i==nxt) ans+=(query(n)-query(i))>>1;
        else ans+=query(n)-query(nxt);
        add(nxt, -1); v[i]=v[nxt]=1;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 54016
#include <iostream>

using namespace std;
int main() {
int A,B,c=0,t=0;
cin >> A >> B;
if(B==1){
    cout << 0;
    return 0;
}
t+=A;
    c++;
while(t < B){
    t-=1;
    t+=A;
    c++;
}

cout << c;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll a[3];
    rep(0,i,3)cin>>a[i];
    ll k;
    cin>>k;
    bool t=false;
    ll c=0;
    rep(0,i,2){
        while(a[i+1]<=a[i]&&c<k){
            a[i+1]=2*a[i+1];
            ++c;
        }
        if(a[i+1]>a[i]&&i==1){
            t=true;
        }
    }
    if(t)cout<<"Yes";
    else cout<<"No";
    //cout<<c;
}

Measured memory_bytes: 3620
MOD=998244353
import bisect
N=int(input())

xdlist=[]
for _ in range(N):
  x,d=map(int,input().split())
  xdlist.append((x,d-0.5))
xdlist.sort()
#print(xdlist)

class SegTree:
  #init(init_val, ide_ele): 配列init_valで初期化 O(N)
  def __init__(self, init_val, segfunc, ide_ele):
    #init_val: 配列の初期値
    #segfunc: 区間にしたい操作
    #ide_ele: 単位元
    #n: 要素数
    #num: n以上の最小の2のべき乗
    #tree: セグメント木(1-index)
    n = len(init_val)
    self.segfunc = segfunc
    self.ide_ele = ide_ele
    self.num = 1 << (n - 1).bit_length()
    self.tree = [ide_ele] * 2 * self.num
    # 配列の値を葉にセット
    for i in range(n):
      self.tree[self.num + i] = init_val[i]
    # 構築していく
    for i in range(self.num - 1, 0, -1):
      self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

  #update(k, x): k番目の値をxに更新 O(logN)
  def update(self, k, x):
    #k番目の値をxに更新
    #k: index(0-index)
    #x: update value
    k += self.num
    self.tree[k] = x
    while k > 1:
      self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
      k >>= 1

  #query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
  def query(self, l, r):
    #[l, r)のsegfuncしたものを得る
    #l: index(0-index)
    #r: index(0-index)
    res = self.ide_ele
    l += self.num
    r += self.num
    while l < r:
      if l & 1:
        res = self.segfunc(res, self.tree[l])
        l += 1
      if r & 1:
        res = self.segfunc(res, self.tree[r - 1])
      l >>= 1
      r >>= 1
    return res
  
def segfunc(x,y):
  return max(x,y) #最大値
ide_ele=-float("inf") #最大値
seg=SegTree([-float("inf")]*N, segfunc, ide_ele)

for i in reversed(range(N)):
  x,d=xdlist[i]
  right=x+d
  pos=bisect.bisect(xdlist,((x+d,float("inf"))))
  
  #print(pos)  
  if pos==i+1:
    seg.update(i,i)
  else:
    max_pos=seg.query(i+1,pos)
    seg.update(i,max_pos)
    
dp=[2]*N
for i in reversed(range(N-1)):
  dp[i]=dp[i+1]
  right=seg.query(i,i+1)
  if right<N-1:
    dp[i]+=dp[right+1]
  else:
    dp[i]+=1
  dp[i]%=MOD
  
#print(dp)
print(dp[0])

Measured memory_bytes: 113456
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> num(n);
	REP(i, n) scanf("%d", &num[i]);
	
	FOR(i, 1, m + 1) {
		int pos = 0;
		while (pos < n - 1) {
			int mod1 = num[pos] % i;
			int mod2 = num[pos + 1] % i;
			
			if (mod1 > mod2) swap(num[pos], num[pos + 1]);
			pos++;
		}
	}
	
	REP(i, n) printf("%d\n", num[i]);
	return 0;
}

Measured memory_bytes: 3208
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();

		if (D <= T*S) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}

Measured memory_bytes: 35688
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  auto cnt = vect(4, 0);
  for (int i = 0; i < 3; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cnt[a]++;
    cnt[b]++;
  }
  for (int i = 0; i < 4; i++) {
    if (cnt[i] == 3) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 1000000007;
		long[] fact = new long[2000002];
 		fact[0] = 1;
 		long ans1 = 1;
 		for(int i = 1;i<=2000001;i++){
 			ans1= (ans1*i) % num;
 			fact[i] = ans1;
 		}
 		long[] inv = new long[2000002];
 		inv[0] = 1;
 		for(int i = 1;i<=2000001;i++){
 			inv[i] = power(fact[i], num-2, num)%num;
 		}
		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int k = Integer.parseInt(bf.readLine());
 		String s = bf.readLine();
 		long sum = 0;
 		for(int i = 0;i<=k;i++){
 			long prod = 1;
 			prod*= power(25, i, num);
 			prod%= num;
 			prod*= power(26, k-i, num);
 			prod%= num;
 			prod*= fact[i+s.length()-1];
 			prod%= num;
 			prod*= inv[i];
 			prod%= num;
 			prod*= inv[s.length()-1];
 			prod%= num;
 			sum+= prod;
 			sum%= num;
 		}
 				
 		
 		
 		out.println(sum);
	 		
 		out.close();
 		
 		
 		
 	}
	public static int power(long x, long y, long mod){
		long ans = 1;
		while(y>0){
			if (y%2==1)
				ans = (ans*x)%mod;
			x = (x*x)%mod;
			y/=2;
		}
		return (int)(ans);
	}
	
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 76176
#include <iostream>
#include <cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
double con(int w,int s){
    if(w+s==0)return 0;
    return (double)s/(double)(w+s);
}
int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    double max=0;
    int m_w=0,m_s=0;
    rep(i,31)rep(j,31)rep(k,101)rep(l,101){
        int w1=100*a*i,w2=100*b*j,s1=c*k,s2=d*l;
        if(w1+w2+s1+s2>f || (w1+w2==0||(double)(s1+s2)/((double)(w1+w2)/100.)>e)){
            break;
        }
        if(max<=con(w1+w2,s1+s2)){
            max=con(w1+w2,s1+s2);
            m_w=w1+w2;
            m_s=s1+s2;
            }
    }
    cout<<m_w+m_s<<" "<<m_s<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
    int N,A;
    char s[80];
  	scanf("%s",s);
    N = atoi(s);
  	scanf("%s",s);
    A = atoi(s);
    N%=500;
    if(N<=A){
  		printf("Yes");
    }else{
      	printf("No");
    }
    return 0;
}

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

ll n, m, a, b;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), a = read(), m = read(), b = read();
	if (n == m){
		if (a < b){
			if (a < n) puts("No");
			else puts("Yes");
		} else puts("Yes");
		exit(0);
	}
	while (n > 0 && m > 0){
		m -= a;
		n -= b;
	}
	if (m < 1) puts("Yes");
	else puts("No");
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint q, h, s, d;
    cin >> q >> h >> s >> d;
    lint n;
    cin >> n;
    lint onemin = s;
    onemin      = min(onemin, 4 * q);
    onemin      = min(onemin, 2 * h);
    onemin      = min(onemin, 2 * q + h);
    lint twomin = min(d, 2 * onemin);
    lint ret    = twomin * (n / 2) + onemin * (n % 2);
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

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

    int cnt = 0;
    for(int i=0; i<(int)S.size(); i++){
        if(S[i]!=T[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3784
#include <stdio.h>

int main(int argc, char* argv[])
{
	int data[5];
	int k;

 	int ok = 1;

 	for (int n = 0; n < 5; n++) {
		scanf("%d", &data[n]);
      	if (data[n] < 0 || data[n] > 123) {
          ok *= 0;
        }
		//printf("%d\n", data[n]);
	}
	scanf("%d", &k);
	if (k < 0 || k > 123) {
		ok *= 0;
	}
	//printf("%d\n", k);

  
  	for (int i = 0; i < 4; i++) {
      for (int j = i+1; j < 5; j++) {
        int d = data[j] - data[i];
        if (d > k) {
          ok *= 0;
        }
      }
   }
  
  	if (ok == 1) { printf("Yay!\n"); }
  	else if (ok == 0) { printf(":(\n"); }
  
	return 0;
}

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

using namespace std;

const int INF = 1e9 + 5;

int n, q, ans[200005];

struct dat {
	int x, y, t;
	
	bool operator < (const dat& T) const {
		return x < T.x;
	}
};

int main() {
	scanf("%d%d", &n, &q);
	
	vector <dat> pt;
	
	for (int i = 0; i < n; i++) {
		int l, r, x;
		scanf("%d%d%d", &l, &r, &x);
		
		int lb = l - x;
		int ub = r - x;
		pt.push_back({lb, x, 0});
		pt.push_back({ub, x, 1});
	}
	
	sort(pt.begin(), pt.end());
	
	vector <pair<int, int> > qu;
	
	for (int i = 0; i < q; i++) {
		int x;
		scanf("%d", &x);
		qu.push_back(make_pair(x, i));
	}
	
	sort(qu.begin(), qu.end());
	
	int p = 0;
	
	multiset <int> s;
	
	for (int i = 0; i < q; i++) {
		while (p < pt.size() && pt[p].x <= qu[i].first) {
			if (pt[p].t == 0) s.insert(pt[p].y);
			else s.erase(s.find(pt[p].y));
			p++;
		}
		
		if (s.empty()) ans[qu[i].second] = -1;
		else ans[qu[i].second] = *s.begin();
	}
	
	for (int i = 0; i < q; i++) printf("%d\n", ans[i]);
}


Measured memory_bytes: 17644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

struct Combination{
    vector<long long> _fac,_finv,_inv;
    const int m = MOD;

    Combination(int sz) : _fac(sz),_finv(sz),_inv(sz){
        _fac[0] = _fac[1] = 1;
        _finv[0] = _finv[1] = 1;
        _inv[1] = 1;
        for(int i = 2; i <= sz; i++){
            _fac[i] = _fac[i-1]*i%m;
            _inv[i] = m-_inv[m%i]*(m/i)%m;
            _finv[i] = _finv[i-1]*_inv[i]%m;
        }
    }

    inline int fac(int n){return _fac[n];}
    inline int inv(int n){return _inv[n];}
    inline int finv(int n){return _finv[n];}

    int comb(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return _fac[n]*(_finv[k]*_finv[n-k]%m)%m;
    }
};

int main(){
    int n; cin >> n;
    vector<int> a(n+1);
    rep(i,n+1){
        cin >> a[i];
        a[i]--;
    }
    map<int,int> mp;
    int two;
    int l,r;
    rep(i,n+1){
        mp[a[i]]++;
        if(mp[a[i]] == 2){
            r = i;
            two = a[i];
            break;
        }
    }
    rep(i,n+1){
        if(a[i] == two){
            l = i;
            break;
        }
    }
    Combination C(200000);
    repr(i,1,n+2){
        int ans = (C.comb(n+1,i)-C.comb(n-r+l,i-1)+MOD)%MOD;
        cout << ans << endl;
    }

}


Measured memory_bytes: 11008
require 'prime'

N = gets.to_i
h = {}
(1..N).each{|i|
	next if i % 2 == 0
  s = 1
  i.prime_division.map{|j| s *= j[1] + 1}
  h.key?(s) ? h[s] += 1 : h[s] = 1
}
if h[8].nil?
	puts 0
else
	puts h[8]
end

Measured memory_bytes: 2044
#include <iostream>
#include <array>
#include <algorithm>


auto read = [](auto &x){std::cin >> x;};

auto readSeq = [](auto *begin, auto *end){
                  std::for_each(begin, end, read);
                };
auto println = [](auto x){std::cout << x << std::endl;};
auto printSeq = [](auto *begin, auto *end){
                  std::for_each(begin, end-1, [](auto x){std::cout<<x.suit<<x.value<<" ";});
                  std::cout << (end-1)->suit << (end-1)->value <<  std::endl;
                 };

struct Card {
  char suit;
  char value;

  bool operator == (const Card rhs) const{
    return ((suit == rhs.suit) && (value == rhs.value));
  };
};

int selectionSort(Card *begin, Card *end);
int bubbleSort(Card *begin, Card *end);


int main ()
{
  int n;
  const int max_n = 36;
  std::array<Card, max_n> cards1, cards2;

  read(n);
  for (int i=0; i<n; i++)
    {
      std::cin >> cards1.at(i).suit >> cards1.at(i).value;
      cards2.at(i) = cards1.at(i);
    }


  bubbleSort(cards1.begin(), cards1.begin()+n);
  selectionSort(cards2.begin(), cards2.begin()+n);

  printSeq(cards1.begin(), cards1.begin()+n);
  println("Stable");
  printSeq(cards2.begin(), cards2.begin()+n);

  auto is_stable = true;
  for (int i=0; i<n; i++)
    {
      if (!(cards1[i] == cards2[i]))
        {
          is_stable = false;
          break;
        }
    }
  if (is_stable)
    println("Stable");
  else
    println("Not stable");

  return 0;
}

int selectionSort(Card *begin, Card *end)
{
  auto swap = [](auto &a, auto &b){
                auto tmp = a;
                a = b;
                b =tmp;
              };

  auto n = std::distance(begin, end);
  auto itr = begin;

  auto cnt = 0;

  for (int i=0; i<n-1; i++)
    {
      auto min_i = i;
      for (int j=i+1; j<n; j++)
        {
          if (itr[j].value < itr[min_i].value)
            {
              min_i = j;
            }
        }
      if (i != min_i){
        swap(itr[i], itr[min_i]);
        cnt++;
      }
    }

  return cnt;
}


int bubbleSort(Card *begin, Card *end)
{
  auto swap = [](auto &a, auto &b){
                auto tmp = a;
                a = b;
                b =tmp;
              };

  auto n = std::distance(begin, end);
  auto itr = begin;

  auto cnt = 0;

  for (int i=0; i<n; i++)
    {
      for (int j=n-1; j>i; j--)
        {
          if (itr[j-1].value > itr[j].value)
            {
              swap(itr[j-1], itr[j]);
              cnt++;
            }
        }
    }

  return cnt;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
int cmp(ll a,ll b){
	return a>b;
}
ll bc[1000001],ans[3000001];
int main(){
	int x,y,z,k,n=0;
	ll a[1001],b[1001],c[1001];
	cin>>x>>y>>z>>k;
	for(int i=0;i<x;i++)scanf("%lld",&a[i]);
	for(int i=0;i<y;i++)scanf("%lld",&b[i]);
	for(int i=0;i<z;i++)scanf("%lld",&c[i]);
	sort(a,a+x,cmp);
	sort(b,b+y,cmp);
	sort(c,c+z,cmp);
	for(int i=0;i<y;i++){
		for(int j=0;j<z;j++){
			bc[n]=b[i]+c[j];
			n++;
		}		
	}
	sort(bc,bc+(y*z),cmp);
	n=0;
	for(int i=0;i<x;i++){
		for(int j=0;j<k;j++){
			ans[n]=a[i]+bc[j];
			n++;
		}		
	}
	sort(ans,ans+(x*k),cmp);
	for(int i=0;i<k;i++)cout<<ans[i]<<endl;
	return 0;
}



Measured memory_bytes: 31488
import java.util.Scanner;
class Main
{
	static void Bubble( String B[] )
	{
		for( int i = 0 ; i < B.length ; i++ )
			for( int j = B.length-1 ; i < j ; j-- )
				if( B[j-1].charAt(1) > B[j].charAt(1) )
				{
					String work = B[j-1];
					B[j-1] = B[j];
					B[j] = work;
				}
	}
	static void Selection( String A[] )
	{
		for( int i = 0 ; i < A.length ; i++ )
		{
			int min = i;
			for( int j = i ; j < A.length ; j++ )
				if( A[j].charAt(1) < A[min].charAt(1) )min = j;
			if( min!=i )
			{
				String work = A[i];
				A[i] = A[min];
				A[min] = work;
			}
		}
	}
	static void putArray( String A[] )
	{
		for( int i = 0 ; i < A.length ; i++ )
			if( i==A.length-1 )
				System.out.println( A[i] );
			else
				System.out.print( A[i]+" " );
	}
	static boolean ArrayEquals( String[] A, String B[] )
	{
		for( int i = 0 ; i < A.length ; i++ )
			if( !A[i].equals(B[i]) )return false;
		return true;
	}
	public static void main( String[] args )
	{
		Scanner sc = new java.util.Scanner( System.in );
		
		int n = sc.nextInt();
		String A[] = new String[n], B[] = new String[n];
		for( int i = 0 ; i < n ; i++ )
		{
			A[i]=sc.next();
			B[i] = A[i];
		}
		Bubble( A );
		putArray( A );
		System.out.println("Stable");
		Selection( B );
		putArray( B );
		System.out.println( ArrayEquals(A,B)? "Stable" : "Not stable" );
	}
}

Measured memory_bytes: 26076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp20
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            if (AB[0] <= AB[1]) ans = AB[0];
            else ans = AB[0] - 1;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
ll m=1000000007;
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
int main()
{
ll n;
cin>>n;
ll a[n],b[n],c[n],ans=0;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
cin>>b[i];
for(i=0;i<n-1;i++)
cin>>c[i];
for(i=0;i<n;i++)
{
ans+=b[a[i]-1];
if((i+1)<n && (a[i+1]-a[i])==1)
ans+=c[a[i]-1];
}
cout<<ans;
return 0;
}

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

void printv(vector<ll> v) {
  for (ll i : v)
    cout << i << endl;
}

int main() {
long double a,b,H,M;
	cin>>a>>b>>H>>M;
	long double pi = 3.141592653589793;
	long double theta;
	long double m = 60*H+M;
	long double diff=pi*(M-m/12)/30;
	theta=diff;
	long double c2=a*a +b*b - 2*a*b*cos(theta);
	long double ans=sqrt(c2);
	cout << fixed << setprecision(15)<<ans<<endl;
}


Measured memory_bytes: 4172
S = input()
S = list(S)
flag = True
if S[0] != "A":
    flag = False
flag1 = False
for i in range(2,len(S)-1):
    if S[i] == "C" and flag1:
        flag = False
        
        
    elif S[i] == "C" and not flag1:
        flag1 = True
        S[i] = "c"
if not flag1:
    flag = False
S[0] = "a"
for i in range(len(S)):
    if not S[i].islower():
        flag = False
        
if flag:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
const int D = 60;
const int MAX_N = 200010;
int to[D][MAX_N];

int main() {
    long long N, K; cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> to[0][i];
        to[0][i]--;
    }

    for (int i = 0; i < D - 1; i++) {
        for (int j = 0; j < N; j++) {
            to[i+1][j] = to[i][to[i][j]];
        }
    }

    int v = 0;
    for (int i = 0;  i < D; i++) {
        if (K & (1LL << i)) {
            v = to[i][v];
        }
    }
    cout << v+1 << endl;
}

Measured memory_bytes: 50500
#include<iostream>
using namespace std;
int f(int x[],int y[],int px,int py,int n,int c){
  int i,j,k,l;
  if(c==n)
    return 1;
  for(i=x[c]-1;i<x[c]+2;i++){
    for(j=y[c]-1;j<y[c]+2;j++){
      if(0<=j&&i<=9){
	if(0<=j&&j<=9){
	  for(k=-1;k<2;k++){
	    for(l=-2;l!=6;l+=4){
	      if(i==px+l&&j==py+k){
		   if(f(x,y,px+l,py+k,n,c+1))
		  return 1;
	      }
	      if(i==px+k&&j==py+l){
		if(f(x,y,px+k,py+l,n,c+1))
		  return 1;
	      }
	    }
	  }
	}
      }
    }
  }
  return 0;
}    
int main(){
  int i;
  int px,py,n,x[10],y[10];
  for(;;){
    cin>>px>>py;
    if(px+py==0)
      break;
    cin>>n;
    for(i=0;i<n;i++)
      cin>>x[i]>>y[i];
    if(f(x,y,px,py,n,0))
      cout<<"OK"<<endl;
    else
      cout<<"NA"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int> dp(n);
  dp[0]=0,dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++){
    dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1024
import math
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(N):
        if i != j:
            a = math.pow(xy[j][0] - xy[i][0],2) + math.pow(xy[j][1] - xy[i][1],2)
            ans += math.sqrt(a)

print(ans/N)

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool used[125];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int x, n, p;
  cin>>x>>n;
  REP(i, n){
    cin>>p;
    used[p]=true;
  }
  REP(i, 101){
    if(!used[x-i]){
      cout<<x-i<<'\n';
      break;
    }
    if(!used[x+i]){
      cout<<x+i<<'\n';
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  int n,i,x[45];
  scanf("%d",&n);
  x[0]=x[1]=1;
  for(i=2;i<=n;i++){
    x[i]=x[i-1]+x[i-2];
  }
    printf("%d\n",x[n]);

    return 0;
}



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

using namespace std;

int n;
long long int pool[3628800];
int fwd_min[3628800], bwd_min[3628800];
int fac[11];

long long int enc(int *p)
{
    long long int tmp = 0;
    for (int i = 0; i < n; i++){
        tmp = tmp * 10 + p[i] - 1;
    }
    return (tmp);
}

void bfs(int *p, int *s)
{
    for (int i = 0; i < fac[n]; i++){
        p[i] = -1;
    }

    int id = lower_bound(pool, pool + fac[n], enc(s)) - pool;
    int c[10];

    queue<int> q;
    q.push(id);

    p[id] = 0;

    while (q.size()){
        int x = q.front(); q.pop();

        long long int t = pool[x];
        for (int i = 0; i < n; i++){
            c[n - i - 1] = (t + 1) % 10;
            if (c[n - i - 1] == 0) c[n - i - 1] = 10;
            t /= 10;
        }

        for (int i = 0; i < n; i++){
            for (int j = i + 1; j < n; j++){
                int s = i, t = j;
                while (s < t){
                    c[s] ^= c[t]; c[t] ^= c[s]; c[s] ^= c[t];
                    s++; t--;
                }
                int y = lower_bound(pool, pool + fac[n], enc(c)) - pool;
                if (p[y] == -1){
                    p[y] = p[x] + 1;
                    if (p[y] < 4) q.push(y);
                }

                s = i, t = j;
                while (s < t){
                    c[s] ^= c[t]; c[t] ^= c[s]; c[s] ^= c[t];
                    s++; t--;
                }
            }
        }
    }
}

int main()
{
    int a[16], e[16];

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

    int ctr = 0;
    do {
        long long int tmp = 0;
        for (int i = 0; i < n; i++){
            tmp = tmp * 10 + e[i] - 1;
        }
        pool[ctr++] = tmp;
    } while (next_permutation(e, e + n));

    sort(pool, pool + fac[n]);


    fac[0] = 1;

    for (int i = 1; i <= n; i++){
        fac[i] = i * fac[i - 1];
        e[i - 1] = i;
    }

    bfs(fwd_min, e);
    bfs(bwd_min, a);

    int ans = n - 1;
    int t = lower_bound(pool, pool + fac[n], enc(a)) - pool;

    if (~fwd_min[t]) ans = fwd_min[t];

    for (int i = 0; i < fac[n]; i++){
        if (~fwd_min[i] && ~bwd_min[i]) ans = min(ans, fwd_min[i] + bwd_min[i]);
    }

    printf("%d\n", ans);

    return (0);
}



Measured memory_bytes: 60048
#include <stdio.h>

int main() {
  int i;
  int cnt_5 = 0, cnt_7 = 0;
  int data[3];
  scanf("%d %d %d", &data[0], &data[1], &data[2]);

  for(i = 0; i < 3; i++) {
    if(data[i] == 5) cnt_5++;
    if(data[i] == 7) cnt_7++;
  }
  
  if(cnt_5 == 2 && cnt_7 == 1) printf("YES");
  else  printf("NO");
  
  return 0;
}


Measured memory_bytes: 1708
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int t,x;
  cin >> t >> x;
  double ans = (double)t/x;
  printf("%.10f\n",ans);
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e5+5, LG = 17, MOD = 998244353;
const int SQ = 450;
const long double EPS = 1e-7;
vector<int> v;
int mx1[N], mx2[N], a[N];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  int n;
  cin >> n;

  f(i,1,n+1){
    cin >> a[i];
    mx1[i] = max(mx1[i-1], a[i]);
  }
  for(int i = n; i >= 1; --i){
    mx2[i] = max(mx2[i+1], a[i]);
  }

  f(i,1,n+1){
    cout << max(mx1[i-1], mx2[i+1]) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,x,y,dian;
ll dis[300001];


void solve(){
	int di = 0;
	cin >> n >> x >> y;
	dian = y - x - 1;
	for(int i = 1;i <= n;i ++){
		for(int j = i + 1;j <= n;j ++){
			if(i <= x && j >= y) dis[j - dian -  i] ++;
			else if((i <= x && j <= x) || (i >= y && j >= y)) dis[j - i] ++;
			else if(i >= x && j <= y) dis[min(i - x + y - j + 1,j - i)] ++;
			else if(i >= x && j >= y) di = min(j - y + i - x + 1,j - i), dis[di] ++;
			else if(i <= x && j <= y ) di = min(y - j + x - i + 1,j - i),dis[di] ++;
		}
	}
	for(int i = 1;i < n;i ++) cout << dis[i] << endl;
	return;
}

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

Measured memory_bytes: 256
import Control.Applicative

solve [] = 0
solve ((i,c):s)
  | odd  i && c == 'g' = 0  + solve s
  | odd  i && c == 'p' = -1 + solve s
  | even i && c == 'g' =  1 + solve s
  | even i && c == 'p' =  0 + solve s
  | otherwise = undefined

main = do
  s <- getLine :: IO String
  print $ solve $ zip [1..] s


Measured memory_bytes: 6652
/* AUTHOR :  SHIVANK JAIN */

#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

#define ll long long
#define li long int

#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define reprev(i,n,a) for(int i=n;i>=a;i--)
#define endl "\n"

#define vi vector<int>
#define vll vector<ll>
#define vpi vector< pair<int , int> >
#define mapi map<int , int>
#define mapll map<ll ,ll >
#define seti set<int> 

#define fr first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define sort(v) sort(v.begin() , v.end())

#define BIG 1000000007
int gcd(int a, int b) 
{ // builtin function __gcd(a,b)
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){

     fast;itt;now;
 
//    #ifndef ONLINE_JUDGE
//    // for getting input from input.txt
//    freopen("input.txt", "r", stdin);
//    // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
//    #endif
    
     int n , m;  cin>>n>>m;
     vll h(n+1) , vis(n+1 , 1);
     
	 vis[0] = 0;
     
     rep(i,1,n+1){
     	cin>>h[i];
	 }
	 
	 rep(i,0,m){
	 	int a,b;  cin>>a>>b;
	 	
	 	if(h[a] == h[b])
	 	  vis[a] = 0 , vis[b] = 0;
	 	else{
	 		if(h[a] < h[b])
	 		 vis[a] = 0;
	 		else
			 vis[b] = 0; 
		 }  
	 }
     
	 int ans = 0;
     
     rep(i,1,n+1)
      if(vis[i] == 1)
       ++ans;
       
       cout<<ans<<endl;
}

Measured memory_bytes: 4756
#include<iostream>
using namespace std;
int main()
{ 
 int N,K,count;
 count=0;
 cin>>N>>K;
 int h[N];

 for(int i=0;i<N;i++)
 {
   cin>>h[i];
 }

for(int i=0;i<N;i++)
{
  if(h[i]>=K)
  {
    count++;
  }
}
cout<<count;
return 0;
}

Measured memory_bytes: 640