akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  bool ok = false;

  FOR(i, 1, 1e3 + 1) {
    int ax = i * 8 / 100;
    int bx = i * 10 / 100;
    if (ax == a && bx == b) {
      ans = i;
      ok = true;
      break;
    }
  }

  print(ok ? ans : -1);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int d = b/a;

    int ans = min(c, d);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	string s; ll k;
	cin >> s >> k;
	rep(i, min((ll)s.size(), k)) {
		if (s[i] != '1') {
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3632
d = gets.to_i
d.times do |i|
    n = gets.to_i
    a = Array.new(n).map { Array.new(n, 0) }
    a.map! {|r| [9] + r + [9]}
    a.unshift [9] * (n + 2)
    a<< [9] * (n + 2)
    y = n
    x = 1
    dy = -1
    dx = 0
    loop do
        a[y][x] = 1
        if a[y + dy][x + dx] == 0
            a[y + dx][x - dy] = 9
            y += dy
            x += dx
        else
            dy, dx = dx, -dy
            if a[y + dy][x + dx] == 0
                a[y - dx][x + dy] = 9
                y += dy
                x += dx
            else
                break
            end
        end
    end
    a[1..-2].each do |r|
        puts r[1..-2].map {|x| x == 1 ? '#' : ' '} * ''
    end
    puts if i < d - 1
end


Measured memory_bytes: 7364
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int distance_to_a(char c) {
  return c=='a' ? 0 : 'z' - c + 1;
}

char next_char(char c) {
  return (((c-'a')+1)%('z'-'a'+1)) + 'a';
}
char add_char(char c, int a) {
  return (((c-'a')+a)%('z'-'a'+1)) + 'a';
}

int main() {
  string s; cin >> s;
  int K; cin >> K;
  for(int i = 0; i < s.size() ; i++) {
    while(K) {
      int dis = distance_to_a(s[i]);
      if(dis <= K && dis != 0) {
        s[i] = add_char(s[i], dis);
        K-=dis;
      } else if(i+1>=s.size()) {
        s[i] = next_char(s[i]);
        K--;
      } else break;
    }
  }
  cout << s << endl;
}


Measured memory_bytes: 888
void main() {
    string[] s = readln.split;
    foreach (i; 0 .. 3) {
        s[i][0].toUpper.write;
    }
    writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.uni;

Measured memory_bytes: 256
N = int(input())

import math

ALPHABET = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(ALPHABET))
    surplus = v % len(ALPHABET)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(ALPHABET) if surplus == 0 else surplus
    result.append(surplus)
    if len(ALPHABET) < quotient:
        alphabet_decimal(quotient)
    elif len(ALPHABET) < v:
        result.append(quotient)
    return "".join([ALPHABET[i - 1] for i in reversed(result)])

print(alphabet_decimal(N))


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

int main(){
  int n,m;
  cin >> n >> m;
  int a[n],b[n],c[m],d[m];
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];
  
  rep(i,n){
    int MIN = 1001001001, cp;
    rep(j,m){
      int md = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(md < MIN){
        MIN = md;
        cp = j+1;
      }
    }
    cout << cp << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: Ivan
 *
 * Created on July 3, 2018, 11:31 AM
 */

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

/*
 * 
 */

int partition(int A[], int p, int r);

int main(int argc, char** argv) {
    int n;
    scanf("%d", &n);
    int A[n];
    for (int i = 0; i < n; i++) scanf("%d", &A[i]);
    
    int q = partition(A, 0, n-1);
    
    for (int ix = 0; ix < n; ix++)
    {
        if (ix) printf(" ");
        if (ix == q) printf("[");
        printf("%d", A[ix]);
        if (ix == q) printf("]");
    }
    
    printf("\n");
    
    return (EXIT_SUCCESS);
}

int partition(int A[], int p, int r)
{
    int temp;
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++)
    {
        if (A[j] <= x)
        {
            i++;
            temp = A[i];
            A[i] = A[j];
            A[j] = temp;
        }
    }
    temp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = temp;
    
    return i + 1;
}


Measured memory_bytes: 2248
/*
	*#*#*#* Author GaryMr *#*#*#*
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	匹配括号 左减右>=0
	多组数据清空？
	dp优化用g？
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
const int MOD=1e9+7;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
long long c[200001],n,m;
long long LAST[200001];
long long dp[200001]={0,1};
long long ans=0;
int main(){
	scanf("%I64d",&n);
	m=0;
	rb(i,1,n) {
		scanf("%I64d",&c[++m]);
		if(c[m]==c[m-1]){
			m--;
		}
	}
	rb(i,1,m){
		dp[i]+=dp[i-1]+dp[LAST[c[i]]];
		LAST[c[i]]=i;
		dp[i]%=MOD;
	}
	printf("%I64d\n",dp[m]);
	return 0;
}

Measured memory_bytes: 4992
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
import math

N = INT()
A = LIST()


if (N == 0 and A[0] != 1) or (N > 0 and A[0] != 0):
    print(-1)
    exit()


node_min, node_max = [0]*(N+1), [0]*(N+1)
node_min[-1] = A[-1]
node_max[-1] = A[-1]
for i in reversed(range(N)):
    node_min[i] = math.ceil(node_min[i+1]/2) + A[i]
    node_max[i] = node_max[i+1] + A[i]


if node_min[0] > 1:
    print(-1)
    exit()

ans = 1
node = 1
for i in range(1, N+1):
    node = min(node_max[i], 2*node)
    ans += node
    node = node - A[i]


print(ans)







Measured memory_bytes: 84620
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[n];
		int[] modified = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			modified[i] = (a[i] > x) ? x : a[i];
		}
		for(int i = 0; i < n - 1; i++) {
			if(modified[i] + modified[i + 1] > x)
				modified[i + 1] = x - modified[i];
		}
		long sum = 0;
		for(int i = 0; i < n; i++)
			sum += a[i] - modified[i];
		System.out.println(String.valueOf(sum));
	}
}

Measured memory_bytes: 46788
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		long A = Long.parseLong(line[0]);
		long B = Long.parseLong(line[1]);
		long x = Long.parseLong(line[2]);
		long count = 0;

		System.out.println((B/x-A/x)+(A%x==0?1:0));
	}
}


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

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

	string ans("");

	if (N<1000) {
		ans = "ABC";
	} else {
		ans = "ABD";
		N -= 1000;
	}
	
	cout << ans << endl;

	return 0;
}


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

int main()
{
    int n, k, ans = 0;
    cin >> n >> k;

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

    sort(p, p + n);

    for (int i = 0; i < k; i++) {
        ans += p[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

#define NO_DATA -1
#define MAX_COUNT 1000
int main(int argc, const char * argv[]) {
    // insert code here...
    int result[MAX_COUNT];
    int dataCount;
    
    for (int i = 0; i < MAX_COUNT; i++ ) {
        result[i] = NO_DATA;
    }
    
    scanf("%d", &dataCount);
    int data[3];
    for (int i=0;i<dataCount;i++) {
        scanf("%d %d %d", &data[0], &data[1], &data[2]);
        if (data[0] > data[1]) {
            int tmp=data[0];
            data[0]=data[1];
            data[1]=tmp;
        }
        if (data[1] > data[2]) {
            int tmp=data[1];
            data[1]=data[2];
            data[2]=tmp;
        }
        
        result[i]=(data[2]*data[2])==(data[1]*data[1]+data[0]*data[0])?1:0;
    }
    
    for (int i=0;i<dataCount;i++) {
        printf("%s\n", result[i]==1?"YES":"NO");
    }
    return 0;
}



Measured memory_bytes: 2048
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int MAXN = (int)1e2 + 10;
const int INF = (int) 0x3f3f3f3f;

vector<int> g[MAXN],val[MAXN];
int n;
int d[MAXN],vis[MAXN];

void Dijkstra(int s){
    for(int i=1;i<=n;i++) d[i]=INF;
    d[s]=0;
    vis[s]=1;
    for(int i=0;i<g[0].size();i++){
        int v=g[0][i];
        if(!vis[v]) d[v]=min(d[v],d[0]+val[0][i]);
    }
    int cnt=1;
    while(cnt<=n){
        int id=-1;
        for(int i=1;i<=n;i++)if(!vis[i]){
            if(id==-1||d[id]>d[i]) id=i;
        }
        vis[id]=1;
        cnt++;
        for(int i=0;i<g[id].size();i++){
            int v=g[id][i];
            if(!vis[v]) d[v]=min(d[v],d[id]+val[id][i]);
        }
    }
}

void work(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int u,k; scanf("%d%d",&u,&k);
        while(k--){
            int v,c; scanf("%d%d",&v,&c);
            g[u].push_back(v);
            val[u].push_back(c);
        }
    }
    Dijkstra(0);
    for(int i=0;i<n;i++) printf("%d %d\n",i,d[i]);
}

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

/*
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3
*/



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

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

    long long ans = 0;
    vector<long long> nums(100010, 0);

    long long k;
    for(long long i = 0; i < n; i++){
        cin >> k;
        nums[k]++;
        ans += k;
    }


    long long q;
    cin >> q;
    long long b, c;

    for(long long i = 0; i < q; i++){
        cin >> b >> c;
        ans -= nums[b] * (b - c);
        cout << ans << endl;
        nums[c] += nums[b];
        nums[b] = 0;
    }

}

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

int main() {

	int n;
	cin >> n;
	int arr[n];
	
	for (int i=0; i<n; i++) cin >> arr[i];
	
	multiset<int> ends;
	
	for (int i=0; i<n; i++) {
		// can current be added to existing, or should new be made?
		int curr = arr[i];
		multiset<int>::iterator fd = ends.lower_bound(curr);
		if (fd == ends.begin()) {
			ends.insert(curr);
		}
		else {
			--fd;
			ends.erase(fd);
			ends.insert(curr);
		}
	}
	
	cout << ends.size() << endl;
	
	

}


Measured memory_bytes: 5376
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <string>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;

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

int main()
{
  int N,count=0,num,max=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> num;
    if(num >= max){
      max = num;
      count++;
    }
  }
  cout << count;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;


int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	map<int, int>m;
	int num[100001] = {};
	for (int i = 0; i < N; i++) {
		cin >> num[i];
		m[num[i]] = i;
	}
	sort(num, num + N);
	for (int i = 0; i < N; i++) {
		ans += abs(i - m[num[i]]) % 2;
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

long long max(long long A,long long B){
    return A>B?A:B;
}

long long min(long long A,long long B){
    return A<B?A:B;
}

long long roundup(long long A,long long B){
    return (A+B-1)/B;
}

int main(void){
    long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    printf("%lld\n",min(a*n,b));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef _GLIBCXX_DEBUG
int c_;
#define dbg(...) {if(!c_)cerr<<"\033[96;1m";++c_; \
__VA_ARGS__;--c_;if(!c_)cerr<<"\033[0m";}
#else
#define dbg(...)
#endif
#define st first
#define nd second
#define flg() __LINE__, __PRETTY_FUNCTION__
#define mkp(...) make_pair(__VA_ARGS__)
#define prt(...) print(cout, __VA_ARGS__)
#define dprt(...) dbg(print(cerr, __VA_ARGS__))
#define dmp(...) dprt(#__VA_ARGS__, __VA_ARGS__)
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template< typename t > using V = vector< t >;
template< typename t > void print(ostream& os, const t& a){os<<a<<'\n';}
template< typename t, typename... v > void print(ostream& os, const t& a, 
v&&... b){os << a << ' '; print(os, b...);}

int n;
V< int > tb;

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

    cin >> n;

    for (int i = 0; i < 2 * n; ++i)
    {
        int v; cin >> v;
        tb.push_back(v);
    }

    sort(all(tb));

    int sum = 0;
    for (int i = 2 * n - 2; i >= 0; i -= 2)
        sum += tb[i];

    prt(sum);


}

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

int main() {

  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
      int count = 0;
      for (int j = i; j < S.size(); j++) {
        if(S.at(j)=='A'||S.at(j)=='C'||S.at(j)=='G'||S.at(j)=='T') 
          count++;
        else break;
      }
      ans = max(ans, count);
  }

    cout << ans << endl;

}

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

int main() {

  int N, Q;
  cin >> N >> Q;

  string S;
  cin >> S;

  vector<pair<int, int>> p(Q);

  for (int i = 0; i < Q; i++) {
    int a,b;
    cin >> a >> b;
    p[i] = make_pair(a, b);
  }
  
  vector<int> v(N+1);
  v[0] = 0;
  v[1] = 0;

  // v : 0 1 2 3 4 5 6 7 8
  //     0 0 1 1 2 2 2 3 3
  // S :  A C A C T A C G

  for (int i = 1; i <= N; i++) {
    if (S[i - 1] == 'A' && S[i] == 'C') {
      v[i + 1] = v[i] + 1;
    } else {
      v[i + 1] = v[i];
    }
  }

  for (int i = 0; i < Q; i++) {
    cout << v[p[i].second] - v[p[i].first] << endl;
  }

}

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

int main()
{
  double N;
  cin >> N;
  double sum = 0;
  long double ans = 0;
  vector<vector<double>> a(N, vector<double>(2));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 2; j++)
    {
      cin >> a[i][j];
    }
  }
  vector<int> v(N);
  iota(v.begin(), v.end(), 0);
  int num = 1;
  for (int i = 1; i <= N; i++)
    num *= i;
  vector<vector<int>> b(num);
  int l = 0;
  do
  {
    for (auto x : v)
      b[l].push_back(x);
    l++;
  } while (next_permutation(v.begin(), v.end()));
  for (int i = 0; i < b.size(); i++)
  {
    for (int j = 1; j < N; j++)
    {
      sum += sqrt(pow((a[b[i][j]][0] - a[b[i][j - 1]][0]), 2) + pow((a[b[i][j]][1] - a[b[i][j - 1]][1]), 2));
    }
  }
  ans = sum / num;
  cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int w[100008],v[108],n;
long long int dp[105][100008]={0},W;
long long int solve(int i, long long int c)
{
    long long int ans1,ans2;
    //ans1=0;ans2=0;
    if(i==n+1){return 0;}
    if(dp[i][c]!=-1)
    {return dp[i][c];}
    ans1=solve(i+1,c);
    if((c-w[i])>=0){ans2=solve(i+1,c-w[i])+v[i];}
    else{ans2=0;}
    dp[i][c]=max(ans1,ans2);
    return max(ans1,ans2);

}
int main()
{
    int i;
    //long long int a;
    cin>>n>>W;
    for(i=0;i<=101;i++)
        for(int j=0;j<=100004;j++)
            dp[i][j]=-1;
        
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        //cout<<dp[1][i];
    }
    //a=solve(1,W,N);
    cout<<solve(1,W);
}

Measured memory_bytes: 80128
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

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

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

    return 0;
}


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

vector<ll> to[10010];

int main(){
    ll H,W,bcn=0;cin>>H>>W;
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
    char c[55][55];
    rep(i,0,H)rep(j,0,W){cin>>c[i][j];if(c[i][j]=='#'){bcn++;}}
    rep(i,0,H){
        rep(j,0,W){
            if(c[i][j]=='#')continue;
            rep(k,0,4){
                ll nex=i+dx[k],ney=j+dy[k];
                if(0<=nex&&0<=ney&&H>nex&&W>ney){
                    if(c[i][j]=='.'&&c[nex][ney]=='.'){
                        to[W*i+j].push_back(W*nex+ney);
                        to[W*nex+ney].push_back(W*i+j);
                        
                    }
                }
            }
        }
    }
    vector<int> dist(H*W, -1); 
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while (!que.empty()) {
        int v = que.front(); 
        que.pop();

        for (int nv : to[v]) {
            if (dist[nv] != -1) continue; 

            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    if(dist[H*W-1]==-1){
        cout<<-1<<endl;
    }
    else{
        cout<<H*W-bcn-dist[H*W-1]-1<<endl;
    }

    
}







Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

vector<ll> trial_division(ll n)
{
    vector<ll> factorization;
    while (n % 2 == 0)
    {
        factorization.push_back(2);
        n /= 2;
    }
    for (ll d = 3; d * d <= n; d += 2)
    {
        while (n % d == 0)
        {
            factorization.push_back(d);
            n /= d;
        }
    }
    if (n > 1)
        factorization.push_back(n);
    return factorization;
}

int main()
{
    // vector<ll> v = divisors(24);
    // for (auto x:v)
    //     cout << x << " ";
    ll a,b;
    cin >> a >> b;
    vector<ll> v1 = trial_division(a);
    vector<ll> v2 = trial_division(b);
    map<ll, int> mp1;
    map<ll, int> mp2;
    map<ll, int> mp;
    for (auto x:v1)
        mp1[x]++;
    for (auto x:v2)
        mp2[x]++;
    int res = 0;
    for (auto x:mp1)
        if (mp2[x.first] != 0)
        {
            // cout << x.first << " ";
            res++;

        }
    cout << res + 1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9+7;
const ll nax = 3e3+7;
const ll INF = 1e18;

ll n,a[nax];
ll dp[nax][nax][2];

int main(){
//	freopen("input.inp","r",stdin);
//	freopen("output.out","w",stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin>>n;
	
	for (ll i=0;i<n;++i) cin>>a[i];
	
	for (ll l=n-1;l>=0;--l){
		for (ll r=l;r<n;++r){
			if (l==r){
				dp[l][r][0]=a[l];
				dp[l][r][1]=-a[l];
			}
			
			else {
				dp[l][r][0]=max(dp[l+1][r][1]+a[l],dp[l][r-1][1]+a[r]);
				dp[l][r][1]=min(dp[l+1][r][0]-a[l],dp[l][r-1][0]-a[r]);
			}
		}
	}
	
	cout<<dp[0][n-1][0]<<"\n";
}

Measured memory_bytes: 85668
#include <iostream>

using namespace std;

// naive but easy to implement
int calc(int n)
{
  int count = 0;
  for (int a = 0; a <= 9; a++) {
    for (int b = 0; b <= 9; b++) {
      for (int c = 0; c <= 9; c++) {
        for (int d = 0; d <= 9; d++) {
          if (a + b + c + d == n){
            count++;
          }
        }
      } 
    }
  }

  return count;
}

int main(int argc, char const* argv[])
{
  int n;
  while (cin >> n) {
    cout << calc(n) << endl;
  };
  return 0;
}

Measured memory_bytes: 1156
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int maxn = 100005;
int a[maxn];

bool check (int x, int n, int m, int v, int p) {
	int r = n - (p - 1);
	if (r <= x) return 1;
	v = std::max(0, v - x - (n - r));
	int h = a[x] + m;
	ll sum = 0;
	for (int i = x + 1; i <= r; i ++)
		if (a[i] > h)
			return 0;
	for (int i = x + 1; i <= r; i ++)
		sum += std::min(m, h - a[i]);
	return 1ll * m * v <= sum;
}

int main () {
	int n = read, m = read, v = read, p = read;
	for (int i = 1; i <= n; i ++) read(a[i]);
	std::sort(a + 1, a + n + 1);
	int l = 1, r = n;
	while (l < r) {
		int mid = (l + r) >> 1;
		if (check(mid, n, m, v, p)) r = mid;
		else l = mid + 1;
	}
	printf("%d\n", n - l + 1);
}


Measured memory_bytes: 512
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll m,k;
	cin>>m>>k;
	if(k>=(1<<m)||(m==1&&k==1))
	cout<<-1;
	else
	{
		if(m==1)
		cout<<"0 0 1 1";
		else
		{
		
		for(ll i=0;i<(1<<m);i++)
		if(i==k)continue;
		else
		cout<<i<<" ";
		cout<<k<<" ";
		for(ll i=(1<<m)-1;i>=0;i--)
		if(i==k)continue;
		else
		cout<<i<<" ";
		cout<<k<<" ";
	}
}
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdint.h>
//#include <unordered_map>
#include <map>

using namespace std;

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

  //unordered_map<int32_t, unsigned> modA;
  map<int32_t, unsigned> modA;
  modA[0] = 1;

  int64_t sum = 0;
  for (int64_t n=0; n<N; ++n) {
    int64_t a;
    cin >> a;
    sum += a;
    int32_t key = sum%M;
    try {
      modA.at(key)++;
    } catch (...) {
      modA[key] = 1;
    }
  }

  int64_t count = 0;
  for (auto kv : modA) {
    int32_t key = kv.first;
    unsigned value = kv.second;
    cerr << kv.first << ":" << kv.second << endl;
    if (value > 1) {
      count += static_cast<int64_t>(value) * (value-1) / 2;
    }
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 3200
N = int(input())

L = []

for i in range (0, N):
	L.append(int(input()))

counter = 0
initial = 0

for i in range (0, 2*N+1):
	initial = L[initial]-1
	counter+=1
	if initial == 1:
		print(counter)
		exit()

print(-1)

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

int main()
{
	int n;
	scanf("%d", &n);
	std::vector<std::pair<int, int>> ab(n);
	for (auto& e: ab) scanf("%d%d", &e.first, &e.second);
	std::sort(ab.begin(), ab.end(),
		[](const auto& a, const auto& b) { return a.first + a.second > b.first + b.second; }
	);
	long long sum{};
	for (int i{}; i < n; i += 2)
		sum += ab[i].first;
	for (int i{1}; i < n; i += 2)
		sum -= ab[i].second;
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := nextInts(n)
	c := 1
	for i := 0; i < n; i++ {
		if a[i] == c {
			c++
		}
	}
	if c == 1 {
		fmt.Println(-1)
	} else {
		fmt.Println(n - c + 1)
	}
}


Measured memory_bytes: 3968
import heapq
N, M = list(map(int, input().split()))
A = [-a for a in list(map(int, input().split()))]
heapq.heapify(A)

while M>0:
    max_a = heapq.heappop(A)
    heapq.heappush(A,-int(-max_a/2))
    M = M-1
print(-sum(A))

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

typedef long long ll;

using namespace std;

bool IsPrime(int x){
    if (x == 1) return false;
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0) return false;
    return true;
}

int main(){
    int x;
    cin >> x;
    while(!IsPrime(x)) x++;
    cout << x;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
DP = [0] * n
DP[0] = 0
DP[1] = abs(h[0]-h[1])
for i in range(2,n):
    DP[i] = min(DP[i-2]+abs(h[i-2]-h[i]),DP[i-1]+abs(h[i-1]-h[i]))
print(DP[-1])

Measured memory_bytes: 13928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 100000

int main(int argc,char const* argv[])
{
  string s;
  int sn,loc=0;
  cin >> s;
  sn=s.size();
  reverse(s.begin(),s.end());
  for(loc=0;loc<sn;loc++)
    {
      if(s.substr(loc,5)=="maerd")loc+=4;
      else if(s.substr(loc,5)=="esare")loc+=4;
      else if (s.substr(loc,7) == "remaerd")loc+=6;
      else if (s.substr(loc,6) == "resare")loc+=5;
      else{
	    cout << "NO" << endl;
	    return 0;
	  }
	
    }
    cout << "YES" << endl;
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int MAX = 1<<20;
LL N, M;
double num[MAX], prob[MAX];

using LLL = __int128;

LLL gcd(LLL x, LLL y){
  if(y == 0) return x;
  return gcd(y, x%y);
}
LLL lcm(LLL x, LLL y){
  return x / gcd(x, y) * y;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cin >> N >> M;
  VL xs(N);
  vector<double> ps(N);
  REP(i,N)
	cin >> xs[i];
  REP(i,N){
	cin  >> ps[i];
	ps[i] /= 100.;
  }

  FOR(b,1,1<<N){
	LLL l = 1;
	int bc = 0;
	REP(i,N){
	  if(b>>i&1){
		if(l <= M)
		  l = lcm(l, xs[i]);
		++bc;
	  }
	  num[b] = (bc%2*2-1) * M / l;
	}
  }

  for(int i=0;i<N;++i){
	for(int b=0;b<(1<<N);++b){
	  if((b>>i&1) == 1)
		num[b] += num[b^(1<<i)];
	}
  }

  double ans = 0.;
  REP(b,1<<N){
	prob[b] = 1;
	REP(i,N){
	  prob[b] *= (b>>i&1? ps[i]: 1.-ps[i]);
	}
	ans += prob[b] * num[b];
  }

  cout << fixed << setprecision(9) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 19688
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
constexpr int INF32       = 1'050'000'000;
constexpr long long INF64 = 4'000'000'000'000'000'000;
constexpr int MOD7        = 1'000'000'007;
constexpr int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

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

    int N;
    scan(N);
    vector<ll> v(N);
    scan(v);
    ll ans = 0;
    REP(i, N - 1) {
        FOR(j, i + 1, N) { ans += v[i] * v[j]; }
    }
    print(ans);

    return 0;
}

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


int main()
{
	int N, K;
	cin >> N >> K;
	int l[60];
	for (int i = 0; i < N; ++i) cin >> l[i];
	sort(l, l + N, greater<int>());
	int total = 0;
	for (int i = 0; i < K; ++i) {
		total += l[i];
	}

	cout << total << endl;	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
vector<int> v(3030);
int n,k;
int tab[3030][3030][2];
int dp(int l,int r,bool pl){
    if(tab[l][r][pl]){
        return tab[l][r][pl];
    }
    if(l==r){
        return (pl ? -v[l] : v[l]);
    }
    if(pl){
        return tab[l][r][pl] = min(dp(l+1,r,!pl)-v[l],dp(l,r-1,!pl)-v[r]);
    }
    return tab[l][r][pl] = max(dp(l+1,r,!pl)+v[l],dp(l,r-1,!pl)+v[r]);
}
int32_t main(){
    ms(tab,0);
    fastio;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    cout << dp(0,n-1,0) << endl;
} 

Measured memory_bytes: 143872
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

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

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

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

        if x == y:
            return

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

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

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

    # これ追加
    def count_group(self):
        return len({self.find(x) for x in range(N)})

N = getN()
que = [getList() for i in range(N)]
if N == 1:
    print(1)
    exit()

dis = []
# [p, q]の通りは50C2通りある
for i in range(N):
    for j in range(i + 1, N):
        dis.append([que[i][0] - que[j][0], que[i][1] - que[j][1]])

ans = float('inf')
for p, q in dis:
    U = UnionFind(N)
    for i in range(N):
        for j in range(i + 1, N):
            if (que[i][0] + p == que[j][0] and que[i][1] + q == que[j][1]) or (que[i][0] - p == que[j][0] and que[i][1] - q == que[j][1]):
                U.union(i, j)
    ans = min(ans, U.count_group())
print(ans)

Measured memory_bytes: 11212
#include<iostream>
#include<vector>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    string S;
    cin >> S;
    int r = 0;
    int b = 0;
    for(int i = 0;i <= S.length();i++){
        if(S[i] == '0')r++;
        else if(S[i] == '1')b++;
    }
    cout << min({r, b}) * 2;
}


Measured memory_bytes: 512
from collections import deque
n=int(input())
l=["3","5","7"]
q=deque(["3","5","7"])
l1=["3","5","7"]
count=0
while q:
  a=q.popleft()
  for i in l:
    if int(i+a)<=n:
      q.append(i+a)
      l1.append(i+a)
for i in l1:
  if ("3" in i) and ("5" in i) and ("7" in i):
    count+=1
print(count)

Measured memory_bytes: 7012
#include <cstdio>
#include <cstring>
int dp[100][100][5];
int main() {
	int w,h;
	while(scanf("%d %d",&w,&h),w|h) {
		memset(dp,0,sizeof(dp));
		dp[0][0][0]=1;
		for(int y=0;y<h;y++) for(int x=0;x<w;x++) {
			if(0<x) {
				dp[x][y][1]=dp[x-1][y][4];
				dp[x][y][2]=(dp[x-1][y][0]+dp[x-1][y][1]+dp[x-1][y][2])%100000;
			}
			if(0<y) {
				dp[x][y][3]=dp[x][y-1][2];
				dp[x][y][4]=(dp[x][y-1][0]+dp[x][y-1][3]+dp[x][y-1][4])%100000;
			}
		}
		int sum=0;
		for(int i=0;i<=4;i++) sum=(sum+dp[w-1][h-1][i])%100000;
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll n, c;
  cin >> n >> c;
  
  ll D[c][c];
  ll tmp;
  for (int i=0;i<c;i++){
    for (int j=0;j<c;j++){
      cin >> tmp;
      D[i][j] = tmp;
    }
  }
  
  ll G[3][c];
  for (int i=0;i<3;i++) fill(G[i], G[i]+c, 0);
  
  for (int i=0;i<n;i++){
    for (int j=0;j<n;j++){
      cin >> tmp;
      G[(i+j+2)%3][tmp-1] += 1;
    }
  }
  
  ll cost[3*c];
  fill(cost, cost+3*c, 0);

  for (int i=0;i<3;i++){
    for (int j=0;j<c;j++){
      for (int k=0;k<c;k++) cost[c*i+j] += G[i][k]*D[k][j];
    }
  }
  
  ll ans = INF;
  for (int i=0;i<c;i++){
    for (int j=c;j<2*c;j++){
      if (i == j-c) continue;
      for (int k=2*c;k<3*c;k++){
        if (i == k-2*c || j == k-c) continue;
        if (cost[i]+cost[j]+cost[k] < ans) ans = cost[i]+cost[j]+cost[k];
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i
a = Array.new(4){Array.new(3){Array.new(10,0)}}

n.times do
  b, f, r, v = gets.split(" ").map(&:to_i)
  a[b - 1][f - 1][r - 1] += v
end

4.times do |i|
  3.times do |j|
    puts " " + a[i][j].join(" ")
  end
  if i == 3
    next
  end
  puts "#" * 20
end

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

int lt(int ok, int ng, int key, vector<int> s) {
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (s[mid] < key) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> c[i];

  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  long long ans = 0;
  for (int i = 0; i < n; i++)
  {
    // long long cnta = lt(-1,n,b[i],a) + 1;
    int ok = -1;
    int ng = n;
    int key = b[i];
    while (abs(ok - ng) > 1) {
      int mid = (ok + ng) / 2;
      if (a[mid] < key) ok = mid;
      else ng = mid;
    }
    long long cnta = ok+1;
    // long long cnta = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
    long long cntc = c.end() - upper_bound(c.begin(),c.end(),b[i]);
    ans+=cnta*cntc;
  }
  cout << ans << endl;  
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void){

	int H,W,i,j;

	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0){
			break;
		}

		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				printf("#");
				if(j == W-1){
					printf("\n");
				}
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1000
n = int(input())
d = {}
arr = list(map(int,input().split()))
for a in arr:
    if a-1 not in d:
        d[a-1] = 1
    else:
        d[a-1]+=1
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1

    if a+1 not in d:
        d[a+1] = 1
    else:
        d[a+1] += 1

# print(d)
print(max(d.values()))

Measured memory_bytes: 19756
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 
int main()
{
	int n, j = 0;
    string s;
    cin >> s;
    n = s.length();
    for (int i = 0; i < n; i++)
    {
    	if (s[i] == '7')
    	{
    		cout << "Yes";
    		j = 1;
    		break;
    	}
    }

    if (j == 0)
    {
    	cout << "No";
    }

	return 0;
}

Measured memory_bytes: 3608
from collections import defaultdict
n=int(input())
arr=list(map(int,input().split()))
dd=defaultdict(int)
for a in arr:
    dd[a]+=1
if n%2==0:
    for i in range(1,n,2):
        if dd[i]!=2:
            print(0)
            exit(0)
    else:
        prod=1
        for i in range(n//2):
            prod*=2
            prod%=1000000007
        print(prod)
else:
    if dd[0]!=1:
        print(0)
        exit(0)
    for i in range(2,n,2):
        if dd[i]!=2:
            print(0)
            exit(0)
    else:
        prod=1
        for i in range((n-1)//2):
            prod*=2
            prod%=1000000007
        print(prod)


Measured memory_bytes: 14820
from collections import Counter
P = [0] * 100001
Q = [0] * 100002
P[0] = 1
P[1] = 1

for i in range(2, 100000):
    if P[i] == 0:
        for j in range(i*2, 100000, i):
            P[j] += 1

n = int(input())
num = [list(map(int,input().split())) for _ in range(n)]

for k in range(3, 100000, 2):
    if P[k] == 0 and P[(k + 1) // 2] == 0:
        Q[k] = 1
for l in range(100000):
    Q[l+1] += Q[l]

for m in range(n):
    l, r = num[m][0], num[m][1]
    print(Q[r] - Q[l-1])
    

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(1e5) + 5;
const double EPS = 1e-8;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#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 (ll i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

struct UnionFindTree {
    int par[MAX_N];
    int rank[MAX_N];
    int siz[MAX_N];

    void init(int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        siz[x] += siz[y];
    }
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        x = find(x);
        return siz[x];
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    UnionFindTree g;
    g.init(n);
    REP(i,q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c){
            cout << (g.is_same(x,y)?1:0) << endl;
        }
        else{
            g.unite(x,y);
        }
    }
    return 0;
}



Measured memory_bytes: 3212