akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	string s, t; cin >> s >> t;
	int l = lcm(n, m);
	for (int i = 0; i < l; i += l / n) {
		if (i % (l / m) == 0) {
			if (s[i / (l / n)] != t[i / (l / m)]) {
				cout << -1 << endl; return 0;
			}
		}
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"strings"
)

func main() {
	var str string
	fmt.Scan(&str)

	count := 0
	maxCount := 0
	target := "ACGT"
	for i := 0; i < len(str); i++ {
		if strings.Contains(target, str[i:i+1]) {
			count++
			if maxCount < count {
				maxCount = count
			}
		} else {
			count = 0
		}
	}

	fmt.Println(maxCount)
}


Measured memory_bytes: 640
import scala.collection.mutable.ListBuffer

object Main extends App {
  import scala.io.StdIn.readLine;

  val n = readLine().toInt
  val inputs = new ListBuffer[Int]
  for (i <- 1 to n) {
    inputs += readLine().toInt
  }

  val aaa = inputs.sorted

  var res = 0;
  for (i <- 0 to n - 1) {
    var a = aaa(i)
    if (i == n -1)  a = aaa(i) / 2
    res = res + a
  }

  println(res)
}


Measured memory_bytes: 25528
package main

import (
	"fmt"
	"math"
)

func main() {

	var n, v int

	max, min := math.MinInt32, math.MaxInt32

	var c int64

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&v)

		if v > max {
			max = v
		}

		if v < min {
			min = v
		}

		c += int64(v)
	}

	fmt.Println(min, max, c)

}

//a, _ := strconv.ParseFloat(tmp[0], 64)



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

takahashi_win=True
while True:
    c-=b
    if c<=0:
        takahashi_win=True
        break
    a-=d
    if a<=0:
        takahashi_win=False
        break


if takahashi_win:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9180
def incremental? (card)
	(card.size-2).times {|i| return false if card[i]+1 != card[i+1]}
	return true
end

def is_straight(card)
	return true if incremental?(card) || card == [1,10,11,12,13]
	return false
end

while gets
	card = $_.split(',').map(&:to_i).sort
	next if card[0] == 0
	count = []
	5.times {|i| count[i] = card.count(card[i])}
	hand = "null"
	hand = "one pair" if count.index(2)
	hand = "two pair" if count.count(2) == 4
	hand = "three card" if count.index(3)
	hand = "straight" if is_straight(card)
	hand = "full house" if count.index(2) && count.index(3)
	hand = "four card" if count.index(4)
	puts hand
end

Measured memory_bytes: 6108
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t N = 0, M = 0;
  std::cin >> N >> M;

  std::vector<uint32_t> H(N);
  std::vector<bool> flag(N, true);
  for (size_t i = 0; i < N; ++i) {
    std::cin >> H[i];
  }

  for (size_t i = 0; i < M; ++i) {
    uint32_t a = 0, b = 0;
    std::cin >> a >> b;
    if (H[a - 1] > H[b - 1]) {
      flag[b - 1] = false;
    } else if (H[a - 1] < H[b - 1]) {
      flag[a - 1] = false;
    } else {
      flag[a - 1] = false;
      flag[b - 1] = false;
    }
  }

  std::cout << std::count(flag.begin(), flag.end(), true) << std::endl;

  return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  string s;
  
  while(1){  
    cin >> s;
    if(s == "0"){
      break;
    }
    int ans = 0;   
    for(int i = 0; i < s.size(); i++){
      ans += (int)(s[i] - '0');
    }
    cout << ans << endl;
  }
  return 0;
}




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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

ll gcd_euclid(ll a, ll b){
    return b==0 ? a : gcd_euclid(b, a%b);
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }
    
    ll lcm = a[0];
    for(int i = 1; i < n; i++){
        int gcd = gcd_euclid(lcm, a[i]);
        lcm = lcm * a[i] / gcd;
    }

    for(int i = 0 ; i < n; i++){
        if((lcm/a[i])%2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    
    if(lcm > m) cout << 0 << endl;
    else{
        ll ans = 1 + (m-lcm) / (lcm*2);
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
<?php
  
  fscanf(STDIN,"%d%d",$n,$l);
$s_li=array();
for($i=0;$i<$n;$i++){
  $s_li[]=trim(fgets(STDIN));
}

//print_r($s_li);

sort($s_li);
//print_r($s_li);
$re = '';
foreach($s_li as $val){
  $re.=$val;
}

echo $re."\n";

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

using namespace std;

string a,tmpa,b,tmpb;

int aa[105],bb[105];

inline bool cmp1(int x,int y)
{
	return x<y;
}

inline bool cmp2(int x,int y)
{
	return x>y;
} 

int main()
{
	ios::sync_with_stdio(false);
	
	cin>>a;
	
	cin>>b;
	
	for (register int i=0;i<a.size();++i)
		aa[i]=a[i]-64;
	
	sort(aa,aa+a.size(),cmp1);
	
	for (register int i=0;i<a.size();++i)
		tmpa+=char(aa[i]+64);
	
	//cout<<tmpa<<endl;
	
	for (register int i=0;i<b.size();++i)
		bb[i]=b[i]-64;
	
	sort(bb,bb+b.size(),cmp2);
	
	for (register int i=0;i<b.size();++i)
		tmpb+=char(bb[i]+64);
	
	//cout<<tmpb<<endl;
	
	if (tmpa<tmpb) cout<<"Yes"<<endl; else cout<<"No"<<endl;
	
	return 0;	
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define F               first
#define S               second
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18 + 1
#define endl            '\n'
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define forI(i,a,n)     for(int i=a;i<=n;i++)
#define forD(i,a,n)     for(int i=n;i>=a;i--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void init(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

vector<vi> multiply(vector<vi> a, vector<vi> b){
    int n = a.size();
    vector<vi> c(n, vi(n, 0));
    forI(i, 0, n-1){
        forI(j, 0, n-1){
            forI(x, 0, n-1){
                c[i][j] = (c[i][j] + (a[i][x]*b[x][j]))%mod;
            }
        }
    }

    return c;
}

vector<vi> power(vector<vi> adj, int p){
    if(p == 1)  return adj;

    vector<vi> res = power(adj, p/2);
    if(p&1) 
        return multiply(multiply(adj, res), res);
    else    return multiply(res, res); 
}

int compute(vector<vi> adj, int n){
    int ans=0;
    forI(i, 0, n-1)   forI(j, 0, n-1)
        ans = (ans%mod + adj[i][j]%mod)%mod;
    return ans;
}

void solve(){
    int n, k;  cin>>n>>k;
    vector<vi> adj(n, vi(n));
    forI(i, 1, n)   forI(j, 1, n)   cin>>adj[i-1][j-1];
    adj = power(adj, k);
    cout<<compute(adj, n);
}   

int32_t main(){
    init();
    // w(t) 
    solve();
    return 0;
}

Measured memory_bytes: 5000
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,p,a;
    cin >> n >> p;
    ll odd = 0,even = 0;
    rep(i,n){
        cin >> a;
        if (a%2) odd++;
        else even++;
    }
    if (odd == 0 && p == 1) PRINT(0);
    else if (odd == 0) PRINT((1ll<<even));
    else PRINT((1ll<<odd)*(1ll<<even)/2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
signed main(){
  cout<<fixed<<setprecision(10);
  double h,w,x,y;
  cin>>w>>h>>x>>y;
  cout<<(w*h/2)<<" "<<(w==2*x&&h==2*y)<<endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
A_list.sort()
A_max = A_list[N-1]

is_prime = [False] * (A_max+1)


for i in A_list:
    is_prime[i] = True

x = -1
for i in A_list:
    if not is_prime[i]:
        continue
    elif x == i:
        is_prime[i] = False
        continue
    for j in range(i*2, A_max+1, i):
        is_prime[j] = False
    x = i

count = 0
for i in A_list:
    if is_prime[i]:
        count += 1


print(count)


Measured memory_bytes: 32176
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

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


using namespace std;

int main() {
   
   int H,W,K;
   cin >> H >> W >> K;
   int c[H][W];
   int d[H][W];

   string S;
   REP(i,H){
      cin >>S;
      REP(j,W){
         if(S[j]=='.'){
            c[i][j]=1;
         }else{
            c[i][j]=0;
         }
      }
   }

   for(int l=0;l<H;l++){
      for(int m=0;m<W;m++){
         d[l][m]=c[l][m];
      }
   }

   int p,q;
   int hh[H],ww[W];
   int cnt=0;
   int bla=0;
   REP(i,pow(2,H)){
      p=i;
      for(int j=0;j<H;j++){
         hh[j]=p%2;
         p=p/2;
      }
      REP(j,pow(2,W)){
         cnt=0;
         for(int l=0;l<H;l++){
           for(int m=0;m<W;m++){
               c[l][m]=d[l][m];
            }
         }
         q=j;
         for(int k=0;k<W;k++){
            ww[k]=q%2;
            q=q/2;
         }      
      for(int l=0;l<H;l++){
         for(int m=0;m<W;m++){
            c[l][m]=(hh[l]==1?2:c[l][m]);
            c[l][m]=(ww[m]==1?2:c[l][m]);
         }
      }

      for(int l=0;l<H;l++){
         for(int m=0;m<W;m++){
            cnt+=(c[l][m]==0?1:0);
         }
      }
      if(cnt==K){
         bla+=1;
      }
      }
   }
   cout << bla << endl;

}

Measured memory_bytes: 4072
#[warn(unused_imports)]
use std::io::*;
use std::str::FromStr;
use std::cmp;

#[warn(unused_variables)]

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")
}

fn dfs(v: usize, c: i64, graph: &Vec<Vec<usize>>, color: &mut Vec<i64>) -> bool {
    color[v] = c;
    //println!("{:?}", color);
    for i in 0..graph[v].len() {
        if color[graph[v][i]] == c {
            return false;
        }
        if color[graph[v][i]] == 0 && !dfs(graph[v][i], -c, &graph, color) {
            return false;
        }
    }
    return true;
}

fn solve(graph: &mut Vec<Vec<usize>>, n: usize, m: usize) {
    let mut color = vec![0; n+1];
    color[1] = 1;
    let bipartite: bool = dfs(1, 1, &graph, &mut color);
    if bipartite {
        let mut k = 0;
        for i in 0..color.len() {
            if color[i] == 1 {
                k += 1;
            }
        }
        let n = n as i64;
        let m = m as i64;
        println!("{:?}", k * (n - k) - m);
    } else {
        println!("{}", n * (n-1) / 2 - m);
    }
}

fn main() {
    let n = read::<usize>(); // 頂点数
    let m = read::<usize>(); // 辺の数
    let mut graph: Vec<Vec<usize>> = vec![Vec::new(); n+1];
    for _ in 0..m {
        let a = read::<usize>();
        let b = read::<usize>();
        graph[a].push(b);
        graph[b].push(a);
    }
    solve(&mut graph, n, m);
}

Measured memory_bytes: 12924
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>H>>W;
    cout<<(H <= W ? "unsafe" : "safe")<<endl;
}

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

using namespace std;

int main() {

	int n,m;
	cin >> n >> m ;

	vector<pair<long long, long long>> p(n);

	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
  sort(p.begin(),p.end());
  int sum=0;
  long long price=0;
  
  for(int i=0;i<n;i++){
    price += p[i].first*p[i].second;
    sum += p[i].second;
    if(sum >= m) {
      price -= (sum-m)*p[i].first;
      break;
    }
  }
  
  cout << price << endl;
}
    



Measured memory_bytes: 1792
nm = gets.chomp.split
n = nm[0].to_i
m = nm[1].to_i

h = gets.chomp.split
n.times do |i|
    h[i] = h[i].to_i
end

ab = []
m.times do
    input = gets.chomp.split
    2.times do |i|
        input[i] = input[i].to_i
    end
    input.sort!
    ab << input
end

towers = Array.new(n, true)
m.times do |j|
    a = ab[j][0] - 1
    b = ab[j][1] - 1
    towers[a] = false if h[a] <= h[b]
    towers[b] = false if h[b] <= h[a]
end

puts towers.count(true)

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

using namespace std;

void dfs(int u, int goal, const vector<vector<int>> &g, 
         vector<int> &vis, vector<int> &path) {
    vis[u] = 1;
    if (u == goal) {
        path.push_back(u);
        return;
    }
    for (int v : g[u]) {
        if (!vis[v]) {
            dfs(v, goal, g, vis, path);
            if (!path.empty()) {
                path.push_back(u);
                return;
            }
        }
    }
}
int dfs_depth(int u, const vector<vector<int>> &g,
               vector<int> &vis) {
    vis[u] = 1;
    int mx_depth = 1;
    for (int v : g[u]) {
        if (!vis[v]) {
            mx_depth = max(mx_depth, dfs_depth(v, g, vis) + 1);
        }
    }
    return mx_depth;
}
int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);

    int N, u, v;
    cin >> N >> u >> v;
    --u;
    --v;
    vector<vector<int>> g(N);
    for (int i = 0; i < N - 1; ++i) {
        int A, B;
        cin >> A >> B;
        g[A - 1].push_back(B - 1);
        g[B - 1].push_back(A - 1);
    }
    vector<int> vis(N, 0), path_u_v;
    dfs(u, v, g, vis, path_u_v);
    reverse(begin(path_u_v), end(path_u_v));
    int len = path_u_v.size(), num_init_moves = 0;
    int begin_u = u, begin_v = v;
    for (int i = 0, j = len - 1; i + 1 <= j - 1; ++i, --j) {
        begin_u = path_u_v[i + 1];
        begin_v = path_u_v[j - 1];
        ++num_init_moves;
    }
    int mx_depth = 0, res = 0;
    if (begin_v != begin_u) {
        vis.assign(N, 0);
        vis[begin_v] = 1; // forbid moving through begin_v
        mx_depth = dfs_depth(begin_u, g, vis) - 1;
        res = mx_depth + num_init_moves;
    } else {
        int meet_v = begin_v;
        res = num_init_moves;
        num_init_moves = 0;
        begin_u = u, begin_v = v;
        for (int i = 0, j = len - 1; i + 1 < j - 1; ++i, --j) {
            begin_u = path_u_v[i + 1];
            begin_v = path_u_v[j - 1];
            ++num_init_moves;
        }
        vis.assign(N, 0);
        vis[meet_v] = 1;
        mx_depth = dfs_depth(begin_u, g, vis) - 1;
        res = max(res, num_init_moves + mx_depth + (len % 2 == 1));
    }
    cout << res << "\n";


    return 0;
}

Measured memory_bytes: 11768
def addRoute(i, c):
  t = ''
  for _ in range(i):
    t += c
  return t

pos=list(map(int, input().split()))
ud = pos[3] - pos[1]
rl = pos[2] - pos[0]
s = ''

s += addRoute(ud, 'U')
s += addRoute(rl, 'R')
s += addRoute(ud, 'D')
s += addRoute(rl, 'L')
s += 'L'
s += addRoute(ud+1, 'U')
s += addRoute(rl+1, 'R')
s += 'DR'
s += addRoute(ud+1, 'D')
s += addRoute(rl+1, 'L')
s += 'U'
print(s)

Measured memory_bytes: 9172
from sys import stdin
import math
import fractions
from collections import deque
import collections
import itertools

INF = 10 ** 10


# N個のボールがあり、i番目のボールは(xi, yi)にある
N = int(stdin.readline().rstrip())
xy = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

data = []

if N == 1:
    print(1)
    exit()

for i in range(N):
    for j in range(i+1, N):
        x_diff = xy[i][0] - xy[j][0]
        y_diff = xy[i][1] - xy[j][1]
        data.append("{0},{1}".format(x_diff, y_diff))
        data.append("{0},{1}".format(-x_diff, -y_diff))

c = collections.Counter(data)

print(N - c.most_common()[0][1])


Measured memory_bytes: 66284
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn dfs(edges: &Vec<Vec<usize>>, cur:usize, vs: &mut Vec<usize>, seen: &mut Vec<bool>) {
    if seen[cur] {
        return
    }
    seen[cur] = true;

    for &nd in edges[cur].iter() {
        dfs(edges, nd, vs, seen);
    }
    vs.push(cur);
}


fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      xys: [(usize1, usize1); m],
    }
    let mut edges = vec![vec![]; n];
    for (x, y) in xys {
        edges[x].push(y);
    }
    let mut nodes = vec![];
    let mut seen = vec![false; n];
    for i in 0..n {
        dfs(&edges, i, &mut nodes, &mut seen)
    }

    nodes.reverse();
    let mut dp = vec![0; n];
    for cur in nodes {
        for &nd in edges[cur].iter() {
            dp[nd] = max(dp[cur] + 1, dp[nd]);
        }
    }
    let ans = dp.iter().max().unwrap();
    puts!("{}\n", ans);
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;
const int X = 753;

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

    int tmp = (S[0] - '0') * 10 + (S[1] - '0');
    int res = X;
    repd(i, 2, S.size()) {
        tmp %= 100;
        tmp *= 10;
        tmp += (S[i] - '0');
        res = min(res, abs(tmp - X));
    }

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

Measured memory_bytes: 256
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    answer();
   }
   static void answer()
   {
     Scanner sc = new Scanner(System.in);
     
     int n = sc.nextInt();
     
     boolean[][] card = new boolean[4][14];
     
     String[] suit = {"S","H","C","D"};
     //input
     for(int i = 0;i < n;i ++)
     {
       String s = sc.next();
       
       int num = sc.nextInt();
       
       int sb = 5;
       
       for(int j = 0;j < 4; j ++)
       {
         if(suit[j].equals(s)) sb = j;
       }
       if(sb == 5)
       {
         System.out.println("error!!");
         
         return;
       }
       card[sb][num] = true ;
     }//output 
     for(int i = 0; i < 4; i ++)
     {
       for(int j = 1; j < 14; j ++)
       {
         if(card[i][j] != true)
         {
           System.out.println(suit[i] + " " + j);
         }
       }
     }
   }
 }



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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

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

//--------------------------------------------

int main(){
  char s[110];
  char a[10];
  scanf("%s %s",&a,&s);
  printf("A%cC\n",s[0]);
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
 
class ModInt{
private:
  long long val;
  static const int default_mod = 1e9 + 7;
  static int mod;
  static vector<ModInt> facts;
public:
  ModInt(long long val)
  {
    if(mod == 0){
      mod = default_mod;
    }
    this->val = ((val % mod) + mod) % mod;
  }
  ModInt()
    : ModInt(0)
  {
  }
  static void setMod(int mod){
    if(ModInt::mod != 0){
      throw "The modulo is already set.";
    }
    ModInt::mod = mod;
  }

  const ModInt operator* (const ModInt& another) const{
    return ModInt(val * another.val);
  }
  ModInt operator+ (const ModInt& another){
    return ModInt(val + another.val);
  }
  ModInt operator- (const ModInt & another){
    return ModInt(val - another.val + mod);
  }
  ModInt operator/(const ModInt& rhs){
    return (*this) * rhs.inv();
  }
  ModInt& operator*=(const ModInt& rhs){
    (*this) = (*this) * rhs;
    return *this;
  }
  ModInt& operator+=(const ModInt& rhs){
    (*this) = (*this) + rhs;
    return *this;
  }
  ModInt& operator-=(const ModInt& rhs){
    (*this) = (*this) - rhs;
    return *this;
  }
  ModInt& operator/=(const ModInt& rhs){
    (*this) = (*this) / rhs;
    return *this;
  }
  ModInt pow(long long exponent) const{
    exponent %= mod;
    if(exponent == 0){
      return ModInt(1);
    }else{
      if(exponent % 2){
        return ((*this) * (*this)).pow(exponent / 2) * (*this);
      }else{
        return ((*this) * (*this)).pow(exponent / 2);
      }
    }
  }
  ModInt inv() const{
    return this->pow(mod - 2);
  }
  static ModInt fact(long long n){
    if(n >= mod){
      return 0;
    }
    if(facts.size() < static_cast<size_t>(n + 1)){
      if(facts.size() == 0){
        facts.push_back(1);
      }
      for(int i = facts.size(); i <= n; i++){
        facts.push_back(facts[i - 1] * i);
      }
    }
    return facts[n];
  }
  static ModInt comb(long long n, long long r){
    if(r > n){
      return 0;
    }
    return ModInt::fact(n) * ModInt::fact(r).inv() * ModInt::fact(n - r).inv();
  }
 
  friend ostream& operator<< (ostream& os, const ModInt& modint){
    os << modint.val;
    return os;
  }
  friend istream& operator>>(istream& is, ModInt& modint){
    long long val;
    is >> val;
    modint.val = val % modint.mod;
    return is;
  }
  friend ModInt operator*(const long long lhs, const ModInt& rhs){
    return ModInt(lhs) * rhs;
  }
};
int ModInt::mod = 0;
vector<ModInt> ModInt::facts;

int main(){
  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  ModInt(0);

  ModInt ans = ModInt::comb(r2 + c2 + 2, r2 + 1) - ModInt::comb(r2 + c1 + 1, c1) - ModInt::comb(r1 + c2 + 1, r1) + ModInt::comb(r1 + c1, r1);
  cout << ans << endl;
}


Measured memory_bytes: 18664
#include<stdio.h>
#define max 2000
int Sun(int, int);
int n,q,A[max];
int main(){
  int m[max],i,j,jud;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  
  for(i = 0;i < q;i++){
    scanf("%d",&m[i]);
  }
  for(i = 0;i<q;i++){
    jud = Sun(0,m[i]);
    if(jud==0)printf("yes\n");
    else printf("no\n");
  }
 
  return 0;
}

int Sun(int i,int m){
  int res;
  
  if(m == 0)return 0;
  if(i >= n)return 1;

  res = Sun(i+1,m);
  if(res == 0)return 0;

  res= Sun(i+1,m - A[i]);

  return res;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define bit(x,j) ((x>>j)&1)
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
ll int mod=1e9+7;//998244353;
int mul(ll int x, ll int y)
{
    return (x * 1ll * y) % mod;
}

int add(int x, int y)
{
    x += y;
    while(x >= mod) x -= mod;
    while(x < 0) x += mod;
    return x;
}

long long power(long long a, long long b) {
    a %= mod;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%mod;
    }


  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = add(C[j],C[j-1]); 
    } 
    return C[k]%mod; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 

//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

 ll int sum(ll int n) 
 { 
    ll int s; 
  
    /* Single line that calculates sum */
    for (s = 0; n > 0; s += n % 10, n /= 10); 
  
    return s; 
 } 

ll int factorial(ll int n,ll int m) 
{ 
    ll int fact = 1; 
    for(int i=2;i<=n;i++) { 
        fact = (fact * i)%m; 
    } 
    return fact%m; 
} 

int reduce(int x, int y) 
{ 
    int d; 
    d = __gcd(x, y); 
  
    x = x / d; 
    y = y / d; 
    return x; 
} 
 
 int main() {
  ios;
  string s;
  cin>>s;
  int l=s.length();
  if(s[l-1]=='s')
  {
      s+="es";
  }
  else
  {
      s+="s";
  }
cout<<s<<endl;
  }


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

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

map<int, int> mp;

int main() {
    int n, a;
    cin >> n;
    rep(i, n - 1) {
        cin >> a;
        mp[a]++;
    }
    for (int i = 1; i <= n; ++i) {
        cout << mp[i] << endl;
    }

    return 0;
}

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

struct tree {
  bool is_leaf;
  int idx;
  int value;
  vector<tree> children;
  tree() {}
  tree(int i) : is_leaf(true), idx(i) {}
  tree(const tree& l, const tree& r) : is_leaf(false), children(2)
  {
    children[0] = l;
    children[1] = r;
  }

  tree left() const { return children[0]; }
  tree right() const { return children[1]; }
};

pair<tree,int> parse(const string& s, int start = 0)
{
  if (s[start] == '(') {
    pair<tree,int> left = parse(s, start+1);
    pair<tree,int> right = parse(s, left.second+1);
    return make_pair(tree(left.first, right.first), right.second+1);
  } else {
    return make_pair(tree(s[start]-'1'), start+1);
  }
}

vector<int> evals(const tree& t, vector<int> binds)
{
  if (t.is_leaf) {
    return vector<int>(1, binds[t.idx]);
  } else {
    const vector<int> l = evals(t.left(), binds);
    const vector<int> r = evals(t.right(), binds);
    vector<int> ret;
    for (vector<int>::const_iterator it(l.begin()); it != l.end(); ++it) {
      for (vector<int>::const_iterator jt(r.begin()); jt != r.end(); ++jt) {
        ret.push_back(*it & *jt);
        ret.push_back(*it | *jt);
        ret.push_back(*it ^ *jt);
      }
    }
    return ret;
  }
}

void print(const tree& t)
{
  if (t.is_leaf) {
    cout << t.idx;
  } else {
    cout << '(';
    print(t.children[0]);
    cout << ' ';
    print(t.children[1]);
    cout << ')';
  }
}

int main()
{
  string s;
  while (getline(cin, s) && s != "END") {
    pair<tree,int> p = parse(s);
    getline(cin, s);
    int N = s[0]-'0';
    vector<int> b(N);
    for (int i = 0; i < N; i++) {
      getline(cin, s);
      int v = 0;
      for (int j = 0; j < 4; j++) {
        int a = s[j*2]-'0';
        v = (v<<1) | a;
      }
      b[i] = v;
    }

    int ans = 0;
    vector<int> r = evals(p.first, b);
    for (vector<int>::const_iterator it(r.begin()); it != r.end(); ++it) {
      if (*it == 15) {
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//ありがとうありがとうありがとうありがとうありがとうありがとうありがとうありがとうありがとうありがとう
//ありがとうありがとうありがとうありがとうありがとうありがとうありがとうありがとうありがとうありがとう
std::vector<int> used(10000,0),ans,fans,edge[10000];
bool FIN=false;

int dfs(int now,int cnt){
  if(FIN)return 1;

  used[now]=cnt;

  int t=0,w;
  for(int p:edge[now])
    if(used[p]>t)
      t=used[p],w=p;

  if(t){
    ans.push_back(now);
    used[w]=-1;
    return 1;
  }

  for(int p:edge[now]){
    if(FIN)return 1;
    if(dfs(p,cnt+1)){
      if(FIN)return 1;
      ans.push_back(now);
      if(used[now]<0)FIN=true;
      return 1;
    }
  }

  used[now]=0;
  return 0;
}

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

  while(M--){
    int a,b;cin>>a>>b;a--;b--;
    edge[a].push_back(b);
  }

  for(int i=0;i<N;i++){
    FIN=0;
    fill(used.begin(),used.end(),0);
    if(dfs(i,1)){
      if(ans.size()<fans.size()||!fans.size())fans=ans;
      ans.clear();
    }
  }


  if(fans.size()){
    cout<<fans.size()<<endl;
    for(int p:fans)cout<<p+1<<endl;
  }
  else fin(-1);
}


Measured memory_bytes: 640
package main
import(
	"fmt"
	"os"
	"bufio"
)

func main(){
	stdin:=bufio.NewReader(os.Stdin)
	var a,b,c,cnt int
	cnt=0
	fmt.Fscan(stdin,&a,&b,&c)
	for i:=a;i<=b;i++{
		if c%i==0{
			cnt++
		}
	}
	fmt.Printf("%d\n",cnt)
}


Measured memory_bytes: 1172
n = int(input())
p = [i for i in map(int, input().split())]
q = [i for i in map(int, input().split())]

sorted_list = sorted(p)
all_list = []

def listExcludedIndices(data, indices=[]):
	return [x for i, x in enumerate(data) if i not in indices]

def permutationListRecursive(data, r):
	if r <= 0 or r > len(data):
		return []
	
	result = []
	_permutationListRecursive(data, r, [], result)
	return result

def _permutationListRecursive(data, r, progress, result):
	if r == 0:
		result.append(progress)
		return
	
	for i in range(len(data)):
		_permutationListRecursive(listExcludedIndices(data, [i]), r - 1, progress + [data[i]], result)


a = -1
b = -1

for i, list_ in enumerate(permutationListRecursive(sorted_list, n)):
	#print(list_)
	if list_ == p:
		a = i

	if list_ == q:
		b = i

	if a != -1 and b != -1:
		break

print(abs(a-b))


Measured memory_bytes: 8988
package main

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

const INF = 1000000001
const MAX = 200000

var sc = bufio.NewScanner(os.Stdin)
var B, C [MAX]int
var cnt int

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func merge(A []int, left, mid, right int) {
	n1 := mid - left
	n2 := right - mid
	for i := 0; i < n1; i++ {
		B[i] = A[left+i]
	}
	for i := 0; i < n2; i++ {
		C[i] = A[mid+i]
	}
	B[n1] = INF
	C[n2] = INF

	l, r := 0, 0
	for i := 0; i < right-left; i++ {
		if B[l] < C[r] {
			A[left+i] = B[l]
			l++
		} else if B[l] > C[r] {
			A[left+i] = C[r]
			cnt += (n1 - l)
			r++
		}
	}
}

func mergeSort(A []int, left, right int) {
	if left+1 < right {
		mid := (left + right) / 2
		mergeSort(A, left, mid)
		mergeSort(A, mid, right)
		merge(A, left, mid, right)
	}
}

func main() {
	n := scanInt()

	A := make([]int, n)
	for i := range A {
		A[i] = scanInt()
	}

	mergeSort(A, 0, n)
	fmt.Println(cnt)
}



Measured memory_bytes: 8116
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<algorithm>
using namespace std;
#define N 80020
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,X[N],Y[N],b[N],x[N],y[N],to[N],pos[N],l,r,ans,a[N],gu[N];
int cnt,head[N];
bool cmp(int i,int j){
	return a[i]<a[j];
}
struct Edge{
	int to,nxt;
}edge[N<<5];
void add(int a,int b){
	++cnt;
	edge[cnt].to=b;
	edge[cnt].nxt=head[a];
	head[a]=cnt;
}
int segtot,seg[N];
struct node{
	int l,r;
}tree[N<<2];
#define ls i<<1
#define rs i<<1|1
void build(int i,int l,int r){
	tree[i].l=l;
	tree[i].r=r;
	seg[i]=++segtot;
	if(l==r){
		add(seg[i],((pos[l]+n-1)%(2*n)+1));
		return;
	}
	int mid=(l+r)>>1;
	build(ls,l,mid);
	build(rs,mid+1,r);
	add(seg[i],seg[ls]);
	add(seg[i],seg[rs]);
}
int low[N],dfn[N],num,tot,col[N],vis[N];
stack<int> st;
void Tarjan(int u){
	low[u]=dfn[u]=++num;
	st.push(u);
	vis[u]=1;
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(!dfn[v]){
			Tarjan(v);
			low[u]=min(low[u],low[v]);
		}
		else if(vis[v]){
			low[u]=min(low[u],dfn[v]);
		}
	}
	if(low[u]==dfn[u]){
		int t=0;
		++tot;
		while(u^t){
			t=st.top();
			st.pop();
			vis[t]=0;
			col[t]=tot;
		}
	}
} 
void Change(int i,int l,int r,int u){
	if(l>r)return;
	if(tree[i].l>=l&&tree[i].r<=r){
		add(u,seg[i]);
		return;
	}
	int mid=(tree[i].l+tree[i].r)>>1;
	if(l<=mid){
		Change(ls,l,r,u);
	}
	if(r>mid){
		Change(rs,l,r,u);
	}
}
bool check(int d){
	memset(head,0,sizeof(head));
	memset(dfn,0,sizeof(dfn));
	memset(col,0,sizeof(col));
	memset(low,0,sizeof(low));
	cnt=tot=num=0;
	segtot=(n<<1);
	build(1,1,n<<1);
	for(int i=1;i<=(n<<1);++i){
		int l=upper_bound(b+1,b+(n<<1)+1,a[i]-d)-b;
		int r=lower_bound(b+1,b+(n<<1)+1,a[i]+d)-b-1;
		Change(1,l,gu[i]-1,i);
		Change(1,gu[i]+1,r,i);
	}
	for(int i=1;i<=segtot;++i){
		if(!dfn[i])Tarjan(i);
	}
	for(int i=1;i<=n;++i){
		if(col[i]==col[i+n])return false;
	}
	return true;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		X[i]=a[i]=read(),Y[i]=a[i+n]=read();
	}
	for(int i=1;i<=(n<<1);++i){
		pos[i]=i;
		b[i]=a[i];
	}
	sort(b+1,b+(n<<1)+1);
	sort(pos+1,pos+(n<<1)+1,cmp);
	for(int i=1;i<=(n<<1);++i){
		gu[pos[i]]=i;
	}
	l=0,r=1e9+1;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid)){
			ans=mid,l=mid+1;
		}
		else{
			r=mid;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 18560
#include <cstdio>
#include <iostream>
#include <tgmath.h>
#include <queue>
#include <cstring>

using namespace std;

// https://atcoder.jp/contests/abc076/tasks/abc076_c

string S,T;

bool  judge(string str){
    for(int i = 0; i<T.size();i++){
        if(str[i] != T[i]){
  if(str[i] != '?' ){
            return false;
        }
        }
      
    }
    return true;
}

int main(){
    cin >> S;
    cin >>T;
    bool existAnswer =false;
    if(S.size() < T.size()){
        cout << "UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=S.size()-T.size();i>=0;i--){
        string str = S.substr(i,T.size());
        if(judge(str)){
            existAnswer = true;
            for(int j=0;j<T.size();j++){
                S[j+i] = T[j];
            }
            break;
        }
    }
    if(!existAnswer){
        cout << "UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i = 0; i<S.size(); i++){
        if(S[i] == '?'){
            S[i] = 'a';
        }
    }
    cout << S <<endl;
    
}

Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, s = map(int,input().split())
    a = list(map(int, input().split()))
    dp = [[0] * (s + 1) for i in range(n + 1)]
    #dp[i][j]...最初のi個の数について。総和がjであるように選んでできる部分集合すべてについての集合の個数の総和
    dp[0][0] = 1
    for i in range(n):
        for j in range(s+1):
            dp[i + 1][j] += dp[i][j] * 2 % 998244353
            if j - a[i] >= 0:
                dp[i + 1][j] += dp[i][j - a[i]]
            dp[i + 1][j] %= 998244353
            
    print(dp[n][s])
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 135456
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 998244353;

const ll N = 1e5 + 10;
ll f[N] = {0};

void solve() {
    ll n;
    cin >> n;
    ll a[n], x = 0;
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        x ^= a[i];
    }
    for(ll i = 0; i < n; i++) cout << (x ^ a[i]) << " ";
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5172
using System;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        long[] values = Convert(GetLines());

        long N = values[0];
        long M = values[1];

        long[] values2 = Convert(GetLines());
        long sum = 0;

        foreach (long v in values2)
        {
            sum += v;
        }

        long ans = N - sum;

        if (ans < 0)
            Console.WriteLine("-1");
        else
            Console.WriteLine(ans);


    }


    static long[] Convert(string[] v)
    {
        var temp = new long[v.Length];

        for (int i = 0; i < temp.Length; i++)
        {
            temp[i] = long.Parse(v[i]);
        }

        return temp;
    }




    static string[] GetLines()
    {
        return Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
    }


}

Measured memory_bytes: 28640
#include<stdio.h>
 
int main(){
  int n, m, min, max;
  scanf("%d %d", &n, &m);
  min = 0;
  max = n;
  for (int i = 0; i < m;i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a > min) min = a;
    if (b < max) max = b;
  }
  int count = 0;
  for (int i = 0; i <= n; i++) {
    if (i >= min && i <= max) count++;
  }
  printf("%d\n", count);
  return 0;
}

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

struct edge{
  int to;
  int cost;
};

int main(){
  int v,e;cin>>v>>e;
  int r;cin>>r;
  vector<vector<edge>> G(v);
  for (int i = 0; i < e; i++) {
    int s,t,d;cin>>s>>t>>d;
    edge tmp; tmp.to = t;tmp.cost = d;
    G.at(s).push_back(tmp);
  }

  //累積コスト,頂点
  priority_queue<pair<int,int>,vector<pair<int,int>>, greater<pair<int,int>>> que;
  que.push(pair<int,int>(0,r));
  vector<int> dist(v,1e9);
  while(!que.empty())
  {
    pair<int,int> p = que.top();
    que.pop();
    int now = p.second;
    int cost = p.first;
    dist.at(now) = min(dist.at(now),cost);
    for (auto && a : G.at(now)) {
      int ncost = a.cost;
      int nver = a.to;
      if(dist.at(nver) != 1e9)continue;
      pair<int,int> pn;
      pn.first = dist.at(now) + ncost;
      pn.second = nver;
      que.push(pn);
    }
    
    /*
    for (auto && a : dist) {
    if(a == 1e9)cout<<"INF";
    else cout << a;
    cout<<endl;
  }
  cout << endl;
  */

  }
  for (auto && a : dist) {
    if(a == 1e9)cout<<"INF";
    else cout << a;
    cout<<endl;
  }
}





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

int main()
{
    int N, K;
    cin >> N >> K;
    int hi;
    vector<int> h;
    for(int i=0;i<N;i++){
        cin >> hi;
        h.push_back(hi);
    }
    sort(h.begin(), h.end());
    int res = numeric_limits<int>::max();
    for(int i=0;i<N-K+1;i++){
        res = min(res, h[i+K-1] - h[i]);
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main()
{
  int n;
  while(cin >> n,n)
    {
      vector<int> vec;
      vec.resize(n);
      for(int i=0;i<n;i++)
    cin >> vec[i];
 
      int ans = 0;
 
      for(int i= vec.size()-1;i>0;i--)
    for(int j=0;j<i;j++)
      if(vec[j+1] < vec[j])
        ans++,swap(vec[j+1],vec[j]);
 
      cout << ans << endl;
 
    }
  return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll freq[100001];
int main(){

	ll sum=0,temp;
	int n; cin>>n;
	for(int i=0;i<n;i++){
		cin>>temp;
		freq[temp]++;
		sum+=temp;
	}


	int q; cin>>q;
	while(q--){

		ll a,b;
		cin>>a>>b;
		sum=sum+(b-a)*freq[a];
		freq[b]+=freq[a];
		freq[a]=0;
		cout<<sum<<endl;
	}
}


Measured memory_bytes: 4364
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;

int main()
{
    string S;
    cin >> S;
    int len;
    len = S.size();
    int num1=0;
    num1 = 15-len;
    int counter = 0;
    for (int i = 0; i < len; i++)
    {
        if (S[i] == 'o')
        {
            counter++;
        }
        
    }
    
    if (counter+num1>=8)
    {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();

    if ((A + B) <= (A - B)) {
      if ((A - B) <= (A * B)) {
        System.out.println(A * B);  
      } else {
        System.out.println(A - B);
      }
    } else {
      if ((A + B) <= (A * B)) {
        System.out.println(A * B);  
      } else {
        System.out.println(A + B);
      }
    }

  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979


int main()
{
	ll n, lucas_before = 2, lucas_after = 1;
	cin >> n;

	if (n == 0) 
	{
		cout << lucas_before << endl;
		return 0;
	}
	if (n == 1)
	{
		cout << lucas_after << endl;
		return 0;
	}
	rep(i, n - 2)
	{
		ll temp = lucas_before + lucas_after;
		lucas_before = lucas_after;
		lucas_after = temp;
	}

	cout << lucas_before + lucas_after << endl;
	return 0;
}

Measured memory_bytes: 3600