akhauriyash/Code-Regression huggingface dataset:
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.lang.reflect.Array;
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		while(in.hasNext())new AOJ0058().doIt();
	}
	
	class AOJ0058{
		final double EPS=1.0e-8; 
		boolean parallel(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4){     
			double kata1=(y1-y2)/(x1-x2);
			double kata2=(y3-y4)/(x3-x4);
			if(kata1==kata2)return true;
			if((y1-y2==0&&y3-y4==0)||(x1-x2==0&&x3-x4==0))return true;
			return false;
		}
		boolean parallel(Line2D l1,Line2D l2){
			return parallel(l1.getP1().getX(), l1.getP1().getY(), l1.getP2().getX(),l1.getP2().getY(),
					l2.getP1().getX(),l2.getP1().getY(),l2.getP2().getX(),l2.getP2().getY());
		}
		boolean orthogonal(Line2D l1,Line2D l2){
			return orthogonal(l1.getP1().getX(), l1.getP1().getY(), l1.getP2().getX(),l1.getP2().getY(),
					l2.getP1().getX(),l2.getP1().getY(),l2.getP2().getX(),l2.getP2().getY());
		}
		boolean orthogonal(double x1,double y1,double x2,double y2,double x3,double y3,double x4,double y4){
			double a=(y1-y2)/(x1-x2);
			double b=(y3-y4)/(x3-x4);
			if(Math.abs(a-(-(1/b)))<EPS||Math.abs((-(1/a)-b))<EPS)return true;
			if(Math.abs((-(1/b))-a)<EPS||Math.abs(b-(-(1/a)))<EPS)return true;
			return false;
		}
		
		void doIt(){
			Line2D l1 = new Line2D.Double(in.nextDouble(), in.nextDouble(), in.nextDouble(), in.nextDouble());
			Line2D l2 = new Line2D.Double(in.nextDouble(),in.nextDouble(), in.nextDouble(), in.nextDouble());
			if(parallel(l1, l2))System.out.println("NO");
			else if(orthogonal(l1, l2))System.out.println("YES");
			else System.out.println("NO");
		}
	}
	
}

Measured memory_bytes: 23344
double*q,s[99],*p=s,v,atof();
t;
main(c){
	for(;t=0,~scanf("%s%c",&t,&c);c&2&&printf("%f \n",*--p))
		t<48?
			v=*--p,q=p-1,*q=
				t&1?
					t&2?
						t&4?
							*q/v
						:*q+v
					:*q-v
				:*q*v
			:
				(*p++=atof(&t))
		;
}

Measured memory_bytes: 0
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
a = na()
ans = 0
for i in a:
    while i % 2 == 0:
        i //= 2
        ans += 1
print(ans)


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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    int N, K; cin >> N >> K;
    multiset<int> p; int a; int sum=0; int num=0;
    REP(i,N){
        cin >> a;
        p.insert(a);
    }

   for(auto i: p){
        sum += i;
        num++;
        if(num==K) break;
    }
    cout << sum << endl;
}

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

int main(){
    double d1,d2;
    cin>>d1>>d2;
    double ans=(d1+d2)/2;
    if(abs(d1-d2)>180)ans+=180;
    if(ans>360)ans-=360;
    if(ans<0)ans+=360;
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;

int main() {
    //freopen("hi.txt", "r", stdin);
    ll a,b,c,d;
    ll n;
    scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&n);
    n*=4;
    b=min(b,a*2);
    c=min(c,b*2);
    d=min(d,c*2);
    ll ans=0;
    //1 2 4 8
    ans+=(n/8)*d;
    n-=(n/8)*8;
    ans+=(n/4)*c;
    n-=(n/4)*4;
    ans+=(n/2)*b;
    n-=(n/2)*2;
    ans+=n*a;
    printf("%lld",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
	getline(cin ,a);
	getline(cin ,b);
	int ans=0;
	for(int i=0;i<3;i++){
		if(a[i] == b[i] )
			ans++;
	}
	cout <<ans<<endl;
	return 0;
}

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

int64_t gcd(int64_t a,int64_t b){
  int64_t r=max(a,b)%min(a,b);
  if(r==0){
    return min(a,b);
  }
  return gcd(min(a,b),r);
}

int main(){
  int64_t N,X;
  cin >> N >> X;
  int64_t x,ans;
  cin >> x;
  ans=abs(X-x);
  for(int i=1;i<N;i++){
    cin >> x;
    ans=gcd(ans,abs(X-x));
  }
  cout << ans << endl;
  return 0;
}


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

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

  int a = x/500;
  int b = x%500;
  int c = b/5;

  cout << a*1000 + c * 5 << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
S = [input() for _ in range(N)]

count = defaultdict(int)

for s in S:
	if s[0] in ["M", "A", "R", "C", "H"]:
		count[s[0]] += 1

ans = 0
for a, b, c in combinations(count.values(), 3):
	ans += a*b*c
print(ans)


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

#define int long long

string s;
int a, b;

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	a = (s[0] - '0') * 10 + (s[1] - '0');
	b = (s[2] - '0') * 10 + (s[3] - '0');
	if (a && a < 13 && b && b < 13)
		cout << "AMBIGUOUS";
	else if (a && a < 13)
		cout << "MMYY";
	else if (b && b < 13)
		cout << "YYMM";
	else
		cout << "NA";
}

Measured memory_bytes: 384
// https://atcoder.jp/contests/diverta2019/tasks/diverta2019_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: i64
    };


    let mut set = HashSet::new();
    let mut total = 0;
    for a in 1..1000001i64 {
        let ln = n-a;
        if ln < 0 {
            continue;
        }
        if ln % a == 0 {
            let m = ln/a;
            if m > a {
                total += m;
                set.insert(m);
            }
        }
    }

    for m in 1..1000001i64 {
        let a = n/m;
        let b = n%m;
        if a == b {
            if !set.contains(&m) {
                set.insert(m);
                total += m;
            }
        }
    }
    println!("{}", total);
}


Measured memory_bytes: 4352
import numpy as np

# 入力
N, K = map(int, input().split())
H = np.array([int(i) for i in input().split()])

# ndarray型のDPテーブルを生成
dp = np.zeros(N, dtype=int)
# 初期値をセット
dp[0] = 0

# 各足場へたどり着く最小コストを調べる
for i in range(1, N):
    s = max(0, i-K)
    dp[i] = min(dp[s:i] + np.abs(H[i] - H[s:i])) # iより前の足場のコストに足す

print(dp[N-1])

Measured memory_bytes: 23092
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x,n = readInts()
if n == 0:
    print(x)
    exit()
P = readInts()
A = []
for i in range(-1,max(P)+1,1):
    if i + 1 in P:
        pass
    else:
        A.append(i+1)
#print(A)
m = float('inf')
ans = -1
for a in A:
    if abs(x - a) < m:
        ans = a
        m = abs(x-a)
print(ans)


Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<int, ii>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
const int MOD = 1e9 + 7;
const int INF = 2e9;
// const int N = ;

int k;

void solve() {
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++) {
        cin >> k;
        for(int i = 1; i <= k; i++) {
            cout << "ACL";
        }
        cout << "\n";
    }
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
inline int rd() {
    char ch=getchar(); int i=0,f=1;
    while(!isdigit(ch)) {if(ch=='-')f=-1; ch=getchar();}
    while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=getchar();}
    return i*f;
}
const int N=2e5+50,INF=0x3f3f3f3f;
int n,col[N],fa[N],sze[N];
int d1[N]; 
int d2[N]; 
int d3[N]; 
int d4[N]; 
int d5[N]; 
int d6[N];
vector <int> edge[N]; 
inline void dfs1(int x,int f) {
    fa[x]=f; sze[x]=col[x];
    if((x!=1 && edge[x].size()==1) || (x==1 && !edge[x].size())) {
        d1[x]=0; 
        d3[x]=(col[x]?0:INF);
        return;
    }
    int mx=0,mx2=INF;
    for(auto v:edge[x]) {
        if(v==f) continue;
        dfs1(v,x); sze[x]+=sze[v];
        mx=max(mx,d1[v]); 
        if(d3[v]<INF) mx2=min(mx2,d1[v]);
    }
    d1[x]=mx+1; d3[x]=mx2+1; 
    if(col[x]) d3[x]=min(d3[x],d1[x]); 
}
inline void dfs2(int x,int f) {
    d2[x]=max(d2[x],(f!=0)+d2[f]);
    if(f) d5[x]=max(d5[x],d2[x]-1);
    int mx,mx2;
    mx=-1;
    for(int e=0;e<edge[x].size();++e) {
        int v=edge[x][e]; if(v==f) continue;
        d2[v]=max(d2[v],mx+2);
        mx=max(mx,d1[v]);
    }
    mx=-1;
    for(int e=edge[x].size()-1;e>=0;e--) {
        int v=edge[x][e]; if(v==f) continue;
        d2[v]=max(d2[v],mx+2);
        mx=max(mx,d1[v]);
    }
    for(auto v:edge[x]) if(v!=f) dfs2(v,x);
}
int main() { 
    n=rd();
    memset(d3,0x3f,sizeof(d3));
    memset(d4,0x3f,sizeof(d4));
    for(int i=1;i<n;i++) {
        int x=rd(), y=rd();
        edge[x].push_back(y);
        edge[y].push_back(x); 
    }
    string s; cin>>s; int bz=0;
    for(int i=0;i<n;i++) col[i+1]=s[i]-'0', bz|=col[i+1];
    if(!bz) {puts("0"); return 0;}
    dfs1(1,0); 
    dfs2(1,0);
    long long ans=0;
    for(int i=1;i<=n;i++) {
        if(col[i]) d6[i]=0;
        else d6[i]=min(d3[i],(sze[i]==sze[1])?INF:d2[i]);
        int u=max(d1[i],d2[i])-1;
        for(auto v:edge[i]) {
            if(v==fa[i]) u=min(u,d1[i]+1);
            else u=min(u,d5[v]+1);
        } 
        if(u>=d6[i]) ans=ans+u-d6[i]+1;
    }
    cout<<ans+1;
    return 0;
}


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

int main() {
  int N;
  string s;
  cin >> N;
  for (int i= 0; i < N; i++) {
    cin >> s;
    if (s == "Y") {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


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



int main(){
  
  int K,A,B;
  cin>>K>>A>>B;
  bool can=false;
  for(int i=1;i<1000;i++){
    if(i*K>=A&&i*K<=B){
      can=true;
      break;
    }
  }
  if(can) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;  
  
}

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

using namespace std;

long long d[200005][3];

int main() {
	ios::sync_with_stdio(false);
	long long n, k;
	long long r, s, p;
	cin>>n>>k;
	cin>>r>>s>>p;
	string t;
	cin>>t;
	for (long long i = 0; i < t.size(); i++) {
		if (i >= k) {
			d[i][0] = (i - k >= 0) * max(d[i - k][1], d[i - k][2]) + (t[i] == 's') * r;
			d[i][1] = (i - k >= 0) * max(d[i - k][0], d[i - k][2]) + (t[i] == 'p') * s;
			d[i][2] = (i - k >= 0) * max(d[i - k][0], d[i - k][1]) + (t[i] == 'r') * p;
		} else {
			d[i][0] = (t[i] == 's') * r;
			d[i][1] = (t[i] == 'p') * s;
			d[i][2] = (t[i] == 'r') * p;
		}
	}
	/*for (long long i = 0; i < t.size(); i++)
		cout<<d[i][0]<<" "<<d[i][1]<<" "<<d[i][2]<<endl;*/
	long long res = 0;
	for (long long i = t.size() - 1; (i >= 0) && (k > 0); k--, i--)
		res += max(d[i][0], max(d[i][1], d[i][2]));
	cout<<res;
}


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

int main()
{
    char s[100], t[100], u[100];
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(strcmp(s, u)==0) a--;
    if(strcmp(t, u)==0) b--;

    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
d=dict()
for i in range(n):
    if a[i] not in d:
        d[a[i]]=1
    else:
        d[a[i]]+=1
ans=0
for key in d:
    if key<=d[key]:
        ans+=d[key]-key
    else:
        ans+=d[key]
print(ans)

Measured memory_bytes: 21856
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <time.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define classname SubtreeSumHash



void solve()
{
    ll x;
    cin >> x;
    ll t = 0, s = 0;
    while(s < x)
    {
        t++;
        s += t;
    }
    
    cout << t << "\n";
}

void gcj()
{
    int t;
    cin >> t;
    for(int i = 0; i < t; i++)
    {
        cout << "Case #" << i + 1 << ": ";
        solve();
        cout << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //gcj();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<map>
#define ll long long int
#define ld long double
#define pb push_back
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100009
#define endl '\n'
#define mp make_pair
#define INF 100000000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define pii pair<long long int,long int>
#define mii map<long long int,long long int>
#define w(t) 	int t; cin>>t; while(t--)

using namespace std;

//ll c[MAX];




int main() {
	string s;
	cin>>s;
	if(s=="ABC")	cout<<"ARC";
	else	cout<<"ABC";
}


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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    
    if(x>=r and x <= W - r and y >= r and y <= H - r){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 3112
#define _USE_MATH_DEFINES	//M_PI
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string
#include <vector>			//std::vector
#include <valarray>			//std::valarray	??°????????????????¬???????
#include <algorithm>		//std::sort
#include <time.h>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs, pow, sqrt, sin, cos,
#include <fstream>			//std::ifstream
#include <iomanip>			//std::setprecision

int main(void) {

	//test??¨
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

	int n;
	std::cin >> n;

	std::valarray<double> x(n);
	for (int i = 0; i < n; i++) {
		std::cin >> x[i];
	}

	std::valarray<double> y(n);
	for (int i = 0; i < n; i++) {
		std::cin >> y[i];
	}

	std::valarray<double> z(n);
	z = abs(x - y);
	double p1 = z.sum();

	std::valarray<double> temp = z*z;
	double p2 = sqrt(temp.sum());

	temp *= z;
	double p3 = pow(temp.sum(), 1.0 / 3.0);

	double pm = z.max();

	std::cout << std::fixed << std::setprecision(10) << p1 << std::endl;
	std::cout << std::fixed << std::setprecision(10) << p2 << std::endl;
	std::cout << std::fixed << std::setprecision(10) << p3 << std::endl;
	std::cout << std::fixed << std::setprecision(10) << pm << std::endl;

}

Measured memory_bytes: 1344
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
char n[200010];
cin >> n;
char m[200010];
cin >> m;
bool ans=0;

pair<char, char> id[27];
id[0].first = m[0];
id[0].second =n[0];
int syu=1;
int size=strlen( n );
bool flag=1;
//cout << size << endl;
for(int i=1;i<size;++i){
    //cout << n[i]<<" "<<m[i] <<syu<< endl;
    for(int j=0;j<syu;++j){
        if(id[j].first==m[i]){
            flag=0;
            if(id[j].second!=n[i]){ans=1;}
        }
        if(id[j].second==n[i]){
            flag=0;
            if(id[j].first!=m[i]){ans=1;}
        }

    }
    if(flag){id[syu].first = m[i];id[syu].second =n[i];syu++;}
    flag=1;
}

//回答
string ans1;
if(ans){ans1="No";}
else{ans1="Yes";}
cout << ans1 << endl;
return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
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;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    std::string s;
    cin >> s;
    int l = s.length();
    std::vector<int> over(l, 0);
    std::vector<int> safe(l, 0);
    over[0] = 2;
    safe[0] = 1;
    for (int i = 1; i < l; i++) {
        if (s[i] == '1') {
            over[i] = over[i - 1] * 2 % MOD;
            safe[i] = (over[i - 1] + safe[i - 1] * 3) % MOD;
        } else {
            over[i] = over[i - 1] % MOD;
            safe[i] = safe[i - 1] * 3 % MOD;
        }
    }
    cout << (over[l - 1] + safe[l - 1]) % MOD << endl;
    return 0;
}

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

const int N = 300010;

int num[N], sum[N], n;

int main() {
    scanf("%d", &n); int A = 0, B = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &num[i]), sum[i] = sum[i - 1];
        if (i & 1) sum[i] += num[i], A += num[i];
        else sum[i] -= num[i], B += num[i];
    }
    if (n % 2 == 0) {
        printf("%d %d\n", max(A, B), min(A, B));
        return 0;
    }
    auto check = [&](int mid) -> bool {
        int mn = 0; static int dp[N];
        for (int i = 1; i <= n; i += 2) 
            if (sum[i] - mn >= mid) {
                mn = min(mn, sum[i + 1]), dp[i] = 1;
            } else dp[i] = 0;
        return dp[n];
    };
    int l = 1, r = A + B, mid, res = B;
    while (l <= r) {
        if (check(mid = (l + r) >> 1)) res = B + mid, l = mid + 1;
        else r = mid - 1;
    }
    printf("%d %d\n", res, A + B - res);
} 

Measured memory_bytes: 3712
N = int(input())
h = list(map(int, input().split()))

ans = 'Yes'
for i in range(N - 2, 0, -1):
  if h[i] > h[i + 1] + 1:
    ans = 'No'
    break
  elif h[i] == h[i + 1] + 1:
    h[i] -= 1

print(ans)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h;
	cin >> h;
	if (h == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll ans = 0;
	ll f = 1;
	ans += f;
	h /= ll(2);
	f *= 2;
	while (h > 1){
		 ans += f;
		 h /= ll(2);
		 f *= 2;
	}
	cout << ans+f << endl;
}
 


Measured memory_bytes: 256
/**
*    author:  boutarou
*    created: 05.07.2020 21:04:11
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;

int  h, w, K;
char c[10][10];
int ans;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> h >> w >> K;
    rep(i, h) {
        rep(j, w) {
            cin >> c[i][j];
        }
    }
    rep(i, (1 << h)) {
        rep(j, (1 << w)) {
            int bit1[10], bit2[10];
            rep(k, h) bit1[k] = i / (1 << k) % 2;
            rep(k, w) bit2[k] = j / (1 << k) % 2;
            bool red[10][10];
            rep(k, h) {
                rep(l, w) {
                    red[k][l] = false;
                }
            }
            rep(k, h) {
                if (bit1[k]) {
                    rep(l, w) {
                        red[k][l] = true;
                    }
                }
            }
            rep(k, w) {
                if (bit2[k]) {
                    rep(l, h) {
                        red[l][k] = true;
                    }
                }
            }
            int cnt = 0;
            rep(k, h) {
                rep(l, w) {
                    if (!red[k][l] && c[k][l] == '#') cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3640
n,m = map(int,input().split())

D = 10**9 + 7
if abs(n-m) == 0:
    res = 1
    for i in range(1,n+1):
        res = (res * i)%D
        res = (res * i)%D
    res = (res * 2)%D
    print(res)
elif abs(n-m) == 1:
    n,m = max(n,m),min(n,m)
    res = 1
    for i in range(1,n+1):
        res = (res * i)%D
    for i in range(1,m+1):
        res = (res * i)%D
    print(res)
else:
    print(0)


Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<iostream>
#include<cstdio>
using namespace std;
const int big=(1<<30);
int gcd(int a,int b){if(a<b){swap(a,b);}if(b==0){return a;}return gcd(a%b,b);}
int main(void){
	string ny;
	cin>>ny;
	if(ny.size()==2){if(ny[0]==ny[1]){cout<<"1 2"<<endl;}else{cout<<"-1 -1"<<endl;}return 0;}
	for(int i=0;i<ny.size()-2;i++){if(ny[i]==ny[i+1]||ny[i+1]==ny[i+2]||ny[i+2]==ny[i]){cout<<i+1<<" "<<i+3<<endl;return 0;}}
	cout<<"-1 -1"<<endl;
	return 0;
}

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

int main(){
  int N;cin>>N;
  vector<int> A(100000,0);
  for(int i=0;i<N;i++){
    int D;cin>>D;
    A.at(D)++;
  }
  priority_queue<int> ans;
  for(int i=1;i<99999;i++){
    int L=A.at(i-1)+A.at(i)+A.at(i+1);
    ans.push(L);
  }
  cout<<ans.top()<<endl;
}


Measured memory_bytes: 4264
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


int comb[60][60];

void solve(long long N, long long A, long long B, std::vector<long long> v){
    sort(ALL(v));
    reverse(ALL(v));

    double sum = 0;
    for(int i = 0; i < A; ++i) {
        sum += v[i];
    }

    printf("%.10f\n", sum / A);

    int a = 0;
    for(int i = 0; i < N; ++i) if (v[A - 1] == v[i]) {
        a = i;
        break;
    }

    int m = 0;
    for(int i = 0; i < N; ++i) if(v[i] == v[A - 1]) m++;

    for(int i = 0; i < 60; ++i) {
        comb[i][0] = 1;
        for(int j = 1; j <= i; ++j) {
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
        }
    }

    int res = 0;
    if (v[0] == v[A - 1]) {
        for (int i = A; i <= B; ++i) {
            if (v[i - 1] != v[A - 1]) {
                continue;
            }
            int n = i - a;
            res += comb[m][n];
        }
    } else {
        res += comb[m][A - a];
    }

    cout << res << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&v[i]);
    }
    solve(N, A, B, std::move(v));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N,i;
	double b = 0;
	double z = 0;
	double A[10000];
	if(scanf("%d", &N) == 1){};
	for(i = 0;i < N;i++)
	{
		if( scanf("%lf", &A[i]) == 1){};
	}
		for(i = 0;N > i;i++)
		{
			b =  1 / A[i];
			z = z + b;
		}
printf("%lf",1/z);
return 0;
}

Measured memory_bytes: 128
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = [];
  $b = [];
  for ($i=0; $i<$n; $i++) {
    list($a[], $b[]) = explode(" ", trim(fgets(STDIN)));
  }

  array_multisort($b, $a);

  $sum = 0;
  for ($i=0; $i<$n; $i++){
    $sum+=$a[$i];
    if($b[$i] < $sum){
      echo "No";
      exit;
    }
  }
  echo "Yes";

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

#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define fill(a, z) memset(a, z, sizeof(a))
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << z << ' '
#define cnl(z) cout << z << '\n'
#define printclock cerr << "Time : " << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms\n";
#define M 1000000007
#define M2 998244353
#define MAXN 300005
#define INF 1000000000000
#define endl "\n"
#define iip(t) \
	int t;     \
	cin >> t;
#define iip2(a, b) \
	int a, b;      \
	cin >> a >> b;
#define dip(a) \
	double a;  \
	cin >> a;
#define dip2(a, b) \
	double a, b;   \
	cin >> a >> b;
#define garr(ip)       \
	for (auto &x : ip) \
		cin >> x;
#define parr(ip)          \
	for (auto &x : ip)    \
		cout << x << " "; \
	cout << endl;
#define test   \
	int _t;    \
	cin >> _t; \
	while (_t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vp;

int modExp(int base, int exponent = M - 2, int MOD = M)
{
	if (exponent == 0)
		return 1;
	int curr = modExp(base, exponent >> 1);
	curr = (curr * curr) % MOD;
	if (exponent & 1)
		curr = (curr * base) % MOD;
	return curr;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	iip(n);
	set<string> s;
	while (n--)
	{
		string t;
		cin >> t;
		s.insert(t);
	}
	cnl(s.size());
}

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

int main()
{
    int n, m, lot[100];
    string s, num[100];

    while( cin >> n >> m )
    {
        if( n + m == 0 )
            break;

        for( int i = 0; i < n; i++ )
            cin >> num[i] >> lot[i];

        int sum = 0;
        for( int i = 0; i < m; i++ )
        {
            cin >> s;
            for( int j = 0; j < n; j++ )
            {
                bool judge = true;
                for( int k = 0; k < s.size(); k++ )
                    if( num[j][k] != '*' && num[j][k] != s[k] )
                    {
                        judge = false;
                        break;
                    }
                if( judge )
                    sum += lot[j];
            }
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;

// #define  part ..
#define listi vector<int > 
#define listll vector<long long >
#define pii pair<int ,int > 
#define pll pair<long long ,long long >
#define heap priority_queue<long long >

#define pb(a) push_back(a)
#define mod 998244353
#define maxx 200006
#define ll long long 
#define quick  	ios_base::sync_with_stdio(NULL),cin.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// #define test int t;cin>>t;while(t--)
// end of #define 

// define globals ...


//write function from here ...



int Main(){

	long a,b,c,k;
	cin>>a>>b>>c>>k;

	int ans= min(a,k);
	k=k-a;
	if(k>0){
		
		k =k-b;
	}

	if(k>0){
		ans -= min(c,k);
	}

cout<<ans<<endl;




return 0;



}
























// main function..
int main(){
	quick;  
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    Main();
    
    
}


Measured memory_bytes: 3620
mod = 10**9+7
rng = 100001
fctr = [1]
finv = [1]
for i in range(1,rng):
    fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
    finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
    if n<0 or k<0:
        return 0
    else:
        return fctr[n]*finv[n-k]*finv[k]%mod
n,k = map(int,input().split())
n += 1
for i in range(1,k+1):
    if k+i>n:
        print(0)
    else:
        print(cmb(k-1,i-1)*cmb(n-k,i)%mod)

Measured memory_bytes: 11300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll ans = 0;
    int n;
    cin >> n;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++ ){
                ans +=__gcd(k,__gcd(j,i));
            }
        }
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define mod 1000000007
#define pb(a) push_back((a))
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
//#define INF 931931114518101
using namespace std;
typedef pair<ll, ll> P;
typedef pair<ll, P> lP;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
ll h, w;
char grid[501][501];
ll x4[] = {0, 1, 0, -1, 0};
bool blue[501][501], red[501][501], vis[501][501];
P road[501][501];
//-------------------関数----------------------//
int main() {
  cin >> h >> w;
  REP(i, h) {
    REP(j, w) { cin >> grid[i][j]; }
  }
  REP(i, h) {
    REP(j, w) {
      if ((j == 0 || i % 2 || grid[i][j] == '#') && j != w - 1) {
        cout << "#";
      } else {
        cout << ".";
      }
    }
    cout << endl;
  }
  cout << endl;
  REP(i, h) {
    REP(j, w) {
      if ((j == w - 1 || i % 2 == 0 || grid[i][j] == '#') && j != 0) {
        cout << "#";
      } else {
        cout << ".";
      }
    }
    cout << endl;
  }
}


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

using namespace std;
const long mod = 1000000007;
typedef long long lint;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(N) for(int i = 0; i < (int)(N); i++)
#define all(x) (x).begin(),(x).end()
#define length(x) ((int)(x).size())
#define prln(s) cout<<s<<endl;

#define str(s) string s;cin>>s;
#define int1(x) int x;cin>>x;
#define int2(x,y) int x,y;cin>>x>>y;

int main() {
  int2(n,d);
  
  int map[n][d];
  rep(i,n){
    rep(j,d){
      cin>>map[i][j];
    }
  }
  int ans=0;
  rep(i,n-1){
    for (int j=i+1; j < n; ++j) {
      lint nijowa=0;
      rep(k,d){
        nijowa+=(map[i][k]-map[j][k])*(map[i][k]-map[j][k]);
      }
      double kyori=sqrt(nijowa);
      if(kyori==round(kyori)){
        ans++;
      }
    }
  }
  prln(ans);

}


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

int main() {
	int n;
	while (cin >> n, n) {
		int ans = 0;
		for (int i = 1;i <= n / 2;i++) {
			int count = 0;
			for (int j = i;count < n;j++) {
				count += j;
			}
			if (n == count)ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
n = int(input())
l = [list(input().split()) for i in range(n)]
sum = float(0)
rate = float(380000)
for i in range(n):
    if l[i][1] == "JPY":
        sum += float(l[i][0])
    else:
        sum += float(l[i][0]) * rate
print(sum)

Measured memory_bytes: 3060
x, n = map(int, input().split())
try:
	p_li = list(map(int, input().split()))
except:
	print(x)
	exit()

for i in range(100000):
	
	if not((x - i) in p_li):
		print(x - i)
		break
	
	if not((x + i) in p_li):
		print(x + i)
		break

Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define poi 601000
using namespace std;
typedef long long ll;
struct girl
{
	int x,y;
	bool operator<(const girl &b)const
	{
		return (x^b.x)?x<b.x:y<b.y; 
	}
}a[poi];
int b[poi],ans,h,w,n,tans;
set<pair<int,int> > s;
inline int re()
{
	char x=getchar();
	int k=1,y=0;
	while(x<'0'||x>'9')
	{if(x=='-') k=-1;x=getchar();}
	while(x>='0'&&x<='9')
	{y=(y<<3)+(y<<1)+x-'0';x=getchar();}
	return y*k;
}
void wr(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) wr(x/10);
	putchar(x%10+'0');
}
int lookfor(int st)
{
	int x=a[st].x;
	for(int i=st;;i++)
	{
		if(a[i].x!=x) break;
		s.erase(make_pair(b[a[i].y]--,a[i].y));
		s.insert(make_pair(b[a[i].y],a[i].y));
	}
	ans=(*--s.end()).first;
	for(int i=st;;i++)
	{
		if(a[i].x!=x) return i;ans++;
		s.erase(make_pair(b[a[i].y]++,a[i].y));
		s.insert(make_pair(b[a[i].y],a[i].y));
	}
}
signed main()
{
	//freopen("lca.in","r",stdin);
	//freopen("lca.out","w",stdout);
	h=re(),w=re(),n=re();
	for(int i=1;i<=n;i++)
	{
		a[i].x=re(),a[i].y=re();
		b[a[i].y]++;
	}
	for(int i=1;i<=w;i++)
	s.insert(make_pair(b[a[i].y],a[i].y));
	sort(a+1,a+n+1);
	for(int i=1;i<=n;)
	{
		i=lookfor(i);
		tans=max(ans,tans);
	}
	wr(tans);
	return 0;
}

Measured memory_bytes: 21220
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

ll cnt2(ll n) {
    if(n == 0LL) return 0;
    if(n % 2LL != 0) return 0;
    return (n / 2LL) + cnt2(n / 2LL);
}

ll cnt5(ll n) {
    if(n < 5LL) return 0;
    return (n / 10LL) + cnt5(n / 5LL);
}

int main() {
    ll n; cin >> n;
    cout << min(cnt2(n), cnt5(n)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9+10;
const int maxn=1e5+10;
const int maxm=20;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n;
struct node {
    int x,y;
    int id;
}town[maxn];
struct edge {
    int st,ed;
    int cost;
}e[maxn*4];
int fa[maxn];
bool cmp1(const node &a,const node &b) {
    return a.x<b.x;
}
bool cmp2(const node &a,const node &b) {
    return a.y<b.y;
}
bool cmp3(const edge &a,const edge &b) {
    return a.cost<b.cost;
}
int Find(int x)
{
    if(fa[x]!=x)
        fa[x]=Find(fa[x]);
    return fa[x];
}
int main() {
	cin >> n;
    for(int i=1;i<=n;i++) {
        cin >> town[i].x >> town[i].y;
        town[i].id=i;
    }
    int k=0;
    sort(town+1,town+1+n,cmp1);
    for(int i=1;i<=n-1;i++) {
        e[k].st=town[i].id;
        e[k].ed=town[i+1].id;
        e[k++].cost=abs(town[i].x-town[i+1].x);
    }
    sort(town+1,town+1+n,cmp2);
    for(int i=1;i<=n-1;i++) {
        e[k].st=town[i].id;
        e[k].ed=town[i+1].id;
        e[k++].cost=abs(town[i].y-town[i+1].y);
	}
    sort(e,e+k,cmp3);
    for(int i=1;i<=n;i++)
        fa[i]=i;
	int ans=0;
	for(int i=0;i<k;i++) {
            int a=Find(e[i].st),b=Find(e[i].ed);
            if(a!=b) {
                ans+=e[i].cost;
                fa[b]=a;
            }
        }
    cout << ans;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <numeric>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>


using namespace std;
using ll = long long;
const ll INF = 1e18;

int main() {
    int N;
    cin >> N;
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

ll modpow(ll n, ll r) {
    ll ret = 1;
    ll p = n;
    while (r > 0) {
        if (r & 1)
            ret = (ret * p) % MOD;
        r /= 2;
        p = (p * p) % MOD;
    }
    return ret;
}

ll P[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    Combination cmb(2LL * N + 10);
    ll ans = 0;
    if (K >= 2)
        ans++;
    REP(i, std::min(K, N + 1)) {
        ll p = cmb.get(N, i + 1) * cmb.get(N - (i + 1) + (i + 1) - 1, i + 1);
        ans += p;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  ll a,b,c,k,sum,ans=0;
  cin >> a >> b >> c >> k;
  sum=a+b+c;
  if(a>k){
    ans+=k;
  }
  else if(a<=k && k < a+b){
    ans+=a;
  }
  else if(a+b <= k && k < sum ){
    ans=a-(k-(a+b));
  }
  else if(k=sum){
    ans=a-c;
  }

  cout << ans << endl;



}

Measured memory_bytes: 3612
#include<stdio.h>
#define INFTY 1000000

int min(int,int);

int main(){
  int l,i,j,k,n,p[100],m[101][101],q;
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++){
    m[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INFTY;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=min(m[i][j],q);
      }
    }
  }

  printf("%d\n",m[1][n]);
  return 0;
}

int min(int a,int b){
  if(a<b)return a;
  else return b;
}
	

  

  



Measured memory_bytes: 2764
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int s[n];
    for(int i=0;i<n;i++){
        cin >> s[i];
    }
    int q; cin >> q;
    int t[q];
    for(int i=0;i<q;i++){
        cin >> t[i];
    }
    int count=0;
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if (s[j] == t[i]){
                count++;
                break;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1196
N = int(input().rstrip())
As = [int(x) for x in input().rstrip().split()]

d = {}
for x in As:
    if x not in d.keys():
        d[x] = 1
    else:
        d[x] += 1
if len(As) == len(d):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 33004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807

int main()
{
ll n;
cin >> n ;
vector<vector<ll>> g(n);
vector<pair<ll,ll>> v(n);
rep(i, n)
{
  ll a, b;
  cin >> a >> b;
  v[i].first=a;
  v[i].second=b;
  if(i==0)continue;
  g[i].push_back((i-1)/2);
  g[(i-1)/2].push_back(i);
}
vector<ll> par(n);
vector<ll> d(n);
vector<bool> see(n);
{
queue<ll> q;
par[0]=-1;
see[0]=1;
d[0]=1;
q.push(0);
while(!q.empty()){
  auto p=q.front();
  q.pop();
  for(auto r:g[p]){
    if(see[r]!=0)continue;
    par[r]=p;
    d[r]=d[p]+1;
    see[r]=1;
    q.push(r);
  }
}
}
vector<vector<ll>> dp(min(n,(1LL<<9) -1), vector<ll>(100010,INF) );
rep(i,100010)if(i<v[0].second)dp[0][i]=0; else dp[0][i]=v[0].first; 
rep(i,min(n,(1LL<<9) -1)){
  if(i==0)continue;
  rep(j,100010)dp[i][j]=dp[(i-1)/2][j];
  rep(j,100010)if(j-v[i].second>=0)dp[i][j]=max(dp[i][j], dp[(i-1)/2][j-v[i].second]+v[i].first);
}
ll q ;
cin >> q ;
vector<ll> ans(q,0);
rep(i,q){
  ll u , l ;
  cin >> u >>l  ;
  if(u< 1LL<<9)ans[i]=dp[u-1][l];
  else{
    vector<pair<ll,ll>> t;
    ll w=u-1;
    rep(j,d[u-1]-9){
      t.push_back(v[w]);
      w=(w-1)/2;
    }
    ans[i]=dp[w][l];
    ll vv=0,ww=0;
    rep(j,1LL<<t.size()){
      if(j==0)continue;
      ll c=j^(j>>1);
      if(c>>__builtin_ctzll(j) &1LL){vv+=t[__builtin_ctzll(j)].first;ww+=t[__builtin_ctzll(j)].second;}
      else {vv-=t[__builtin_ctzll(j)].first;ww-=t[__builtin_ctzll(j)].second;}
      if(l-ww>=0)ans[i]=max(ans[i],dp[w][l-ww]+vv);
    }
  }
}
for(auto r:ans)cout << r << endl;
return 0;
}

Measured memory_bytes: 429988
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;
    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) != T.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
int p2(int n)
{
  int a = 1;
  while(n--) a *= 2;
  return a;
}

int main(void)
{
  int n, m;
  std::cin >> n >> m;
  std::cout << (1800 * m + 100 * n) * p2(m) << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val p = (0 until n).map { sc.next().toLong() }
    println(problem152c(n, p))
}

fun problem152c(n: Int, p: List<Long>): Int {
    val p = p.toLongArray()
    var count = 0
    val dp = LongArray(n)
    dp[0] = p[0]
    for (i in 1 until n) {
        dp[i] = Math.min(dp[i - 1], p[i])
    }
    for (i in 0 until n) {
        if (p[i] <= dp[i]) count++
    }
    return count
}

Measured memory_bytes: 62700
H,W = map(int, input().split())
grid = []
for i in range(H):
    grid.append(input())
horiz = [[None]*W for _ in range(H)]
horiv = [[] for _ in range(H)]
for i in range(H):
    cur = 0
    for j in range(W):
        if grid[i][j] == '.':
            horiz[i][j] = len(horiv[i])
        else:
            horiv[i].append(j - cur)
            cur = j + 1
    horiv[i].append(W-cur)

maxv = 0
for c in range(W):
    cur = 0
    besth = 0
    for r in range(H):
        if grid[r][c] == '.':
            besth = max(besth, horiv[r][horiz[r][c]])
        else:
            maxv = max(maxv, r-cur + besth - 1)
            cur = r+1
            besth = 0
    maxv = max(maxv, H-cur + besth - 1)

print(maxv)

Measured memory_bytes: 155864
#include <stdio.h>

#define MAX_N 100

typedef struct{
  int src,dst;
} Node;

void dfs(int,int,int[MAX_N][MAX_N]);

int time,visited[MAX_N];
Node node[MAX_N];

int main(){
  int n,u,k,v,i,j;
  int G[MAX_N][MAX_N];
  for(i = 0 ; i < MAX_N ; i++){
    for(j = 0 ; j < MAX_N ; j++){
      G[i][j] = 0;
    }
  }
  time = 0;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d%d",&u,&k); u--;
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v); v--;
      G[u][v] = 1;
    }
    visited[i] = 0;
  }
  for(i = 0 ; i < n ; i++){
    if(!visited[i]){
      visited[i] = 1;
      dfs(i,n,G);
    }
  }
  for(i = 0 ; i < n ; i++){
    printf("%d %d %d\n",i+1,node[i].src,node[i].dst);
  }
  return 0;
}

void dfs(int v,int n,int G[MAX_N][MAX_N]){
  int i;
  node[v].src = ++time;
  for(i = 0 ; i < n ; i++){
    if(G[v][i] == 0){ continue; }
    if(visited[i] == 1){ continue; }
    visited[i] = 1;
    dfs(i,n,G);
  }
  node[v].dst = ++time;
}

Measured memory_bytes: 636