akhauriyash/Code-Regression huggingface dataset:
i = int(input())

for i in range(i):
    i = i+1
    a = True

    if i%3 == 0:
        print(' ', end = '')
        print(i, end = '')
    else:
        x = i
        while a:
            if x%10 == 3:
                print(' ', end = '')
                print(i, end = '')
                break
            x //= 10
            if x == 0:
                a = False

print()


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

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

int main(){
	string d, h;
	cin >> d >> h;
	string ans = "H";
	if(d != h) ans = "D";
	cout << ans << endl;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int minv, maxv;
    minv = min(min(a, b), c);
    maxv = max(max(a, b), c);
    cout << maxv - minv << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int maxn = 100000;
const int maxw = 1000000000;

int N;
int u[maxn],v[maxn],w[maxn];
typedef struct edge{
    int to;
    int cost;
}Edge;
vector<vector<edge> > G(maxn);
vector<int> color(maxn,INF);

void dfs(int v, int c){
    color[v] = c;
    if(G[v].size() != 0){
        REP(i,G[v].size()){
            if(color[G[v][i].to] == INF){
                if(G[v][i].cost == 0){color[G[v][i].to] = color[v];}
                else{color[G[v][i].to] = (color[v] + 1) % 2 ;}
                dfs(G[v][i].to, color[G[v][i].to]);
            }
        }
    }
}

int main(){
    cin >> N;
    REP(i,N-1){
        cin >> u[i] >> v[i] >> w[i];
        u[i]--, v[i]--;
        w[i] = w[i] % 2;
        Edge ev = {v[i], w[i]};
        Edge eu = {u[i],w[i]};
        G[u[i]].push_back(ev);
        G[v[i]].push_back(eu);
    }

    REP(i,N){
        if(color[i] == INF){
            dfs(i,0);
        }
        printf("%d\n", color[i]);
    }
}

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

string T,P;
vector<int> vec;

main(){
	cin >> T >> P;
	vec = vector<int>(P.size(),-1);
	int ip = 0;
	for(int i = 0; i < T.size() && ip < P.size(); i++){
		if(T[i] == P[ip]){
			vec[ip++] = i;
		}
	}
	if(vec[P.size()-1] < 0){
		cout << "no" << endl;
		return 0;
	}
	ip = P.size() - 1;
	for(int i = T.size() - 1; i >= 0; i--){
		if(T[i] == P[ip]){
			if(i != vec[ip--]){
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;

	return 0;
}

Measured memory_bytes: 7920
n, k = gets.split.map(&:to_i)
all_hands = ["r", "s", "p"]
score = Hash[all_hands.zip(gets.split.map(&:to_i))]
seq = gets.chomp
win = { "r" => "p", "s" => "r", "p" => "s" }

log = []
earned = 0
seq.chars.each.with_index do |h, i|
  w = win[h]
  if i - k < 0 || log[i - k] != w
    earned += score[w]
    log << w
  else
    if i + k <= n - 1 && h != win[seq[i + k]]
      log << h
    else
      log << (all_hands - [w, h]).first
    end
  end
end

puts earned


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

using namespace std;

int main(){
   int a;
   string s , ns;
   cin >> a >> s;
   ns = s;
   for(int i = 0 ; i < s.size() ; i++){
   	   int p = int(s[i]);
   	   p += a;
   	   if(p > 90) p = p - 26;
	   char o = p; 	   
   	   ns[i] = o;
   }
   cout << ns;
}
	

Measured memory_bytes: 256
import java.util.*;
public class Main{
  	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
        int res = -1;
        if(sc.hasNext()){
        	int n = sc.nextInt();
            res = (1999 - n)/200 + 1;
            System.out.println(res);
        }                
    }
}

Measured memory_bytes: 35620
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;
LL MOD = 1000000007;


LL dp[50][(1<<19)];
LL nx[(1<<19)][12];

int main() {
	int N,X,Y,Z;
	cin >> N >> X >> Y >> Z;
	Y += X;
	Z += Y;
	for(int i=0; i<=N; i++)
		for(int j=0; j<(1<<19); j++)
			dp[i][j] = 0;
	
	for(int i=0; i<(1<<19); i++)
		for(int j=0; j<11; j++)
		nx[i][j] = -1;
	
	dp[0][0] = 1;
	
	
	for(int z=0; z<N; z++) {
//	cout << "====" << endl;
		for(int i=0; i<(1<<(Z+1)); i++) {
//			cout << i << endl;
			for(int j=1; j<=10; j++) {
				int bit = i;
				int next = 0;
				int pos = 0;
				if(j<=X) next += (1<<j);
				if(nx[i][j]==-1) {
				for(;bit!=0; bit/=2, pos++) {
					if(bit%2==1) {
						if(pos<X && pos+j>X) continue;
						if(pos<Y && pos+j>Y) continue;
						if(pos<Z && pos+j>Z) continue;
						if(pos>=Z) continue;
						next += (1<<(pos+j));
					}
					
				}
				if((i&(1<<Z)) !=0) next |= (1<<Z);
/*				if(dp[z][i] != 0) {
					cout << i << " " << next << " " << dp[z][i] << endl;
				}*/
				nx[i][j] = next;
				}
				else next = nx[i][j];
				dp[z+1][next] += dp[z][i] ;
				dp[z+1][next] %= MOD;
			}
		}
	}
	LL ans = 0;
	for(int i=(1<<Z); i<(1<<19); i++)
		ans += dp[N][i];
	ans %= MOD;
	cout << ans << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 217344
let () = 
    let rec f _ = 
        let (h, w) = Scanf.sscanf(read_line()) "%d %d" (fun x y -> (x, y)) in
        if h = 0 && w = 0 then ()
        else (
            let row = String.make w '#' in
            for _ = 1 to h do Printf.printf "%s\n" row; done;
            print_newline ();
            f ()
        )
    in f ();;


Measured memory_bytes: 2348
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[50]= {0};
    int cnt=1,now=0;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];

    }
    now=arr[0];
    for(int i=1; i<n; i++)
    {
        if(arr[i]>=now)
        {
            now=arr[i];
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'


#define point complex<ll>
vector<point> hull,vecs;
ll dot(point a,point b)
{
    return (conj(a)*b).real();
}
ll cross(point a,point b)
{
    return (conj(a)*b).imag();
}
bool comparion(point a,point b)
{
	return cross(a,b)>0;
}
void add_line(ll k,ll b)
{
    point nw={k,b};
    while(!vecs.empty()&&dot(vecs.back(),nw-hull.back())<0)
    {
        hull.pop_back();
        vecs.pop_back();
    }
    if(!hull.empty())
    {
    	point im={0,1};
        vecs.push_back(im*(nw-hull.back()));
    }
    hull.push_back(nw);
}
ll get(ll x)
{
    point query={x,1};
    auto it=lower_bound(vecs.begin(),vecs.end(),query,comparion);
    return dot(query,hull[it-vecs.begin()]);
}
int main()
{
	FAST
	#ifdef ayk_16
	    time_taken_start
		freopen("input.txt","rt",stdin);
		freopen("output.txt","wt",stdout);
	#endif
	ll n,c;
	cin>>n>>c;
	ll x,y;
	cin>>x;
	y=x*x;
	add_line(2*x,y);
	for(ll i=2;i<n;i++)
	{
		cin>>x;
		y=get(-x);
		y+=c;
		y+=(2*x*x);
		add_line(2*x,y);
	}
	cin>>x;
	cout<<(get(-x)+c+(x*x));
}

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

b = [0]
b.extend(a)
array = [0 for _ in range(n+1)]
result = []

for i in range(n, 0, -1):
    num = 1
    counter = 0
    while i*num <= n:
        if array[i*num] == 1:
            counter += 1

        num += 1

    if counter % 2 != b[i]:
        array[i] = 1
        result.append(i)

print(len(result))
for i in result:
    print(i, end=' ')


Measured memory_bytes: 13440
import java.util.*;class Main{public static void main(String[]r){Scanner c=new Scanner(System.in);int i,n=c.nextInt(),m=c.nextInt(),x=c.nextInt(),w=999999,q=w;int[]a=new int[n],b=new int[m];for(i=0;i<n;i++)w=(w<(a[i]=c.nextInt()))?w:a[i];for(i=0;i<m;i++)q=(q<(b[i]=c.nextInt()))?q:b[i];n=q+w;for(i=0;i<x;i++)n=(n<(q=a[c.nextInt()-1]+b[c.nextInt()-1]-c.nextInt()))?n:q;System.out.print(n);}}

Measured memory_bytes: 148604
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
#define MAXN 70
#define int long long
// #define fo(i,a,b) for(i=a;i<=b;i++)
// #define fd(i,a,b) for(i=a;i>=b;i--)
inline int read() {
    int s = 0, w = 1; char ch = getchar();
    while(ch < '0' || ch > '9') { if(ch == '-') w = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
int bny[MAXN], A, B, ans, x, y, u, v, d, i, j, k, l, t, n, m;
signed main() {
    A = read(), B = read();
    swap(A, B);
    bny[0] = 1;
    for(i = 1; i < 0x3f; i++)
        bny[i] = (bny[i - 1] << 1);
    for(i = 62; i >= 0; i--) {
        if((A & bny[i]) != (B & bny[i])) break ;
        if((A & bny[i]) > 0)
            A ^= bny[i], B ^= bny[i];
    }
    if(A == B) { puts("1"); return 0;}
    d = i;
    for(k = i - 1; k >= -1; k--)
        if(!(k + 1) || (A & bny[k]) > 0)
            break ;
    x = B, y = bny[d] + bny[k + 1] - 1,
    u = bny[d] + B, v = bny[d + 1] - 1,
    ans = y - x + 1;
    if(u > y) ans += (v - u + 1);
    else if(u <= y && v > y) ans += v - y;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 2e5 + 20 ;
int n , a[N] , k ;
ll p[N] ;
vector <ll> v ;

ll ans ;
int fen[N] ;

inline void add (int p) {
	for (p ++ ; p < N ; p += p & -p) fen[p] ++ ;
}

inline int get (int p) {
	int ans = 0 ;
	for (; p ; p -= p & -p) ans += fen[p] ;
	return ans ;
}

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

	cin >> n >> k ;

	for (int i = 0 ; i < n ; i ++) cin >> a[i] , a[i] -= k , p[i + 1] = p[i] + a[i] ;

	for (int i = 0 ; i <= n ; i ++) v.push_back(p[i]) ;

	sort(v.begin() , v.end()) ;
	v.resize( unique(v.begin() , v.end()) - v.begin() ) ;

	for (int i = 0 ; i <= n ; i ++) {
		int x = lower_bound(v.begin() , v.end() , p[i]) - v.begin() ;
		ans += get(x + 1) ;
		add(x) ;
	}

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


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

int p[10][10];
int d[5] = {0, 1, 0, -1, 0};
int h, w, c;

int dfs(int cnt) {
    if (cnt == 5) {
        if (p[0][0] != c) return 0;
        int ret = 1;
        int vis[10][10] = {};
        queue<int> qi;
        queue<int> qj;
        qi.push(0);
        qj.push(0);
        vis[0][0] = 1;
        while (!qi.empty()) {
            int pi = qi.front(), pj = qj.front();
            qi.pop();
            qj.pop();
            for (int i = 0; i < 4; ++i) {
                int ti = pi + d[i], tj = pj + d[i + 1];
                if (ti >= 0 && ti < h && tj >= 0 && tj < w && !vis[ti][tj] && p[ti][tj] == c) {
                    ++ret;
                    vis[ti][tj] = 1;
                    qi.push(ti);
                    qj.push(tj);
                }
            }
        }
        return ret;
    }
    int ret = -1;
    for (int col = 1; col <= 6; ++col) {
        int prev = p[0][0];
        if (prev == col) continue;
        int temp[10][10];
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                temp[i][j] = p[i][j];
            }
        }
        queue<int> qi;
        queue<int> qj;
        qi.push(0);
        qj.push(0);
        p[0][0] = col;
        while (!qi.empty()) {
            int pi = qi.front(), pj = qj.front();
            qi.pop();
            qj.pop();
            for (int i = 0; i < 4; ++i) {
                int ti = pi + d[i], tj = pj + d[i + 1];
                if (ti >= 0 && ti < h && tj >= 0 && tj < w && p[ti][tj] == prev) {
                    p[ti][tj] = col;
                    qi.push(ti);
                    qj.push(tj);
                }
            }
        }
        ret = max(ret, dfs(cnt + 1));
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                p[i][j] = temp[i][j];
            }
        }
    }
    return ret;
}


int main() {
    while (1) {
        cin >> h >> w >> c;
        if (!h) return 0;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> p[i][j];
            }
        }
        cout << dfs(0) << "\n";
    }
}

Measured memory_bytes: 3084
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		List<Integer> numbers = Arrays.asList(a, b, c);
		Collections.sort(numbers);
		String output = numbers.stream().map(s -> s.toString()).collect(Collectors.joining(" "));
		System.out.println(output);
	}
}


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

int main(){
	int n;
	cin >> n;
	n %= 10;
	if(n == 3) cout << "bon" << endl;
	else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
	else cout << "hon" << endl;
}


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

#define ll long long
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)

//library----------------------------------------------


int main(){
  int a,b,t; cin>>a>>b>>t;
  int x = t/a;
  printf("%d\n",x*b);
  return 0;
}

Measured memory_bytes: 256
# ===================================
# (c) MidAndFeed aka ASilentVoice
# ===================================
# import math 
# import collections
# import string
# ===================================
n = int(input())
q = [int(x) for x in input().split()]
ans = [None for _ in range(n)]
ans[0] = 0

for i in range(1, n):
	t1 = t2 = int(1e9)
	if i-1 >= 0: t1 = ans[i-1] + abs(q[i-1] - q[i])
	if i-2 >= 0: t2 = ans[i-2] + abs(q[i-2] - q[i])
	ans[i] = min(t1, t2)

print(ans[n-1])


Measured memory_bytes: 13924
import itertools
n,m,x=list(map(int,input().split()))
ans=10**18
A=[list(map(int,input().split())) for i in range(n)]
for i, _ in enumerate(A,1):
  for j in itertools.combinations(A,r=i):
    B=list(zip(*j))
    
    C=[0]*(m+1)
    for m in range(m+1):
      C[m]=sum(B[m])
    if len([i for i in C[1:] if i>=x ])==m:
      ans=min(ans,C[0])
print(ans) if ans!=10**18 else print(-1)

Measured memory_bytes: 9204
<?php
// From https://qiita.com/yoshikyoto/items/6924478283dbdd549e4b
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}


list($H,$N) = sscanf(trim(fgets(STDIN)),"%d %d");
$sc = new Scanner();
for($i=0;$i<$N;$i++){
    $n = $sc->nextInt();
    $H -= $n;
    if($H <= 0){
        printf("Yes");
        exit;
    }
}
printf("No");

Measured memory_bytes: 21668
# coding: utf-8
# Your code here!

N = int(input())

S = input()

ans = 1
tmp = 0
cnt = [0]*26
for s in S:
    cnt[ord(s)-ord('a')] += 1
    
for c in cnt:
    if c != 0:
        ans *= (c+1)
        ans %= 10**9+7
    
        
print(ans-1)
    

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

	public static void main(String[] args) {
      	Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		if ( s.length()<=k ) {
			System.out.println(s);
		} else {
			for ( int i=0 ;i<k-1 ; i++ ) {
				System.out.print(s.charAt(i));
			}
			System.out.println(s.charAt(k-1)+ "..." );
		}
	}

}


Measured memory_bytes: 38580
from math import sqrt
from fractions import gcd

A, B = map(int, input().split())

ans = 1

g = gcd(A, B)

for i in range(2, 1 + int(sqrt(g))):

    if g % i == 0:
        ans += 1

        while g % i == 0:
            g //= i

if g != 1:
    ans += 1

print(ans)


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

int main(void){
    
    int N;
    cin >> N;
    
    int ans = 0;
    for(int i = 1; i <= N; i++){
        string S = to_string(i);
        int size = S.size();
        if(size % 2 == 1) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    class UnionFind(private var num: Int) {
        private val parent: IntArray = IntArray(num)
        private val rank: IntArray = IntArray(num)
        private val size: IntArray = IntArray(num)

        init {
            for (i in 0 until num) {
                parent[i] = i
                rank[i] = 1
                size[i] = 1
            }
        }

        fun union(u: Int, v: Int): Int {
            var u = u
            var v = v
            u = root(u)
            v = root(v)
            if (u == v)
                return u
            if (rank[v] < rank[u]) {
                val t = v
                v = u
                u = t
            }
            parent[u] = v
            rank[v] += rank[u]
            rank[u] = -1
            num--

            return v
        }

        fun root(u: Int): Int {
            var u = u
            while (parent[u] != u)
                u = parent[u]
            return u
        }
    }

    val (n, k, l) = readLine()!!.split(' ').map(String::toInt)
    val pqList = (1..k).map {
        val (p, q) = readLine()!!.split(' ').map(String::toInt)
        Pair(p, q)
    }
    val rsList = (1..l).map {
        val (r, s) = readLine()!!.split(' ').map(String::toInt)
        Pair(r, s)
    }

    val pqUnion = UnionFind(n+1)
    val rsUnion = UnionFind(n+1)
    pqList.forEach {
        pqUnion.union(it.first, it.second)
    }
    rsList.forEach {
        rsUnion.union(it.first, it.second)
    }

    val routeList = IntArray(n + 1) { pqUnion.root(it) }
    val trainList = IntArray(n + 1) { rsUnion.root(it) }

    val ps = mutableMapOf<Pair<Int, Int>, Int>()
    for (i in 1..n) {
        val p = Pair(routeList[i], trainList[i])
        if (ps.containsKey(p)) {
            ps[p] = ps[p]!! + 1
        } else {
            ps[p] = 1
        }
    }
    for (i in 1..n) {
        val p = Pair(routeList[i], trainList[i])
        print(ps[p]!!.toString() + " ")
    }
    println()
}

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


using LL = long long int;
using uLL = unsigned long long int;
using uint = unsigned int;
using ld = long double;

const int N = 100007;
const int MAXN = (1<<18);

LL dp[2*N], tree[2*MAXN+7];
int A[2*N], h[2*N];

void add(int a, LL val){
    a += MAXN;
    tree[a] = val;
    a >>= 1;
    while(a > 0){
        tree[a] = max(tree[(a<<1)], tree[(a<<1)+1]);
        a >>= 1;
    }
}
LL query(int a, int b){
    a += MAXN;
    b += MAXN;
    LL res = 0;
    while(a <= b){
        if((a&1) == 1) res = max(res, tree[a]);
        if((b&1) == 0) res = max(res, tree[b]);
        a = ((a+1)>>1);
        b = ((b-1)>>1);
    }
    return res;
}

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }
    for(int i = 1; i <= n; i++){
        dp[i] = query(1, h[i])+A[i];
        add(h[i], dp[i]);
    }
    cout << query(1, MAXN-1) << '\n';
    
    
    return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
const int inf = 1e9; //1(1倍)e(指数)9(10^9)
int main()
{
    int n, t, a;
    scanf("%d%d%d", &n, &t, &a);
    int d = inf;
    int ans = 0;
    rep(i, n)
    {
        int h;
        scanf("%d", &h);
        int temp = abs((t * 1000 - h * 6) - a * 1000);
        if (temp < d)
        {
            d = temp;
            ans = i + 1;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define pb push_back
#define powerof2 ()
#define mp make_pair
using ll = long long;
const ll M = 1000000007;
const ll M1= 998244353;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

std::vector<ll> a(200005,0LL),b(200005,0LL),c(200005);

void solve(){
    ll n,k;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>k;
        a[k]++;
        c[i] = k;
    }
    ll s=0;
    for(int i=1;i<=n;i++){
        b[i] = (a[i]*(a[i]-1))/2;
        s+=b[i];
    }
    //cout<<s;
    for(int i=1;i<=n;i++){
        k = ((a[c[i]]-2)*(a[c[i]]-1))/2;
        if(b[c[i]]==0){
            k = 0;
        }
        cout<<s-b[c[i]]+k<<"\n";
    }
}
int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    
    solve();
    return 0;
}

/*
2
2
3
2
3

*/


Measured memory_bytes: 7296
def dfs(al,bl,cl):
    if(len(al) == 0):
        return True
    else:
        if(al[0] > bl[-1]):
            b = dfs(al[1:], bl+al[0:1], cl)
            if(b):
                return True
        if(al[0] > cl[-1]):
            b = dfs(al[1:], bl, cl+al[0:1])
            if(b):
                return True
        return False

for i in xrange(int(raw_input())):
    if(dfs([int(j) for j in raw_input().split()],[-1],[-1])):
        print 'YES'
    else:
        print 'NO'

Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=200000+100;

ll n,m,q,t[maxn<<2],x,y,z;
/*
ll low(ll x){
	return x&(-x);
}
ll query(ll x){
	ll res=0;
	for(;x>0;x-=low(x))res+=t[x];
	return res;
}
void updata(ll x,ll k){
	for(;x<=n;x+=low(x))t[x]+=k;
}*/

int main(){
	scanf("%lld%lld%lld",&n,&m,&q);
	memset(t,0,sizeof(t));
	for(int i=0;i<q;i++){
		scanf("%lld",&x);
		t[x]++;
	}
	for(int i=1;i<=n;i++){
		int k=t[i]+m-q;
		if(k<=0)printf("No\n");
		else printf("Yes\n");
	}
}

Measured memory_bytes: 6912
N, M, Q = map(int, input().split())
rail = []
for i in range(M):
    r = list(map(int, input().split()))
    rail.append(r)

query = []
for i in range(Q):
    q = list(map(int, input().split()))
    query.append(q)

f = [[0 for i in range(N)] for j in range(N)]
g = [[0 for i in range(N)] for j in range(N)]

for i in range(M):
    f[rail[i][0]-1][rail[i][1]-1] += 1

for i in range(N):
    j = 0
    while j + i < N:
        if i == 0:
            g[j][j+i] = f[j][j+i]
        else:
            g[j][j+i] = f[j][j+i] + g[j+1][j+i] + g[j][j+i-1] - g[j+1][j+i-1]
        j += 1

for i in range(Q):
    print(g[query[i][0]-1][query[i][1]-1])

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    int ans = 1;
    for (int i = 2; i*i <= X; ++i) {
        int j = i*i;
        while (j <= X) j *= i;
        j /= i;
        if (j == i) continue;
        chmax(ans, j);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B;
    cin >> A >> B;
    cout << (B + A - 3) / (A - 1) << endl;
    return 0;
}

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

int main(void)
{
    int a1, b1, a2, b2, a3, b3;
    cin >> a1;
    cin >> b1;
    cin >> a2;
    cin >> b2;
    cin >> a3;
    cin >> b3;

    int node_list[] = {a1, b1, a2, b2, a3, b3};
    int num_list[] = {0, 0, 0, 0};
    int flg = 0;

    for (int i = 0; i < 6; ++i)
    {
        num_list[node_list[i]-1]++;
    }

    for (int i = 0; i < 4; ++i)
    {
        if(num_list[i] > 2 || num_list[i] == 0)
            flg = 1;
    }

    if(flg)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=200200,INF=1000010000;
int n,L,R,t,a[N];
struct ele{
	int l,r,w;
	ele(int _l=0,int _r=0,int _w=0){l=_l,r=_r,w=_w;}
}s[N];
bool chk(int S){
	int x=0,t=0,w,y;
	FOR(i,1,n){
		if(a[i]>x){s[++t]=ele(x+1,a[i]);x=a[i];continue;}
		x=a[i];
		while(s[t].l>x) t--;
		s[t].r=x;y=x+1;
		while(t && s[t].w==S-1) y=s[t--].l;
		if(!t) return 0;w=s[t].w;
		s[t].l<s[t].r?s[t].r--:t--;
		s[++t]=ele(y-1,y-1,w+1);
		if(y<=x) s[++t]=ele(y,x,0);
	}
	return 1;
}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOR(i,1,n) scanf("%d",&a[i]);
	L=1;R=INF;
	while(L<R){
		int md=(L+R)>>1;
		chk(md)?R=md:L=md+1; 
	}
	cout<<L<<"\n";
}

Measured memory_bytes: 3328
#include <iostream>

int main()
{
	int n;
	std::cin >> n;
	
	int min = 56562;
	int a;
	int j;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		for (j = 0; a % 2 == 0; j++) a /= 2;
		if (min > j) min = j;
	}
	
	std::cout << min << std::endl;
	
	return 0;
}


Measured memory_bytes: 3160
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
using namespace std;

#define FOR_ALL_CIN(xs) for (auto& x : (xs)) cin >> x

int main()
{
	cout << fixed << setprecision(6);
	int n, l;
	cin >> n >> l;

	int taste = n * (n - 1) / 2 + l * n;
	int eatTaste = (l <= -n ? l + n - 1 : (l > 0 ? l : 0));
	cout << taste - eatTaste << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <vector>


int main(void){
	int N, res = 0;
	std::vector<bool> dp(1000001, false);
	std::cin >> N;
	std::vector<int> A(N, 0);
	for(int i = 0; i < N; i++){
		std::cin >> A[i];
		dp[A[i]] = true;
	}
	std::sort(A.begin(), A.end());
	
	for(int i = 0; i < N; i++){
		if(!dp[A[i]]) continue;
		else if((i < N-1 && A[i] == A[i+1]))
			dp[A[i]] = false;
		for(int j = 2*A[i]; j <= A[N-1]; j += A[i]){
			dp[j] = false;
		}
		
		if(dp[A[i]]) res++;
	}
	std::cout << res << std::endl;
	return 0;
}



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

int main(){

    int n;
    cin >> n;
    set<string> v;
    set<string>::iterator p;

    for(int i=0; i<n; i++){
        bool flag = false;
        string command, str;
        cin >> command;
        if(command=="insert"){
            cin >> str;
            v.insert(str);
        }else if(command=="find"){
            cin >> str;
            p = v.find(str);
            if(p != v.end()) cout << "yes" << endl;
            else cout << "no" << endl; 
        }
    }
    return 0;
}


Measured memory_bytes: 32164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    string ans = "Yes";
    for (int i = n - 1; i > 0; i--) {
        if (h[i - 1] - h[i] > 1) {
            ans = "No";
            break;
        } else if (h[i - 1] - h[i] == 1) {
            h[i - 1]--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

bool is_prime(ll x)
{
  if (x<2) return false;
  else if (x==2) return true;
  else if (x%2 == 0) return false;

  double s = sqrt(x);
  for (ll i = 2; i <= s; i++)
  { 
    if(x%i==0) return false;
  }
  return true;
}

int main()
{
  ll x;
  cin >> x;
  
  if (x==2){
    cout << 2 << endl;
    return 0;
  }

  ll y = x/2;
  y = 2*y + 1;



  while(!is_prime(y)) y++;

  cout << y << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX1 10000
#define MAX2 500
int a[MAX1];
int linearSearch(int,int);

int main()
{
  int n,q,i,b[MAX2],x,count=0;
 
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&b[i]);
    }

  for(i=0;i<q;i++)
    {
      x=linearSearch(b[i],n);
      if(x==1) count=count+1;   
    }
 
 printf("%d\n",count);  
  return 0;
}


int linearSearch(int key,int n)
{
  int i; 
  i=0;
  a[n]=key;
  while(a[i]!=key)
    {
      i++;
      if(i==n)
	{
	  return 0;
	}
    }
  if(i!=n) return 1;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int N;
	long long A, B;
	cin >> N >> A >> B;
	vector<long long> X( N );
	for( int i = 0; i < N; i++ ) {
		cin >> X[i];
	}


	long long ans = (N - 1) * B;
	for( int i = 0; i < N - 1; i++ ) {
		long long d = (X[i + 1] - X[i]) * A;
		if( d < B ) ans += d - B;
	}

	cout << ans << endl;
}


Measured memory_bytes: 4020
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc=new Scanner(System.in)){
            int w=sc.nextInt();
            int n=sc.nextInt();
            int[] values=new int[w];
            for(int i=0;i<values.length;i++){
                values[i]=i+1;
            }
            for(int i=0;i<n;i++){
                String str=sc.next();
                String[]ab=str.split(",");
                int a =Integer.parseInt(ab[0])-1;
                int b =Integer.parseInt(ab[1])-1;
                int c =values[a];
                values[a]=values[b];
                values[b]=c;
            }
            for(int i=0;i<values.length;i++){
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 26292
#include <stdio.h>


int main(void){
    int datas;
    int x,y,h,w,size;
    int fee;
    
    while (scanf("%d", &datas)){
        if (datas==0) break;
        fee=0;
        for (int i=0; i<datas; i++){
            scanf("%d %d %d %d", &x, &y, &h, &w);
            size = x+y+h;
            if (size<=60 && w<= 2) fee+= 600;
            else if (size<=80 && w<= 5) fee+= 800;
            else if (size<=100 && w<= 10) fee+= 1000;
            else if (size<=120 && w<= 15) fee+= 1200;
            else if (size<=140 && w<= 20) fee+= 1400;
            else if (size<=160 && w<= 25) fee+= 1600;
        }
        printf("%d\n", fee);
    }
    return 0;
}

Measured memory_bytes: 1028
#include<iostream>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(((a*100 + b*10 + c) % 4) == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/*
题意：给定N个D维坐标。求最远曼哈顿距离。
解法：对于两个二维坐标A(xi,yi),B(xj,yj).其曼哈顿距离可能为以下四种情况：
(xi-xj)+(yi-yj), (xj-xi)+(yi-yj), (xi-xj)+(yj-yi), (xj-xi)+(yj-yi)
将坐标参数按点来分配之后变形如下：
(xi+yi)-(xj+yj), (-xi+yi)-(-xj+yj), (xi-yi)-(xj-yj), (-xi-yi)-(-xj-yj)
易得每项两个点的参数前的正负符号是一样的。这规律在D维下易证通用。
我们且称如上的（xi+yi）等为点A的“11”状态下的本点有效距离。
由此， 每个坐标参数的正负状态下的最长有效距离减去最短有效距离 即是当前
正负状态下的最远曼哈顿距离。再枚举每个状态，取每个状态的最远曼哈顿距离
的最大值即为答案。
*/


#include <bits/stdc++.h>
using namespace std;
#define INF 9999999999999
#define D 2//空间维数
#define M 200005//坐标个数
#define int long long
struct Point
{
    int x[D];
}pt[M];
int dis[1<<D][M],minx[1<<D],maxx[1<<D];

//去掉绝对值后有2^D种可能
void Get(int N)//取得所有点在指定状态（S）下的“本点有效距离”
{
    int tot=(1<<D);
    for(int s=0;s<tot;s++)//遍历所有维数正负状态
    {
        int coe[D];
        for(int i=0;i<D;i++)//设定当前状态的具体正负参数
        if(s&(1<<i)) coe[i]=-1;
        else coe[i]=1;

        for(int i=0;i<N;i++)//遍历所有点，确定每个点在当前状态下的“本点有效距离”
        {
            dis[s][i]=0;
            for(int j=0;j<D;j++)
            dis[s][i]=dis[s][i]+coe[j]*pt[i].x[j];
        }
    }
}
//取每种可能中的最大差距
void Solve(int N)
{
    int tot=(1<<D);
    int tmp,ans;
    for(int s=0;s<tot;s++)
    {
        minx[s]=INF;
        maxx[s]=-INF;
        for(int i=0;i<N;i++)
        {
            if (minx[s]>dis[s][i]) minx[s]=dis[s][i];
            if (maxx[s]<dis[s][i]) maxx[s]=dis[s][i];
        }
    }
    ans=0;
    for(int s=0;s<tot;s++)
    {
        tmp=maxx[s]-minx[s];
        if(tmp>ans) ans=tmp;
    }

    cout << ans << "\n";
}

signed main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    cin >> pt[i].x[0] >> pt[i].x[1];
    Get(n);
    Solve(n);
    return 0;
}

Measured memory_bytes: 12896
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

string s;
int n(0);

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	for (char i : s)
		n += i - '0';
	if (n % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3736
from operator import itemgetter
H,N = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]

L.sort(key=itemgetter(1))
inf = 10**9
dp = [[inf]*(H+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for j in range(H+1):
        if j < L[i][0]:
            dp[i+1][j] = min(dp[i][j], L[i][1])
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-L[i][0]]+L[i][1])
    for j in range(H, -1, -1):
        if dp[i+1][j] < inf:
            num = dp[i+1][j] + dp[i+1][H-j]
            break
    for j in range(H, -1, -1):
        if dp[i+1][j] > num:
            dp[i+1][j] = num
        else:
            num = dp[i+1][j]

print(dp[N][H])


Measured memory_bytes: 119148
#include <bits/stdc++.h>
#include <boost/foreach.hpp>

using namespace std;

int main()
{
    int n, l;
    string s;
    cin >> n >> l;

    vector<string> lst;
    for (int i = 0; i < n; i++){
        cin >> s;
        lst.push_back(s);
    }

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

    string cat = "";
    BOOST_FOREACH (string ss, lst)
    {
        cat += ss;
    }
    cout << cat << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[101];
int i,j,k,n,m,x,y,t;
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	for (i=1;i<=n;i++)x=x*10+s[i]-48,t+=s[i]-48;
	printf("%s\n",x%t==0?"Yes":"No");
}


Measured memory_bytes: 256
N = int(input())
List = [0 for _ in range(N)]
for i in range(N):
  List[i] = int(input())
Res = sorted(List)
ans = sum(Res)
if ans % 10 == 0:
  for j in range(N):
    if Res[j] % 10 != 0:
      ans -= Res[j]
      print(ans)
      break
  else:
    print(0)
else:
  print(ans)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  ll n, k;
  cin >> n >> k;
  vector<pii> p(n);
  rep(i,n) cin >> p[i].fi >> p[i].se;

  sort(p.begin(), p.end());
  ll x = 0;
  ll ans;
  rep(i,n) {
    x += p[i].se;
    if (k <= x) {
      ans = p[i].fi;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
a, b, c = map(int, input().split())
l = [a ,b, c]
l.sort()
ans = []
p = l.pop()
ans.append(abs(p-l[0]) + abs(l[0]-l[1]))
ans.append(abs(p-l[1]) + abs(l[1]-l[0]))
print(min(ans))

Measured memory_bytes: 3064
from string import ascii_lowercase

# a-zまで試す
s = input()
maxN = len(s)
for ch in ascii_lowercase:
    ss = list(s)
    count = 0

    if len(set(s)) == 1:
        count = 0
    else:
        while True:
            count += 1
            new_ss = []
            for j in range(len(ss) - 1):
                if ss[j] == ch or ss[j + 1] == ch:
                    new_ss.append(ch)
                else:
                    new_ss.append(ss[j])
            # print(new_ss)
            ss = new_ss
            if len(set(new_ss)) == 1:
                break
    maxN = min(maxN, count)
print(maxN)

Measured memory_bytes: 40304
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	ll N;
	cin >> N;
	string ans = "";
	while(N > 0) {
		-- N;
		ans = char((N%26) + 'a') + ans;
		N /= 26;
	}
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = scanner.nextInt();
        }

        long sum = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                sum += array[i] * array[j];
            }
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>

using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
  ll n;
  cin>>n;
  vector<pair<ll,ll>> z(n);
  vector<pair<pair<ll,ll>,ll>> cnt;
  rep(i,n){
    cin>>z[i].FI>>z[i].SE;

  }
  sort(all(z));
  rep(i,n-1){
    repf(j,i+1,n){
      bool fla=false;
      rep(k,(ll)cnt.size()){
        if(cnt[k].FI.FI==(z[j].FI-z[i].FI)&&cnt[k].FI.SE==(z[j].SE-z[i].SE)){
          cnt[k].SE++;
          fla = true;
          break;
        }
      }
      if(!fla){
    
       // cout<<1<<endl;
        cnt.push_back(make_pair(make_pair(z[j].FI-z[i].FI,z[j].SE-z[i].SE),1));
      
      }
    }
  }
  ll Max=0;
  rep(i,(ll)cnt.size()){
    Max=max(Max,cnt[i].SE);
    //cout<<cnt[i].FI.FI<<" "<<cnt[i].FI.SE<<" "<<cnt[i].SE<<endl;
  }
  op(n-Max);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

//Unweighted graph (adjacency matrix)
//Initialize : vector<vector<int>>(N, vector<int>(N, 0))
template <typename T>
using UnweightedGraph = vector<vector<T>>;

//distance matrix
template <typename T>
using Matrix = vector<vector<T>>;

template <typename T>
vector<T> dijkstra(WeightedGraph<T> &g, int s)
{
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(g.size(), INF);

    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while (que.empty() != true)
    {
        T cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if (dist[idx] < cost)
            continue;
        for (auto &e : g[idx])
        {
            auto next_cost = cost + e.cost;
            if (dist[e.to] <= next_cost)
                continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

int N, Q, K;

int main()
{
    cin >> N;
    WeightedGraph<ll> G(N);
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--, b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }
    cin >> Q >> K;
    K--;
    auto dist = dijkstra(G, K);
    for (int i = 0; i < Q; i++)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << dist[x] + dist[y] << "\n";
    }
}

Measured memory_bytes: 11120
#include<stdio.h>
int main(){
	int N,i,j,a=0,b=0;
	scanf("%d",&N);
	int d[100];
	for(i=0;i<N;i++){
		scanf("%d",&d[i]);
	}
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j++){
			if(d[i]<d[j]){
				a=d[i];
				d[i]=d[j];
				d[j]=a;
			}
		}
	}
	for(i=0;i<N;i++){
		if(d[i]!=d[i+1]){
			b++;
		}
	}
	printf("%d",b);
	return 0;
}

Measured memory_bytes: 128
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}

#[allow(dead_code)]
fn lcm(a: i64, b: i64) -> i64 {
    a / gcd(a, b) * b
}

fn calc(a: i64, b: i64) -> i64 {
    a / b
}

fn main() {
    let a = read::<i64>();
    let b = read::<i64>();
    let c = read::<i64>();
    let d = read::<i64>();
    let e = lcm(c, d);
    let mut ans = b - a + 1;
    ans -= calc(b, c);
    ans += calc(a - 1, c);
    ans -= calc(b, d);
    ans += calc(a - 1, d);
    ans += calc(b, e);
    ans -= calc(a - 1, e);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define mii map<int,int>
#define MOD 1000000007
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,k;
cin>>n>>k;
int p[n];
for(int i=0;i<n;i++)
cin>>p[i];
sort(p,p+n);
int sum=0;
for(int i=0;i<k;i++)
sum+=p[i];
cout<<sum<<endl;

return 0;
}
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
    int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    if (m <= 4) {
        cout << "Heisei" << endl;
    } else if (5 <= m) {
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a(100), b(100), c(100), d(100);
  for(int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  queue<ll> que;
  for(int i = 0; i < m; i++) {
    que.push(i);
  }
  ll limit = 0;
  for(int i = 0; i < n; i++) {
    limit += (m - 1) * pow(10, i);
  }
  
  for(int i = 0; i <= 99999; i++) {
    bool ok = false;
    ll tmp = que.front();
    ll in = tmp;
    for(int j = in % 10; j < m; j++) {
      que.push(in * 10 + j);
      if(in * 10 + j >= limit){
        ok = true;
        break;
      }
    }
    if(ok){
      break;
    }
    que.pop();
  }

  ll ans = 0;
  while(!que.empty()) {
    ll sum = 0;
    ll tmp = que.front();
    que.pop();
    vector<ll> e(100, 0);
    bool ok = true;
    for(int i = n - 1; i >= 0; i--) {
      e[i] = tmp % 10;
      tmp /= 10;
    }
    if(ok == false) {
      continue;
    }
    for(int i = 0; i < q; i++) {
      if(e[b[i]] - e[a[i]] == c[i]) {
        sum += d[i];
      }
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4804
#Make a Rectangle
N = int(input())
A = list(map(int, input().split()))

a = sorted(A, reverse=True)
b = []

i = 0
while i<N-1:
    if ( a[i]==a[i+1] ):
        b+=[a[i]]
        i+=2
    else:
        i+=1
    if (len(b)>1):
        break

if (len(b)<2):
    print(0)
else:
    print(b[0]*b[1])

Measured memory_bytes: 14224