akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int main (void){
int a,b,c,i;
scanf("%d %d %d",&a,&b,&c); 
for(i=100;i>=1;i--){
if (a%i==0 && b%i==0 ) break;
}
if (c%i != 0) printf("NO\n");
if (c%i == 0) printf("YES\n");
return 0;
}

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

int main(){
  string s[3];
  for(int i = 0;i < 3;i++) cin >> s[i];
  for(int i = 0;i < 3;i++) cout << s[i].at(i);
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	string s;
	cin >> s;
	s[3] = '8';
	cout << s;

	system("PAUSE");

	

}


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

typedef struct point{
	int x,y;
} t_point;

bool cmp(const t_point& a, const t_point& b)
{
	if( a.x < b.x )return true;
	else if( a.x > b.x )return false;
	return a.y < b.y;
}

int main()
{
	int n;
	t_point points[3000];
	
	while(cin>>n,n){
		for(int i=0; i<n; i++)
			cin >> points[i].x >> points[i].y ;
		sort( points, points+n, cmp );
		
		int ans = 0;
		int xi,xj,yi,yj;
		int left,right,diff;
		
		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				xi = points[i].x; yi = points[i].y;
				xj = points[j].x; yj = points[j].y;
				t_point p3 = {yi-yj+xj, xj-xi+yj};
				t_point p4 = {yi-yj+xi,	xj-xi+yi};
				
				left = 0;
				right = n-1;
				while( left<=right ){
					diff = (left+right)/2;
					if( points[diff].x==p3.x && points[diff].y==p3.y )break;
					else if( cmp(points[diff],p3) )
						left = diff+1;
					else
						right = diff-1;
				}
				if( left>right )continue;
				
				left = 0;
				right = n-1;
				while( left<=right ){
					diff = (left+right)/2;
					if( points[diff].x==p4.x && points[diff].y==p4.y )break;
					else if( cmp(points[diff],p4) )
						left = diff+1;
					else
						right = diff-1;
				}
				if( left>right )continue;

				ans = max(ans,(p3.x-p4.x)*(p3.x-p4.x)+(p3.y-p4.y)*(p3.y-p4.y));
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 900
#include<iostream>
using namespace std;
int N,L;
int ice[100000];	//つららの長さ
int ttime[100000];	//伸び始め〜折れるまで
int num[100000];	//左中右とくらべて伸びる順番(0〜2)
int sttime[100000];	//伸び始める時間(>=0)
int main(){
	int i,j;
	cin >> N >> L;
	for(i = 0;i < N;i++){
		cin >> ice[i];
		ttime[i] = L-ice[i];
	}
	for(i = 0;i < N-1;i++){
		if(ice[i] < ice[i+1])
			num[i]++;
		else
			num[i+1]++;
	}
	for(i = 0;i < N;i++){
		if(num[i] != 0)
			continue;
		for(j = i-1;j >= 0;j--){
			if(num[j] == 2){
				if(sttime[j] < sttime[j+1]+ttime[j+1]){
					sttime[j] = sttime[j+1]+ttime[j+1];
				}
				break;
			}
			sttime[j] = sttime[j+1]+ttime[j+1];
		}
		for(j = i+1;j < N;j++){
			if(num[j] == 2){
				if(sttime[j] < sttime[j-1]+ttime[j-1]){
					sttime[j] = sttime[j-1]+ttime[j-1];
				}
				break;
			}
			sttime[j] = sttime[j-1]+ttime[j-1];
		}
	}
	int max = 0;
	for(i = 0;i < N;i++){
		if(max < sttime[i]+ttime[i])
			max = sttime[i]+ttime[i];
	}
	cout << max << endl;
	return 0;
}

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

const int MAX_N = 1e+5;
int color[MAX_N]; // 0(黒), 1(白), -1(未訪問)
vector<P> G[MAX_N];

void dfs(int n, int tmp_col)
{
    // cout << "fill vector with :" << tmp_col << endl;
    color[n] = tmp_col;

    // 対象の頂点と繋がっている頂点を探索
    for (P e : G[n])
    {
        // cout << "target is " << e.first << endl;
        // cout << "target color is " << color[e.first] << endl;
        int t;
        ll cost;
        tie(t, cost) = e;
        // 既に着色済みならば、同色同士が隣接していないか判定
        if (color[t] != -1)
        {
            continue; // いつかは全てのノードが塗りつぶされるので無限ループはしない。
        }

        // 未探索の隣接した頂点があれば、現在の頂点とは異なる色で塗りつぶす
        // cout << "color[n] + cost % 2 is " << (color[n] + cost) % 2 << endl;
        dfs(t, (color[n] + cost) % 2);
    }
}

int main()
{
    int N;
    cin >> N;
    rep(i, N - 1)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back(P(v, w));
        G[v].push_back(P(u, w));
    }

    fill_n(color, N, -1);
    rep(i, N)
    {
        if (color[i] == -1)
        {
            dfs(i, 0);
        }
    }

    rep(i, N)
    {
        cout << color[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 9088
def main():
    N = int(input())
    INF = float('inf')
    dp = [INF] * (N+1)
    dp[0] = 0
    for n in range(1, N+1):
        dp[n] = 1 + dp[n-1]
        for k in range(1, 8):
            p = 6**k
            if n-p >= 0:
                dp[n] = min(dp[n], dp[n-p] + 1)
            p = 9**k
            if n-p >= 0:
                dp[n] = min(dp[n], dp[n-p] + 1)
    
    ans = dp[N]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

int main(){
  int k,ans=0;
  cin>>k;
  rep(i,k){
    rep(j,k){
      rep(l,k){
        ans+=gcd(gcd(i+1,j+1),l+1);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3600
def main():
    n = int(input())
    s = list(input())
    sset = set(s)
    d = {}
    for i in sset:
        d[i] = []
    for i in range(n):
        d[s[i]].append(i)
    dk = d.keys()
    ans = 0
    for i in dk:
        for j in dk:
            for k in dk:
                a = d[i][0]
                f = False
                b = ""
                if d[j][-1] > a:
                    for x in d[j]:
                        if x > a:
                            f = True
                            b = x
                            break
                if f:
                    if d[k][-1] > b:
                        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 41072
#include<bits/stdc++.h>
using namespace std;
int n,ch;
int aa[200002];
int up=100001,dn=100001;
void push(int a[],int now){
  if(now==0){
    aa[dn]=a[now];
    return;
  }
  push(a,now-1);
  if(ch==0){
    dn--;
    aa[dn]=a[now];
    ch=1;
    return;
  }else{
    up++;
    aa[up]=a[now];
    ch=0;
    return;
  }
}
int main(){
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  push(a,n-1);
  if(ch==1){
    for(int i=dn;i<up;i++){
      cout<<aa[i]<<' ';
    }
    cout<<aa[up]<<endl;
  }else{
    for(int i=up;i>dn;i--){
      cout<<aa[i]<<' ';
    }
    cout<<aa[dn]<<endl;
  }
  return(0);
}


Measured memory_bytes: 9984
def euclidean_algorithm(a, b):
    if a < b:
        tmp = b
        b = a
        a = tmp

    ｑ = a // b
    r = a % b
    while r != 0:
        a = b
        b = r
        q = a // b
        r = a % b

    return b


def main():
    a, b = map(int, input().split())

    #ユークリッド互除法(最大公約数)
    gcd = euclidean_algorithm(a, b)

    # 最小公倍数
    lcm = (a*b)//gcd
    print(lcm)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {
    int[] root;

    private void connect(int friend1, int friend2) {
        int root1 = getRootOf(friend1);
        int root2 = getRootOf(friend2);

        root[root2] = root1;
    }

    private int getRootOf(int friend) {
        while (root[friend] != friend) {
            root[friend] = root[root[friend]];
            friend = root[friend];
        }

        return friend;
    }

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        int m = Integer.parseInt(tokenizer.nextToken());
        root = new int[n];
        for (int i = 0; i < n; i++) {
            root[i] = i;
        }
        for (int i = 0; i < m; i++) {
            tokenizer = new StringTokenizer(f.readLine());
            int a = Integer.parseInt(tokenizer.nextToken()) - 1;
            int b = Integer.parseInt(tokenizer.nextToken()) - 1;
            connect(a, b);
        }

        int[] inGroup = new int[n];
        for (int i = 0; i < n; i++) {
            inGroup[getRootOf(i)]++;
        }
        int max = 0;
        for (int i = 0; i < n; i++) max = Math.max(max, inGroup[i]);

        out.println(max);

        out.close();
    }
}

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

typedef long long ll;

int main()
{
    int N;
    string A, B, C;
    cin >> N;
    cin >> A >> B >> C;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] != B[i] && B[i] != C[i] && A[i] != C[i])
        {
            ans += 2;
        }
        else if (A[i] == B[i] && B[i] == C[i] && A[i] == C[i])
        {
            ans += 0;
        }
        else
        {
            ans += 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3576
a,b,n=list(map(int,input().split()))
ans=0
#for x in range(n+1):
if b==n:
  x=n-1
else:
  x=b-1 if n-1>=b else n
ans=int(a*x/b)-a*int(x/b)
print(ans)
#print(x,int(a*x/b),int(x/b)*a,ans)

Measured memory_bytes: 9172
#include <iostream>

using namespace std;

int main() {
    char n;
    cin>>n;
    if(n-'A'>=0 && 'Z'-n>=0) cout << 'A' << endl;
    if(n-'a'>=0 && 'z'-n>=0) cout << 'a' << endl;

    return 0;
}


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){

    long long a,b,c,d,max=LONG_LONG_MIN,tmp;
    
    cin>>a>>b>>c>>d;

    tmp=a*c;
    if(max<tmp){
        max=tmp;
    }

    tmp=a*d;
        if(max<tmp){
        max=tmp;
    }

    tmp=b*c;
        if(max<tmp){
        max=tmp;
    }

    tmp=b*d;
    if(max<tmp){
        max=tmp;
    }


    if(max <0){
        if(a<=0 && b>=0){
            max=0;
        }

        if(c<=0 && d>=0){
            max=0;
        }
    }


    cout<<max<<endl;


    return 0;
}



Measured memory_bytes: 3632
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
int anyDigitSum(int n) {
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}

void Solve() {

	int n, m;
	cin >> n >> m;
	ll x[1005], y[1005], z[1005];
	for (size_t i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i] >> z[i];
	}

	ll best = 0;
	for (size_t i = 0; i < 1 << 3; i++)
	{
		ll sums[1005];
		int t[3];
		
		for (size_t j = 0; j < 3; j++)
		{
			if (i >> j & 1) t[j] = -1;
			else t[j] = 1;
		}
		for (size_t j = 0; j < n; j++)
		{
			sums[j] = x[j] * t[0] + y[j] * t[1] + z[j] * t[2];
		}
		sort(sums, sums + n);
		reverse(sums, sums + n);
		ll sum = 0;
		for (size_t j = 0; j < m; j++)
		{
			sum += sums[j];
		}
		if (i == 0) best = sum;
		else best = max(sum, best);
	}
	cout << best << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define read(arr,n)	for(int i=0;i<n;i++) cin>>arr[i];
#define print(arr,n) for(int i=0;i<n;i++) cout << arr[i]<<' ';cout << endl;
typedef int int32;
#define int ll

using namespace std;

typedef long long ll;

void solve() {
	string s;	cin  >> s;
	char arr[500010] = {};
	int start = 200003;
	int end = 200002;

	for (auto x: s) {
		arr[++end] = x;
	}

	ll q;	cin >> q;
	while (q--) {
		ll a;	cin >> a;
		if (a == 1) {
			swap(start,end);
		} else {
			ll b;	cin >> b;
			char c;	cin >> c;
			if (b == 1) {
				if (start <= end) {	
					start--;	
					arr[start] = c;
				} else {
					start++;	arr[start] = c;
				}
			} else {
				if (start <= end) {
					end++;	arr[end] = c;
				} else {
					end--;	arr[end] = c;
				}
			}
		}
	}
		
	if (start <= end) {
		for (int i =start; i <= end; i++)	cout << arr[i];
	} else {
		for (int i = start; i>= end; i--) cout << arr[i];
	}
}

int32 main() {
	int t = 1;
	ios_base::sync_with_stdio(false);	
	cin.tie(0);

	//cin >> t;
	while (t--) {
		solve();	
	}
	return 0;
}


Measured memory_bytes: 1232
def is_753?(x)
  s = x.to_s(4)
  s.include?('1') && s.include?('2') && s.include?('3') && !s.include?('0')
end

def henkan(n)
  n.to_s(4).tr('3', '7').tr('2', '5').tr('1', '3').to_i
end

def main(n)
  digits = n.size
  cnt = 0
  (4**(digits + 1)).times do |i|
    return cnt if henkan(i) > n
    cnt += 1 if is_753?(i)
  end
  cnt
end

n = gets.to_i
puts main(n)


Measured memory_bytes: 1788
cat<<EOF>Source.cpp
#include <iostream>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int max(int a,int b){
	return a>b?a:b;
}
int x[100000],y[100000],x_mod_k[100000],x_div_k[100000];
char s[100000][2];
int n,k;

void add(int*cnt,int x,int t){
	if((x_div_k[x]&1)==0){
		if(t==0){
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
		else{
			cnt[k-x_mod_k[x]]++;
		}
	}
	else{
		if(t==0){
			cnt[k-x_mod_k[x]]++;
		}
		else{
			cnt[0]++;
			cnt[k-x_mod_k[x]]--;
		}
	}
}
int ans[2000];
int main(){
	scanf("%d%d",&n,&k);
	rep(i,n){
		scanf("%d%d%s",&x[i],&y[i],s[i]);
		x_mod_k[i]=y[i]%k;
		x_div_k[i]=y[i]/k;
	}
	int Max=0;
	#pragma omp parallel for num_threads(2)
	rep(i,k){
		int cnt[max(n,k)];
		rep(j,max(n,k))cnt[j]=0;
		rep(j,n){
			if(s[j][0]=='B'){
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,0);
				}
				else{
					add(cnt,j,1);
				}
			}
			else{
				if(((x[j]+i)/k)%2==0){
					add(cnt,j,1);
				}
				else{
					add(cnt,j,0);
				}
			}
		}
		rep(j,k){
			if(j)cnt[j]+=cnt[j-1];
			ans[i]=max(ans[i],max(cnt[j],n-cnt[j]));
		}
	}
	rep(i,k)Max=max(Max,ans[i]);
	cout<<Max<<endl;
}
EOF
g++ -O3 Source.cpp -o Source -fopenmp -std=c++11
./Source

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

typedef long long ll;

int main()
{
    ll L;
    cin >> L;

    long double l0 = L / 3.0;
    cout << std::fixed;
    cout << l0 * l0 * l0 << endl;

#if 0
    ll l0 = L / 3;
    ll reg = L % 3;

    if(reg == 0)
    {
        cout << l0 * l0 * l0 << endl;
    }
    else if(reg == 1)
    {
        cout << l0 * l0 * (l0 + 1) << endl;
    }
    else
    {
        cout << l0 * (l0 + 1) * (l0 + 1) << endl;
    }
#endif
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main() {
	long long a;
	double b;  
	cin >> a >> b;
    long long b1 = b*100 + 0.5;
	long long res = a * b1;
    long long res1 = res/100;
	printf("%lld", res1);
	return 0;
 
}

Measured memory_bytes: 3792
n, m = map(int, input().split())
l, r = 1, n
for i in range(m):
    li, ri = map(int, input().split())
    if ri<l or r<li:
        print(0)
        exit()
    if l<=li and ri<=r:
        l, r = li, ri
    elif l<=ri<=r:
        r = ri
    elif l<=li<=r:
        l = li
    else:
        continue

print(r-l+1)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <complex>
#include <cassert>
#include <algorithm>
using namespace std;

typedef complex<double> point;
typedef vector<point> polygon;

struct line : public vector<point> {
	line(point a, point b) { push_back(a); push_back(b); }
};

namespace std {
	bool operator<(const point& a, const point& b) {
		return a.real()!=b.real() ? a.real()<b.real() : a.imag()<b.imag();
	}
}

const double eps = 1e-10;
bool   equal(const double a, const double b) { return abs(a-b)<eps; }
bool   equal(const point& a, const point& b) { return abs(a-b)<eps; }
double dot  (const point& a, const point& b) { return (a*conj(b)).real(); }
double cross(const point& a, const point& b) { return (conj(a)*b).imag(); }
point  vec  (const line&  l)                 { return l[1]-l[0]; }
point  ortho(const point& v)                 { return v*point(0,1); }

int ccw(const point& a, const point& b, const point& c) {
	point u=b-a, v=c-a;
	if(cross(u,v) > 0 ) return +1; // ccw
	if(cross(u,v) < 0 ) return -1; // cw
	if(  dot(u,v) < 0 ) return +2; // cab
	if(norm(u)<norm(v)) return -2; // abc
	return 0;                      // acb
}

int ccw(const line& s, const point& p) {
	return ccw(s[0], s[1], p);
}

point crosspoint(const line& l, const line& m) {
	double A = cross(vec(l), vec(m));
	double B = cross(vec(l), l[1]-m[0]);
	if(abs(A)<eps) {			// parallel
		assert(abs(B)<eps);
		return m[0];			// sameline
	}
	return m[0] + B/A*vec(m);
}

polygon convex_hull(polygon& g) {
	polygon r(g),h(2*r.size());
	sort(r.begin(), r.end());

	int i,k,t,sz=r.size();
	for(i=0,k=0; i<sz; h[k++]=r[i++]) {
		while( k>=2 && ccw(h[k-2],h[k-1],r[i])<=0 ) k--;
	}
	for(i=sz-2,t=k+1; i>=0; h[k++]=r[i--]) {
		while( k>=t && ccw(h[k-2],h[k-1],r[i])<=0 ) k--;
	}
	h.resize(k-1);
	return h;
}

polygon convex_cut(const polygon& g, const line& l, int f=0) {
	polygon h;
	line m(l[f%2], l[(f+1)%2]);

	for(int i=0; i<g.size(); i++) {
		const point& a = g[i];
		const point& b = g[(i+1)%g.size()];
		if(ccw(m,a) != -1) h.push_back(a);
		if(ccw(m,a)*ccw(m,b) < 0) {
			point p = crosspoint(line(a,b), m);
			if((!equal(a,p)) && (!equal(b,p))) {
				h.push_back(p);
			}
		}
	}
	return h;
}

int main()
{
	int N;
	while(cin>>N, N) {
		polygon g;
		while(N--) {
			double x,y;
			cin>>x>>y;
			g.push_back(point(x,y));
		}

		polygon h = convex_hull(g);
		for(int i=0; i<g.size(); i++) {
			h = convex_cut(h, line(g[i], g[(i+1)%g.size()]));
		}
		cout << (h.size()?1:0) << endl;
	}


}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}


signed main(){
  int n,h[110000];cin>>n;rep(i,n)cin>>h[i];
  int dp[110000];rep(i,110000)dp[i] = 0;
  dp[1] = abs(h[0]-h[1]);
  repd(i,2,n)dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:https://onlinejudge.u-aizu.ac.jp/services/room.html#RitsCamp18Day1/problems/B>
問題文============================================================
 AORイカちゃんは集合 S={a1,...,aN} と写像 f:S→Sを作った。
 f(ai)=bi である。
 集合 S の任意の要素 x について、g(f(x))=h(f(x)) を満たす全ての写像 g,h:S→S が、
 g(x)=h(x) を満たすかどうか判定し、満たさない場合は反例を一つ構成せよ。

=================================================================

解説=============================================================

 set(b[i]) のサイズがNであれば YES
 Nでなければ、{1..N} のなかで存在しない値に該当する部分を変えれば良い
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> a(N),b(N);
    for(auto& in:a) {cin >> in; in--;}
    for(auto& in:b) {cin >> in; in--;}
    set<ll> s(b.begin(),b.end());
    if(s.size() == N){
        cout << "Yes" << endl;
    }else{
        vector<int> f(N,0);
        for(auto it:s){
            f[it] = 1;
        }
        vector<ll> c(N),d(N);
        iota(c.begin(),c.end(),1);
        iota(d.begin(),d.end(),1);
        for(int i = 0; i < N;i++){
            if(f[a[i]] == 0){
                c[i] = i+1;
                if(i == 0) d[i] = 2;
                else d[i] = 1;
            }else{
                c[i] = i+1;
                d[i] = i+1;
            }
        }
        cout << "No" << endl;
        cout << c << endl;
        cout << d << endl;

    }
	return 0;
}



Measured memory_bytes: 10872
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int n,L,T;
int x[maxn],w[maxn];

int main() {
#ifdef suiyuan2009
  freopen("in.cpp","r",stdin);
#endif
  cin>>n>>L>>T;
  for(int i=0; i<n; i++)cin>>x[i]>>w[i];
  int num=0;
  for(int i=0;i<n;i++){
    if(w[i]==1){
      num+=(x[i]+T)/L;
      x[i]=(x[i]+T)%L;
    } else {
      num+=(x[i]-T)/L;
      x[i]=(x[i]-T)%L;
      if(x[i]<0){
        x[i]+=L;
        num--;
      }
    }
  }
  sort(x,x+n);
  num=(num%n+n)%n;
  for(int i=num;i<n;i++)cout<<x[i]<<endl;
  for(int i=0;i<num;i++)cout<<x[i]<<endl;
  return 0;
}


Measured memory_bytes: 1920
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#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 <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 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,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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


int main(){
    string s;
    int k;
    cin >> k >> s;
    int size = s.length();

    if(size <= k){
        cout << s << endl;
    }else{
        string ss = s.substr(0, k);
        cout << ss << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main() {
    int n, id, p, tid = 0, tp = -1;
    cin >> n;
    while (n--) {
        cin >> id >> p;
        if (tp == p) {
            if (tid > id) {
                tid = id;
            }
        }
        else if (tp < p) {
            tp = p;
            tid = id;
        }
    }
    cout << tid << " " << tp << endl;

    return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<bool> ans(M,true);
  for (int i=0;i<N;i++){
    int K;
    cin >> K;
    set<int> s;
    for (int j=0;j<K;j++){
      int x;
      cin >> x;
      s.insert(x);
    }
    for (int j=1;j<M+1;j++){
      if (!s.count(j)){
        ans[j-1]=false;
      }
    }
  }
  int count=0;
  for (int i=0;i<M;i++){
    if (ans[i]){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import fractions
n=int(input())
lists=list(map(int,input().split()))
gcds=lists[0]
for x in range(n-1):
    if n==0:
        gcds=fractions.gcd(lists[0],lists[1])
    else:
        add=fractions.gcd(lists[x],lists[x+1])
        gcds=fractions.gcd(gcds,add)
print(gcds)

Measured memory_bytes: 16280
#include<stdio.h>
#include<math.h>

int main()
{
    int A,B,H,M;
    scanf("%d%d%d%d",&A,&B,&H,&M);

    double kakuA,kakuB;
    kakuA=(double)0.5*(60*H+M);
    kakuB=(double)6*M;
  	
  	double sa,ans;
  	sa=fabs(kakuA-kakuB)*M_PI/180;
  	ans=sqrt(A*A+B*B-2*A*B*cos(sa));
  	printf("%.16lf",ans);
  	

    return 0;
}


Measured memory_bytes: 2584
#include<iostream>
#include<algorithm>

using namespace std;

static const int MMAX = 20;
static const int NMAX = 50000;
static const int INFTY = (1 << 29);

main() {
  int n, m;
  int C[MMAX];
  int T[NMAX + 1];

  cin >> n >> m;

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

  for ( int i = 0; i <= n; i++ ) T[i] = INFTY;
  T[0] = 0;
  for ( int i = 0; i <= m; i++ ) {
    for ( int j = C[i]; j <= n; j++ ) {
      T[j] = min(T[j], T[j - C[i]] + 1 );
    }
  }

  cout << T[n] << endl;

  return 0;
}

Measured memory_bytes: 3268
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int A[3];
    int D;
    rep(i,3) cin >> A[i];
    cin >> D;
    if((abs(A[1]-A[0])<=D && abs(A[2]-A[1])<=D) || abs(A[2]-A[0])<=D) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0LL)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n;
    cin >> n;
    int max = 0;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        if (max < a[i]) {
            max = a[i];
        }
    }

    int tmp;
    int half_max = -1;
    int half_max_index;
    rep(i, n) {
        tmp = min(max - a[i], a[i]);
        if (half_max < tmp && a[i] != max) {
            half_max = tmp;
            half_max_index = i;
        }
    }

    cout << max << " " << a[half_max_index] << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] l = new int[n];
		for(int i=0; i<n; i++){
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		int len = 0;
		for(int i=0; i<k; i++){
			len += l[n-i-1];
		}
		System.out.println(len);
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(){
    string s,t1="",t2="";
    int n,i,j,cnt1=0,cnt2=0;
    cin >> s;
    n=s.size();
    for (i=0;i<n;i++){
        if (i%2==0){
            t1+='1';
            t2+='0';
        }
        else{
            t1+='0';
            t2+='1';
        }
    }
    for (i=0;i<n;i++){
        if (s[i]!=t1[i])
            cnt1++;
        if (s[i]!=t2[i])
            cnt2++;
    }
    if (cnt1>cnt2)
        cout << cnt2 << endl;
    else
        cout << cnt1 << endl;
    return 0;
}


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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    ll X; cin >> X;
    ll ans = 1;

    for (int i = 2; i <= X; ++i) {
        ll tmp = i * i;
        while (tmp <= X) {
            ans = max(ans, tmp);
            tmp = tmp * i;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

vector<string> p[8] = {
	{}, 

	{}, 

	{},
 
	{"aa.",
  	"..a",
  	"..a"},
 
 	{"aabc",
  	"ddbc",
  	"bcaa",
  	"bcdd"},
 
 	{"aabba",
  	"bcc.a",
  	"b..cb",
  	"a..cb",
  	"abbaa"},
 
 	{"aabc..",
  	"ddbc..",
  	"..aabc",
  	"..ddbc",
  	"bc..aa",
  	"bc..dd"},
 
 	{"aabbcc.",
  	"dd.dd.a",
  	"..d..da",
  	"..d..db",
  	"dd.dd.b",
  	"..d..dc",
  	"..d..dc"}
};

int main() {
	int n;
	cin >> n;

	if(n <= 2) {
		cout << -1 << '\n';
		return 0;
	}

	vector<string> s(n, string(n, '.'));

	function<void(int, int, int)> draw = [&] (int x, int y, int w) {
		for(int i = 0; i < w; ++i) {
			for(int j = 0; j < w; ++j) {
				s[i + x][j + y] = p[w][i][j];
			}
		}
	};

	while(n >= 8) {
		draw(n - 4, n - 4, 4);
		n -= 4;
	}

	draw(0, 0, n);

	for(int i = 0; i < s.size(); ++i) {
		cout << s[i] << '\n';
	}

	return 0;
}

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

struct line {
    long double k, b;
};

vector<line> vt;

long double intersect(line preLast, line last) {
    return - (double)(preLast.b - last.b) / (double)(preLast.k - last.k);
}

long double binarySearch(long double x) {
    int n = vt.size();
    int l = 1, r = n - 1, ans = -1;
    while (l <= r) {
        int m = (l + r) / 2;
        //cout << l << ' ' << m << ' ' << r << ' ' << ans << endl;
        line lcur = vt[m], lprev = vt[m - 1];
        long double xint = intersect(vt[m - 1], vt[m]);
        if (x >= xint) {
            ans = m, l = m + 1;
        } else {
            r = m - 1;
        }
    }
    //cout << vt[0].k * x + vt[0].b << endl;
    if (ans == -1)
        return vt[0].k * x + vt[0].b;
    else
        return vt[ans].k * x + vt[ans].b;
}

void addLine(line l) {
    while (vt.size() >= 2) {
        int n = vt.size();
        line preLast = vt[n - 2], last = vt[n - 1];
        //cout << "go " << preLast.k << ' ' << preLast.b << ' ' << last.k << ' ' << last.b << ' ' << l.k << ' ' << l.b << ' ' << intersect(preLast, last) << endl;
        //cout << - (preLast.b - l.b) * (preLast.k - last.k) << ' ' << - (preLast.b - last.b) * (preLast.k - l.k) << endl;
        long double x1 = intersect(preLast, last), x2 = intersect(preLast, l);
        if (x2 <= x1)
            vt.pop_back();
        else
            break;
    }
    vt.push_back(l);
}

void solve() {
    int n;
    long double c;
    cin >> n >> c;
    vector<long double> h(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    vector<long double> dp(n);
    dp[0] = 0;
    addLine({-2 * h[0], h[0] * h[0]});
    for (int i = 1; i < n; i++) {
        dp[i] = binarySearch(h[i]) + h[i] * h[i] + c;
        //cout << binarySearch(h[i]) << ' ' << h[i] * h[i] << ' ' << c << ' ' << dp[i] << endl;
        addLine({-2 * h[i], dp[i] + h[i] * h[i]});
        //cout << vt.size() << endl;

        // cout << "line" << endl;
        // for (auto x : vt)
        //     cout << x.k << ' ' << x.b << endl;
        // cout << "endline" << endl;
    }
    cout << dp[n - 1];
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(0);
    solve();
    return 0;
}


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

struct UnionFind{
    vector<int> parent;
    vector<int> size;
    vector<int> rank;

    /* constructor (initialize) */
    UnionFind(int n){
        parent.resize(n);
        size.resize(n);
        rank.resize(n);
        for(int i=0; i<n; i++){
            parent[i] = i;// completely-disjoint
            size[i] = 1;
            rank[i] = 0;// union by rank
        }
    }

    int root(int x){
        // terminal case
        if(parent[x] == x){
            return x;// by definition
        }

        // recursion
        parent[x] = root(parent[x]);// path compression : keep tree as shallow as possible
        return parent[x];
    }

    void merge(int x, int y){
        int rx = root(x);
        int ry = root(y);

        // if (root(x) == root(y)) do nothing;
        if (rx != ry){
            if(rank[rx] < rank[ry]){
                parent[rx] = ry;// root of merged tree = ry
                size[ry] += size[rx];
            }
            else if(rank[rx] == rank[ry]){
                parent[rx] = ry;
                size[ry] += size[rx];
                rank[ry] += 1;
            }
            else if(rank[rx] > rank[ry]){
                parent[ry] = rx;// root of merged tree = rx
                size[rx] += size[ry];
            }
        }
        return;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    int nodes(int x){
        return size[root(x)];
    }
};

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

    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    
    set<int> num;
    for(int i=0; i<k; i++){
        num.insert(p[i]);
    }

    UnionFind uf(n-k+1);
    for(int i=0; i+k<n; i++){
        num.insert(p[i+k]);
        if(*num.begin() == p[i] && *prev(num.end()) == p[i+k]){
            uf.merge(i, i+1);
        }
        num.erase(p[i]);
    }

    int count = 1;
    vector<int> non_sorted;
    for(int i=1; i<n; i++){
        if(p[i-1] < p[i]){
            count += 1;
            if(count == k){
                non_sorted.push_back(i-k+1);
                count -= 1;
            }
        }
        else count = 1;
    }
    for(int i=0; i+1<(int)non_sorted.size(); i++){
        int a = non_sorted[i];
        int b = non_sorted[i+1];
        if(uf.same(a,b) == false) uf.merge(a,b);
    }

    set<int> cluster;
    for(int i=0; i<n-k+1; i++){
        cluster.insert(uf.root(i));
    }
    int ans = 0;
    for(auto c : cluster){
        ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int Y;
    cin >> Y;
    int x = -1;
    int y = -1;
    int z = -1;
    for (int i = 0; i <= n; i++) {
        if (10 * i > Y / 1000) break;
        for (int j = 0; j <= n; j++) {
            if (10 * i + 5 * j > Y / 1000) break;
            if (9 * i + 4 * j + n == Y / 1000) {
                x = i;
                y = j;
                z = n - i - j;
            }
        }
    }
    cout << x << " " << y << " " << z << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    String s = next();
    String[] ss = splitString(s);

    int ichi = Integer.parseInt(ss[ss.length-1]);

    //int n = Integer.parseInt(s)


    if(ichi==2 || ichi==4 || ichi==5 || ichi==7 || ichi==9){
      System.out.println("hon");
    }
    if(ichi==0 || ichi==1 || ichi==6 || ichi==8){
      System.out.println("pon");
    }
    if(ichi==3){
      System.out.println("bon");
    }




    //System.out.println();

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35644
#include <stdio.h>

int main(void) {
  int n, count, i, j, div;
  scanf("%d", &n);
  count = 0;
  for (i = 3; i <= n; i += 2) {
    div = 0;
    for (j = 1; j <= i; j++) {
      if (i % j == 0) div++;
    }
    if (div == 8) count++;
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll x[59],y[59];
vector<ll> tate,yoko;

void f(vector<ll> &vec){
    sort(all(vec));
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,K;
    cin>>N>>K;
    
    rep(i,N) cin>>x[i]>>y[i];
    rep(i,N) tate.push_back(y[i]);
    rep(i,N) yoko.push_back(x[i]);
    
    f(tate);
    f(yoko);
    
    ll mn=LLINF*5;
    int n=tate.size();
    rep(i,n)for(int j=i+1;j<n;j++){
        vector<ll> yk;
        rep(ii,N){
            if(y[ii]>=tate[i]&&y[ii]<=tate[j]){
                yk.push_back(x[ii]);
            }
        }
        int nn=yk.size();
        if(nn<K) continue;
        sort(all(yk));
        for(int l=0;l+K-1<nn;l++){
            ll num=1ll*abs(tate[j]-tate[i])*abs(yk[l+K-1]-yk[l]);
            if(num<mn) mn=num;
        }
    }
    cout1(mn);
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

if a % d == 0:
    a_count = a // d
else:
    a_count = a // d + 1

if c % b == 0:
    c_count = c // b
else:
    c_count = c // b + 1


if (c_count - a_count) >= 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9180
#include<stdio.h>
int main()
{
    int N,x,y;
    int A[100000],B[100000];
    scanf("%d",&N);
    for (x=0;x<N;x++)
    {
    	scanf("%d",&A[x]);
	}
	for (x=0;x<N;x++)
	{
		y=A[x]-1;
		B[y]=x+1;
	}
	printf("%d",B[0]);
	for (x=1;x<N;x++)
	{
		printf(" %d",B[x]);
	}
    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

int main(){
    int A,B;
    cin >> A >> B;
    int sum=1;
    int c=0;
    while(sum<B){
        sum+=A-1;
        c++;
    }
    cout << c << endl;
    return 0;

}



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

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


Measured memory_bytes: 256
#ifdef LOCAL
#include "libs/debug/print_list.hpp"
#define debug(x) (cout << # x ": " << x << endl)
#define dev(v, m, n) for(int i=0;i<n;++i){for(int j=0;j<m;++j){cout<<"|"<<v[j][i];}cout<<"|"<<endl;}
#else
#define debug(x) ;
#define dev(v, m, n) ;
#endif

// :----------------------------------------

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;

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;}

#define P (1'000'000'007)

signed main() {
    int a, b, q;
    cin >> a >> b >> q;

    set<int> s, t;

    rep(i, a) {
        capi(x);
        s.insert(x);
    }

    rep(i, b) {
        capi(x);
        t.insert(x);
    }

    rep(i, q) {
        capi(x);
        auto is = s.upper_bound(x);
        auto it = t.upper_bound(x);

        int res = 1ll << 61;
        if (is != s.end() && it != t.end()) {
            chmin(res, max(*is, *it) - x);
        }
        if (is != s.end() && it != t.begin()) {
            auto e = it;
            --e;
            int f = min(x - *e, *is - x);
            int g = max(x - *e, *is - x);
            chmin(res, f * 2 + g);
        }

        if (is != s.begin() && it != t.end()) {
            auto e = is;
            --e;
            int f = min(x - *e, *it - x);
            int g = max(x - *e, *it - x);
            chmin(res, f * 2 + g);
        }

        if (is != s.begin() && it != t.begin()) {
            --is; --it;
            chmin(res, x - min(*is, *it));
        }

        cout << res << endl;
    }
    
    return 0;
}


Measured memory_bytes: 12568
a, b, c = (int(x) for x in input().split())
def check(a, b, c):
    if a==b and not(a==b==c): return(True)
    if a==c and not(a==b==c): return(True)
    if b==c and not(a==b==c): return(True)
    return False

if check(a, b, c):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <stdio.h>

int f[550][550];
int p[550], ans[550];

int main(void)
{
	int i, n, m;
	int a, b, j, sum;
	
	while (1){
		scanf("%d %d", &n, &m);
		
		if (n == 0 && m == 0){
			break;
		}
		for (i = 0; i < n; i++){
			p[i] = 0;
			ans[i] = 0;
			for (j = 0; j < 510; j++){
				f[i][j] = 0;
			}
		}
		for (i = 0; i < m; i++){
			scanf("%d %d", &a, &b);
			f[a - 1][b - 1] = 1;
			if (a == 1){
				p[b - 1] = 1;
				ans[b - 1] = 1;
			}
		}
		sum = 0;
		
		for (i = 1; i < n; i++){
			for (j = 1; j < n; j++){
				if ((p[i] == 1) && (f[i][j] == 1 || f[j][i] == 1)){
					ans[j] = 1;
				}
			}
		}
		for (i = 0; i < n; i++){
			sum += ans[i];
		}
		printf("%d\n", sum);
	}
	return (0);
}
		

Measured memory_bytes: 1680