akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, M) = (NM[0], NM[1]);
        var AB = Enumerable.Range(0, M).Select(i => ReadLine().Split(' ')).Select(s => (A: int.Parse(s[0]) - 1, B: int.Parse(s[1]) - 1)).ToArray();

        var adjacencyList = new HashSet<int>[N];
        for (int i = 0; i < adjacencyList.Length; i++)
            adjacencyList[i] = new HashSet<int>();

        for (int i = 0; i < M; i++)
        {
            var (A, B) = AB[i];
            adjacencyList[A].Add(B);
            adjacencyList[B].Add(A);
        }

        var gCount = 0;

        var visited = new int[N];
        for (int i = 0; i < visited.Length; i++)
            visited[i] = -1;

        for (int i = 0; i < N; i++)
        {
            if (visited[i] != -1)
                continue;

            gCount++;

            var q = new Queue<int>();

            var v = i;
            visited[v] = gCount;
            q.Enqueue(v);

            while (0 < q.Count)
            {
                v = q.Dequeue();

                foreach (var next in adjacencyList[v])
                {
                    if (visited[next] == -1)
                    {
                        visited[next] = gCount;
                        q.Enqueue(next);
                    }
                }
            }
        }

        var ans = visited.GroupBy(x => x).Select(g => g.Count()).Max();

        WriteLine(ans);
    }
}


Measured memory_bytes: 77572
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
const int INF=99999;

bool check(string s,string t)
{
    for(int i=0;i<s.size();i++){
        if(s.at(i)!=t.at(i))return false;
    }
    return true;
}
int main()
{
    string s,t;
    int n,mn=200;
    cin >> n;
    cin >> s >> t;
    for(int i=0;i<n;i++){
        int sz=s.size();
        if(check(s,t)){
            mn=min(mn,n*2-sz);
        }
        s.erase(s.begin());
    }
    if(mn==200)mn=2*n;
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Double> aList = new ArrayList<>();
		
		for(int i = 1; i <= N; i++) {
			aList.add(sc.nextDouble());
		}
		
		//　昇順でソート
		Collections.sort(aList);

		//　前から順に合成
		double ans = aList.get(0);
		for(int i = 1; i < aList.size(); i++) {
			ans = (ans + aList.get(i)) / 2;
		}

		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 25044
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var n = input[0];
        var m = input[1];

        var array = new List<int>();

        for (int i = 0; i < n; i++)
        {
            var inp = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            foreach (var item in inp.Skip(1))
            {
                array.Add(item);
            }
        }

        var count = 0;

        var targets = new HashSet<int>(array);

        foreach (var target in targets)
        {
            if (array.Where(x => x == target).Count() == n)
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13652
parseInt(x::SubString{String}) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,hp = readline() |> split |> parseMap
	x = Array{Int}(2,n)
	maxa = 0
	for i in 1:n
		x[:,i] = readline() |> split |> parseMap
		maxa = max(maxa,x[1,i])
	end
	useb = Int[]
	for i in 1:n
		if x[2,i] > maxa
			push!(useb, x[2,i])
		end
	end
	useb = sort(useb, rev=true)
	count = 0
	for i in 1:length(useb)
		if hp > 0
			hp -= useb[i]
			count += 1
		end
	end
	if hp > 0
		if hp%maxa == 0
			count += div(hp, maxa)
		else
			count += div(hp, maxa)+1
		end
	end
	print(count)
end

main()

Measured memory_bytes: 176044
n = int(input())
ary = list(map(int, input().split()))
cnt = 0

for i in range(n-1):
  minj = i #0
  for j in range(i, n):
    if (ary[j] < ary[minj]):
      minj = j
  ary[i], ary[minj] = ary[minj], ary[i]
  if (i != minj): cnt += 1

print(' '.join(map(str, ary)))
print(cnt)



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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

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

    int n;  cin >> n;

    if (n < 2)  {
        cout << 0;
        return  0;
    }

    int L = 1e9;
    int R = 0;

    vector<ii>  P;

    for(int i = 0 ; i < n ; ++i)    {
        int x;  cin >> x;
        int y;  cin >> y;

        if (x > y)  swap(x,y);

        L = min(L,x);
        R = max(R,y);

        P.pb(ii(x,y));
    }

    int Rmin = L, Rmax = 0;
    int Bmax = R, Bmin = 1e9;

    for(int i = 0 ; i < n ; ++i)    {
        Rmax = max(Rmax,P[i].X);
        Bmin = min(Bmin,P[i].Y);
    }
    ll  ans = 1ll * (Rmax - Rmin) * (Bmax - Bmin);

    sort(all(P));

    multiset<int> S;

    for(ii  A : P)
        S.insert(A.X);

    ans = min(ans,1ll * (R - L) * (P[n - 1].X - P[0].X));

    for(ii  A : P)  {
        S.erase (S.find(A.X));
        S.insert(A.Y);

        ans = min(ans,1ll * (R - L) * ((*--S.end()) - (*S.begin())));
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const int INF = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	int ans = 0;
	rep(i, N) {
		int l, r;
		cin >> l >> r;
		ans += -l + r + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * Created by abhishek on 8/12/2016.
 */
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args)throws Exception {
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       String str = br.readLine();
        boolean flag = false;
        int pos = -1;
        for(int i = 1;i < str.length();i++) {
            if (str.charAt(i) == str.charAt(i - 1)) {
                flag = true;
                pos = i + 1;
            }
        }
        if(flag){
            System.out.println((pos - 1) + " " + pos);
            return;
        }
        for(int i = 2;i < str.length();i++) {
            if (str.charAt(i) == str.charAt(i - 1) || str.charAt(i - 1) == str.charAt(i - 2) ||
                    str.charAt(i - 2) == str.charAt(i)) {
                flag = true;
                pos = i + 1;
            }
        }
        if(flag)System.out.print((pos - 2) + " " + pos);
        else System.out.println("-1 -1");

    }
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

void solve(int n,int m){


}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  VLL h(10000);
  VLL w(10000);
  map<ll,int> hmp;
  map<ll,int> wmp;

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


    rep(i,n) cin >> h[i];
    rep(i,m) cin >> w[i];


    VLL sumH(n);
    rep(i,n) sumH[i] = h[i];
    rep(i,n-1) sumH[i+1] += sumH[i];
    rep(i,n)FOR(j,i,n){
      if(i-1 >= 0) hmp[sumH[j] - sumH[i-1]]++;
      else hmp[sumH[j]]++;
    }

    VLL sumW(m);
    rep(i,m) sumW[i] = w[i];
    rep(i,m-1) sumW[i+1] += sumW[i];
    rep(i,m)FOR(j,i,m){
      if(i-1 >= 0) wmp[sumW[j] - sumW[i-1]]++;
      else wmp[sumW[j]]++;
    }
    ll ans = 0;
    for(auto a: hmp){
      if(wmp[a.first] > 0){
        ans += a.second * wmp[a.first];
      }
    }
    cout << ans << endl;
    hmp.clear();
    wmp.clear();
  }
  return 0;
}



Measured memory_bytes: 44732
import java.util.*;
public class Main {
	static String[] s;
	public static boolean isok(int i) {
		if(s[i].equals("A") || s[i].equals("G") || s[i].equals("C") || s[i].equals("T"))
			return true;
		else
			return false;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		s = S.split("");
		int answer = 0;
		int[] ans = new int[s.length];
		for(int i = 0; i < s.length; i++) {
			if(isok(i)) {
				answer += 1;
				ans[i] = answer;
			}
			else {
				ans[i] = answer;
				answer = 0;
			}
		}
		answer = 0;
		for(int i = 0; i < s.length; i++) 
			if(answer < ans[i]) answer = ans[i];
		System.out.println(answer);
	}

}

Measured memory_bytes: 23252
#include <stdio.h>
 
int main(void){
  int i,j,n,taro_p=0,hana_p=0;
  char taro[101], hana[101];
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++){
    scanf("%s %s", taro, hana);
 
    for(j=0;;j++){
      if(taro[j] > hana[j]){
        taro_p += 3;
        break;
      }else if(taro[j] < hana[j]){
        hana_p += 3;
        break;
      }else if(taro[j] + hana[j] == 0){
        hana_p++;
        taro_p++;
        break;
      }
    }
  }
 
  printf("%d %d\n", taro_p , hana_p);
  return 0;
}
   
      


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

namespace io {
char buf[1<<21], *p1 = buf, *p2 = buf;
inline char gc() {
    if(p1 != p2) return *p1++;
    p1 = buf;
    p2 = p1 + fread(buf, 1, 1 << 21, stdin);
    return p1 == p2 ? EOF : *p1++;
}
#define G gc

#ifndef ONLINE_JUDGE
#undef G
#define G getchar
#endif

template<class I>
inline void read(I &x) {
    x = 0; I f = 1; char c = G();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = G(); }
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = G(); }
    x *= f;
}

template<class I>
inline void write(I x) {
    if(x == 0) {putchar('0'); return;}
    I tmp = x > 0 ? x : -x;
    if(x < 0) putchar('-');
    int cnt = 0;
    while(tmp > 0) {
        buf[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while(cnt > 0) putchar(buf[--cnt]);
}

#define in(x) read(x)
#define outn(x) write(x), putchar('\n')
#define out(x) write(x), putchar(' ')

} using namespace io;

#define ll long long
const int N = 200010;

int n, a[N], b[N];

int main() {
	read(n);
	int ans = 0;
	for(int i = 1; i <= n; ++i) read(a[i]);
	for(int i = n; i; --i) {
		int tot = 0;
		for(int j = i; j <= n; j += i) tot = (tot + b[j]) % 2;
		if(tot != a[i]) b[i] = 1, ++ans;
	}
	outn(ans);
	for(int i = 1; i <= n; ++i) if(b[i]) printf("%d ", i);
}

Measured memory_bytes: 2432
#include <stdio.h>
#define abs(x) ((x) > 0 ? (x) : -(x))
#define neg(x) (((x) == 1) ? 1 : -1)
#define ptc(x) (*st ++ = (x), (__builtin_expect(st == ed, false) && (fwrite(outbuf, 100000, 1, stdout), st = outbuf)))

int main() {
	static char outbuf[100000];
	register char *st = outbuf, *ed = outbuf + 100000;
	long long k, x, y;
	scanf("%lld\n%lld %lld", &k, &x, &y);
	if (!(k & 1) && (x + y & 1))
		return puts("-1") & 0;
	static int sz = 0;
	static int ansx[239017];
	static int ansy[239017];
	long long px = 0, py = 0;
	while (abs(px - x) + abs(py - y) > k * 2) {
		if (abs(px - x) > k) px += (px > x) ? -k : k;
		else py += (py > y) ? -k : k;
		ansx[++ sz] = px, ansy[sz] = py;
	}
	if (abs(px - x) + abs(py - y) != k) {
		if ((k & 1) && (x - px + y - py & 1)) {
			if (abs(py - y) <= k) {
				px += (k - abs(py - y)) * neg(px < x);
				py = y;
			}
			else {
				py += (k - abs(px - x)) * neg(py < y);
				px = x;
			}
			ansx[++ sz] = px, ansy[sz] = py;
		}
		long long t = k * 2 - abs(px - x) - abs(py - y) >> 1;
		if (abs(px - x) < abs(py - y))
			if (px <= x) {
				ansx[++ sz] = x + t;
				ansy[sz] = py + (k - (x + t - px)) * neg(py < y);
			}
			else {
				ansx[++ sz] = x - t;
				ansy[sz] = py + (k - (px + t - x)) * neg(py < y); 
			}
		else
			if (py <= y) {
				ansy[++ sz] = y + t;
				ansx[sz] = px + (k - (y + t - py)) * neg(px < x);
			}
			else {
				ansy[++ sz] = y - t;
				ansx[sz] = px + (k - (py + t - y)) * neg(px < x);
			}
	}
	ansx[++ sz] = x, ansy[sz] = y;
	const static int ssz = sz;
	register char stk[20], top = 0;
	while (sz) stk[top++] = sz % 10, sz /= 10;
	while (top--) ptc(stk[top] + 48); ptc('\n');
	for (int i = 1; i <= ssz; ++i) {
		if (!ansx[i]) ptc('0');
		else {
			if (ansx[i] < 0) ptc('-'), ansx[i] = -ansx[i];
			top = 0;
			while (ansx[i]) stk[top++] = ansx[i] % 10, ansx[i] /= 10;
			while (top--) ptc(stk[top] + 48);
		}
		ptc(' ');
		if (!ansy[i]) ptc('0');
		else {
			if (ansy[i] < 0) ptc('-'), ansy[i] = -ansy[i];
			top = 0;
			while (ansy[i]) stk[top++] = ansy[i] % 10, ansy[i] /= 10;
			while (top--) ptc(stk[top] + 48);
		}
		ptc('\n');
	}
	if (st != outbuf)
		fwrite(outbuf, st - outbuf, 1, stdout);
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long A, long long B){
	ll res = 0;
	REP(i, 2) {
		if (A>B) {
			res += A;
			A--;
		} else {
			res += B;
			B--;
		}
	}
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
string S;






int main()
{

	cin >> S;
	S[3] = '8';

	cout << S;



}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B, C;

int main()
{
  std::cin >> A >> B >> C;

  std::cout << std::max( 0ll, B+C-A ) << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
 
int main() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (M1 == M2) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=2e6+5;
const int mod=998244353;
ll qpow(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1)ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
ll w[N],cnt[N];
int main()
{
    int n;
    ll t,m=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&t);
        cnt[t]++;
        m=max(m,t);
    }
    for(ll i=1;i<=m;i++)
    {
        w[i]=(w[i]+qpow(i,mod-2))%mod;
        for(ll j=i*2;j<=m;j+=i)
        {
            w[j]=(w[j]-w[i]+mod)%mod;
        }
    }
    ll ans=0;
    for(ll i=1;i<=m;i++)
    {
        ll sum=0;
        ll ssum=0;
        for(ll j=i;j<=m;j+=i)
        {
            sum=(sum+cnt[j]*j%mod)%mod;
            ssum=(ssum+cnt[j]*j%mod*j%mod)%mod;
        }
        ll c=(sum*sum%mod-ssum+mod)%mod*w[i]%mod;
        ans=(ans+c)%mod;
    }
    cout<<ans*qpow(2,mod-2)%mod<<endl;
    return 0;
}


Measured memory_bytes: 18688
str_s = STDIN.gets
int_s = str_s.to_i
h = int_s / 3600
mod_1 = int_s % 3600
m = mod_1 / 60
s = mod_1 % 60
print h.to_s + ":" + m.to_s + ":" + s.to_s + "\n"

Measured memory_bytes: 8644
# -*- coding: utf-8 -*-
import sys


def main():
    inputStr = sys.stdin.read()
    lines = inputStr.split("\n")
    text, word = lines[0], lines[1]
    word_length = len(word)
    for i in range(len(text) - word_length + 1):
        if word == text[i:(i + word_length)]:
            print(i)


if __name__ == '__main__':
    main()



Measured memory_bytes: 7852
#include <bits/stdc++.h>
using namespace std;
#define eni(x) template < class c > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; return * this; }
eni(==) return * this << range(begin(i), end(i)); }
template < class c, class b > debug & operator <<(pair < b, c > d) {
  return * this << "(" << d.first << ", " << d.second << ")";
}
template < class c > debug & operator <<(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  return * this << "]";
}
#else
template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000050
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(auto& x: a) cin>>x;
    for(auto& x: b) cin>>x;
    reverse(all(b));
    int s=0,t=n-1;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]){
            if(b[s]!=a[i] && a[s]!=b[i]){
                swap(b[s],b[i]);
                s++;
            }
            else{
                swap(b[t],b[i]);
                t--;
            }
        }
    }
    bool valid=1;
    for(int i=0;i<n;i++){
        if(a[i]==b[i]){
            valid=0;
            break;
        }
    }
    if(!valid) cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        for(int i=0;i<n;i++) cout<<b[i]<<" ";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 4840
#133_D
n=int(input())
a=list(map(int,input().split()))

d_all=sum([a[i] for i in range(n)])
x=sum([2*a[i] for i in range(1,n,2)])

ans=[0]*n
ans[0]=d_all-x
for i in range(1,n):
    ans[i]=2*a[i-1]-ans[i-1]
print(*ans)

Measured memory_bytes: 14152
import sys
import collections
import itertools
import math
import re
from collections import deque

MOD = 10 ** 9 + 7

N = int(input())
A = [int(x) for x in input().split()]
A.sort()

B = []
if N % 2 == 0:
    for i in range(1, N, 2):
        B.append(i)
        B.append(i)
else:
    B.append(0)
    for i in range(2, N, 2):
        B.append(i)
        B.append(i)

if A == B:
    print(2 ** (N // 2) % MOD)
else:
    print(0)


Measured memory_bytes: 14324
#include <iostream>
using namespace std;
int main(){
int a,b,c,d,e,f;
cin >>a>>b>>c>>d>>e>>f;
if(a+5*b+c*10+d*50+e*100+f*500>999) cout << "1\n";
else  cout << "0\n";
return 0;
}

Measured memory_bytes: 1124
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{	
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
         StringBuilder sb=new StringBuilder();
         BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
         String s1=s.nextLine(),t1=s.nextLine();
         int n=s1.length(),m=t1.length();
        int[][] dp=new int[n+1][m+1];
        for(int i=1;i<=n;i++){
            char c1=s1.charAt(i-1);
            for(int j=1;j<=m;j++){
                char c2=t1.charAt(j-1);
                if(c1==c2){
                    dp[i][j]=dp[i-1][j-1]+1;
                }
                else{
                    dp[i][j]=Math.max(dp[i][j-1],dp[i-1][j]);
                }
            }
        }
         /*for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++){
                System.out.print(dp[i][j]+" ");
            }
            System.out.println();
        }*/
         int i=n,j=m,idx=dp[n][m];
            while(i>0 && j>0) {
                if(s1.charAt(i-1)==t1.charAt(j-1)) {
                    sb.insert(0,s1.charAt(i-1));
                    i--;
                    j--;
                    idx--;
                }
                else {
                    if(dp[i-1][j]>dp[i][j-1]) i--;
                    else j--;
                }
            }
        System.out.println(sb);
        }
    }


Measured memory_bytes: 81340
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a,b) memset((a),(b),sizeof(a))
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define LL long long
#define U unsigned

LL a[10];

inline LL removeMod(LL v) {
	return (v - (v % 2));
}

int main()
{
#ifdef Fcdkbear
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
        double beg = clock();
#endif

        FOR(i,0,7) {
        	cin >> a[i];
        }
        LL res = 0;
        LL res1 = removeMod(a[0]) + a[1] + removeMod(a[3]) + removeMod(a[4]);
        res = max(res, res1);
        if ((a[0] > 0) && (a[3] > 0) && (a[4] > 0)) {
        	LL res2 = 3;
        	res2 += removeMod(a[0] - 1) + a[1] + removeMod(a[3] - 1) + removeMod(a[4] - 1);
        	res = max(res, res2);
        }
        cout << res << endl;


#ifdef Fcdkbear
        double end = clock();
        fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
        return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   int x,y;
   cin>>x>>y;
   ll m=1;
   for (int i=1;i<x;i++){
    m*=(y-1);
   }
   printf("%d\n",m*y);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    std::string s,t;std::cin>>s>>t;
    int x=std::stoi(s+t);
    int y=std::sqrt(x);
    std::cout<<(x==y*y?"Yes":"No")<<std::endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == b{
		for i:=0; i<a; i++{
			fmt.Print(a)
		}
	}else if a > b{
		for i:=0; i<a; i++{
			fmt.Print(b)
		}
	}else{
		for i:=0; i<b; i++{
			fmt.Print(a)
		}
	}
	fmt.Println()
}

Measured memory_bytes: 1832
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;
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; }

template<typename T>
vector<bool> sieve_of_eratosthenes(T range) {
    vector<bool> isPrime(range, true);
    isPrime[0] = false;
    isPrime[1] = false;
    for (ll i = 2; i < sqrt(range); ++i)
    {
        for (ll j = 2; i * j < range; ++j)
        {
            ll target = i * j;
            isPrime[target] = false;
        }
    }
    return std::move(isPrime);
}

template<typename T>
vector<T> get_all_primes(T range) {
    vector<bool> isPrime = sieve_of_eratosthenes(range);
    vector<T> primes;
    for (ll i = 0; i < range; ++i)
    {
        if (isPrime[i]) {
            primes.emplace_back(i);
        }
    }
    return std::move(primes);
}

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

    ll n;
    cin >> n;
    
    auto primes = get_all_primes(1e5 + 100);
    
    cout << *lower_bound(primes.begin(), primes.end(), n) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main() {
	char str[1200] = "";
	fgets(str, sizeof(str), stdin);

	for (int i = 0; i < strlen(str); i++) {
		if (str[i] < 91) {
			str[i] = tolower(str[i]);
		}
		else {
			str[i] = toupper(str[i]);
		}
	}

	printf("%s", str);
	return 0;
}

Measured memory_bytes: 1780
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int sum = a;
    int max = a;
    int b = sc.nextInt();
    sum += b;
    max = Math.max(max, b);
    int c = sc.nextInt();
    sum += c;
    max = Math.max(max, c);
    System.out.println(sum - max);

  }
}

Measured memory_bytes: 35536
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>=n;i--)
#define INF 999999999
#define pb(a) push_back(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<pii> VP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
    int puz[10][5] = {};
    bool isdelete[10][5];
    int n;
    while(cin >> n) {
        if(n == 0) break;
        rep(i,0,n) {
            rep(j,0,5) cin >> puz[n-1-i][j];
        }

        /*rep(i,0,n) {
            rep(j,0,5) cout << puz[i][j] << " ";
            cout << endl;
        }*/

        int x = 0;
        int cnt = 1;
        bool flag;
        int ret = 0;
        int temp = 0;
        while(1) {
            rep(i,0,n) {
                rep(j,0,5) {
                    isdelete[i][j] = false;
                }
            }

            rep(i,0,n) {
                rep(j,0,5) {
                    if(puz[i][j] == x && x != 0) cnt++;
                    else {
                        cnt = 1;
                        x = puz[i][j];
                    }

                    if(cnt >= 3) {
                        //cout << "true" << endl;
                        flag = true;
                        rep(k,j-cnt+1,j+1) isdelete[i][k] = true;
                        temp = cnt * x;
                    }
                }
                ret += temp;
                x = 0;
                cnt = 1;
                temp = 0;
            }
            if(!flag) break;
            rep(i,0,n) {
                rep(j,0,5) {
                    if(isdelete[i][j]) puz[i][j] = 0;
                }
            }

            rep(i,0,n) {
                rep(j,0,5) {
                    int k = i;
                    while(k>=1 && puz[k-1][j] == 0) {
                        puz[k-1][j] = puz[k][j];
                        puz[k][j] = 0;
                        k--;
                    }
                }
            }

            /*cout << endl;
            rep(i,0,n) {
                rep(j,0,5) cout << puz[n-1-i][j] << " ";
                cout << endl;
            }*/

            flag = false;
        }

        cout << ret << endl;
        ret = 0;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
struct compare
{
    bool operator()(const string& first, const string& second)
    {
        return first.size()>second.size();
    }
};
void solve()
{

    long long  k,x;
    cin>>k>>x;
    for(int i=x-k+1; i<=(x+k-1); i++)
    {
        cout<<i<<" ";
    }

}

int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
}



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

typedef long long s64;

const int MaxN = 100000;

int n;
int a[MaxN + 1];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];

	s64 l = 2, r = 2;
	for (int i = n; i >= 1; --i)
	{
		s64 x = a[i] * ((l - 1) / a[i] + 1);
		s64 y = a[i] * ((r - 0) / a[i]);
		if (x > y)
		{
			cout << -1 << endl;
			return 0;
		}

		l = x;
		r = y + a[i] - 1;
	}

	cout << l << ' ' << r << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
using P = pair<int,int>;
#define MOD 1000000007

/*
操作をM回数繰り返す
A[N]との比較をするので多分O(N*M)とかになって
TLEになってしまう・・・

まずは普通に書いてみる

途中でpqを使えばいいのでは？？？と思いつく
→例は全部おk
えーTLE・・・・・・・・・・
O(N*B[N])=O(N^2)=O(10^10)になっちゃってた

mapを使えば入力の時にB[N]回数省略できるのでは？？？
*/

int main()
{
  //input
  ll N,M;cin>>N>>M;
  vector<ll> A(N+1);
  vector<ll> B(M+1),C(M+1);
  map<ll, ll, greater<ll>> mp;
  
  for (int i=1;i<=N;i++)
  {
    cin>>A[i];
    mp[A[i]]++;
  }
 
  for (int i=1;i<=M;i++)
  {
    cin>>B[i]>>C[i]; 
  }
  
  for (int m=1;m<=M;m++)
  {
    //B[m]回のCmをmに入れていく
    mp[C[m]] += B[m];
  }
  
  //大きい方からN個の和が最大値
  ll sum=0;
  ll count=0;
  
  for (auto i=mp.begin();i!=mp.end();i++)
  {
    while (i->second >0)
    {
      if (count==N)
      {
        cout<<sum<<endl;
        return (0);
      }
      sum += i->first;
      i->second--;
      count++;
    }
  }
  
  cout<<sum<<endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,v) for(auto it : v)

using namespace std;

int n,ans;
string S;
bool dp[30009][4][1009];

main()
{
        cin>>n>>S;
        dp[0][0][0]=true;

        rep(i,n)
        {
                rep(j,4)
                {
                        rep(k,1000)
                        {
                        if(dp[i][j][k]==false)continue;

                        if(j<3)dp[i+1][j+1][k*10+S[i]-'0']=true;
                        dp[i+1][j][k]=true;
                        }
                }
        }

        each(it,dp[n][3])ans+=it;
        cout<<ans<<endl;
}

Measured memory_bytes: 118528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<bool> good = vector<bool>(n, true);
    rep(i, m) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        if(h[a] <= h[b]) good[a] = false;
        if(h[a] >= h[b]) good[b] = false;
    }
    int ans = 0;
    rep(i,n) if(good[i]) ans++;
    cout << ans << endl;
}

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

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

    int ans = 100100;
    for(char ch = 'a'; ch <= 'z'; ch++){
        string s1 = s;
        for(int count = 0; count <= s1.length(); count++){
            bool isok = true;
            for(int i = 0; i < s1.length()-count; i++){
                if(s1[i] != ch) isok = false;
            }
            if(isok){
                if(ans > count) ans = count;
            }
            for(int i = 0; i < s1.length(); i++){
                if(s1[i] == ch && i-1 >= 0) s1[i-1] = s1[i];
            }
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(){
    int n,ans=1;
    scanf("%d",&n);
    int h[n];
    scanf("%d",&h[0]);
    int max=h[0],min=h[0];
    for(int i=1;i<n;i++){
        scanf("%d",&h[i]);
        if(h[i-1]-h[i] > 1){
            ans=0;
            break;
            
        }
        if(h[i]>max) max=h[i];
        if(max-h[i] > 1){
            ans=0;
            break;
            
        }
    }
    if(ans==1) printf("Yes");
    else printf("No");
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
const int MAX = 200005;
using namespace std;
int main()
{
    int a[MAX];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int maxv = a[1]-a[0];
    int mina = a[0];
    for(int i=1;i<n;i++)
    {
        maxv = max(maxv,a[i]-mina);
        mina = min(a[i],mina);
    }
    cout<<maxv<<endl;
    return 0;
}

Measured memory_bytes: 3828
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);

    vector<long>  a(m), b(m);
    set<long> xx;
    long i;
    for(i=0; i<m; i++) {
        scanf("%ld%ld", &a[i], &b[i]);
        if(a[i]==1) {
            xx.insert(b[i]);
        }
    }
    for(i=0; i<m; i++) {
        if(b[i]==n) {
            if(xx.find(a[i])!=xx.end()) {
                printf("POSSIBLE\n"); return 0;
            }
        }
    }

    printf("IMPOSSIBLE\n");

    return 0;
}


Measured memory_bytes: 8064
#include<stdio.h>
int main()
{
  int i,a[3],b,c,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  b=a[0];
  for(i=1;i<n;i++){
    if(a[i]<b)b=a[i];
  }
  for(i=1;i<b;i++){
    if(n==2){
      if(a[0]%i==0&&a[1]%i==0){
	printf("%d\n",i);
      }
    }
    else{
      if(a[0]%i==0&&a[1]%i==0&&a[2]%i==0){
	printf("%d\n",i);
      }
    }
  
  }
  return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

const int N = 2e3 + 10;

bool dp[3][3][N];
string s[3];
int len[3];
int tot = 0;
int ans = MOD;

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

    cin >> s[0] >> s[1] >> s[2];
    len[0] = s[0].length();
    len[1] = s[1].length();
    len[2] = s[2].length();
    tot = len[0] + len[1] + len[2];

    for (int i=0;i<3;i++){
        for (int j=0;j<3;j++){
            if (i == j) continue;
            for (int k=0;k<=len[i];k++){
                bool bisa = 1;
                int id2 = -1;
                for (int id1=k;id1<len[i];id1++){
                    id2++;
                    if (id2 >= len[j]) break;
                    if (s[i][id1] == s[j][id2] || s[i][id1] == '?' || s[j][id2] == '?') continue;
                    bisa = 0;
                    break;
                }
                dp[i][j][len[i] - k] = bisa;
            }
            dp[i][j][0] = 1;
        }
    }
    
    for (int id1=0;id1<3;id1++){
        for (int id2=0;id2<3;id2++){
            if (id1 == id2) continue;
            int id3 = 0;
            if (id3 == id1 || id3 == id2) id3++;
            if (id3 == id1 || id3 == id2) id3++;

            for (int i=0;i<=len[id1];i++){
                for (int j=i;j<=4001;j++){
                    if (dp[id1][id2][len[id1] - i] && dp[id2][id3][max(0, len[id2] - j + i)] && dp[id1][id3][max(0, len[id1] - j)]){
                        ans = min(ans, max(len[id1], max(len[id2] + i, len[id3] + j)));
                    }
                }
            }
        }
    }
    if (ans != MOD) cout << ans << el;
    else cout << tot << el;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
  int h,i,A[MAX+1];

  scanf("%d",&h);
  for(i=1;i<=h;i++)scanf("%d",&A[i]);

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<= h) printf("left key = %d, ",A[left(i)]);
    if(right(i)<= h) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------
ll n;
ll x[50], y[50];

ll simulate(ll p, ll q) {
    ll cnt = n;

    rep(i, n) rep(j, n) {
        if (i == j) continue;
        if (x[i] - x[j] == p && y[i] - y[j] == q) cnt--;
    }
    return cnt;
}

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

    cin >> n;
    rep(i, n) cin >> x[i] >> y[i];
    ll ans = LINF;
    if (n == 1) ans = 1;

    rep(i, n) rep(j, n) {
        if (i == j) continue;
        ll p = x[i] - x[j];
        ll q = y[i] - y[j];
        ans = min(ans, simulate(p, q));
    }

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



Measured memory_bytes: 256
import sys
N, M = map(int, input().split())
ls = []
for i in range(M):
    ls.append(list(map(int, input().split())))

if M == 0 and N == 1:
    print(0)
    sys.exit()
elif M == 0 and N != 1:
    print('1' + '0'*(N-1))
    sys.exit()

for x in range(1000):
    if len(str(x)) == N:
        cur = 0
        for i in range(M):
            if str(ls[i][1]) == str(x)[ls[i][0] - 1]:
                cur += 1
                if cur == M:
                    print(x)
                    sys.exit()
print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    int s,w;cin >> s >> w;
    if(s <= w) puts("unsafe");
    else puts("safe");
    return 0;
}


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

using namespace std ;

#define N  100010

int n , L , m ;
int a[ N ] , to[ N ] ;
int num , block , belong[ N ] ; 
int nxt[ N ] , val[ N ] ;

int find( int x ) {
    int l = x + 1 , r = n , ans = 0 ;
    while( l <= r ) {
        int mid = ( l + r ) >> 1 ;
        if( a[ mid ] - a[ x ] <= L ) l = mid + 1 , ans = mid ;
        else r = mid - 1 ;
    }
    return ans ;
}

int main() {
    scanf( "%d" , &n ) ;
    for( int i = 1 ; i <= n ; i ++ ) {
        scanf( "%d" , &a[ i ] ) ;
    }
    sort( a + 1 , a + n + 1 ) ;
    scanf( "%d%d" , &L , &m ) ;
    for( int i = 1 ; i < n ; i ++ ) {
        to[ i ] = find( i ) ;
    }
    to[ n ] = n + 1 ;
    block = sqrt( n ) ;
    num = n / block ;
    if( n % block ) num ++ ;
    for( int i = 1 ; i <= n ; i ++ ) {
        belong[ i ] = ( i - 1 ) / block + 1 ;
    }
    for( int i = 1 ; i < n ; i ++ ) {
        int t = i , sp = 0 ;
        while( belong[ t ] == belong[ i ] ) {
            t=to[ t ] ;
            sp ++ ;
        }
        val[ i ] = sp ;
        nxt[ i ] = t ;
        if( i >= block * ( num - 1 ) + 1 ) val[ i ] -- , nxt[ i ] -- ;
    }
    for( int i = 1 ; i <= m ; i ++ ) {
        int x , y  , ans = 0 ;
        scanf( "%d%d" , &x ,&y ) ;
        if( x > y )swap( x , y ) ;
        while( belong[ x ] < belong[ y ] ) {
            ans += val[ x ] ;
            x = nxt[ x ] ;
        }
        while( x < y ) {
            x = to[ x ] ;
            ans ++ ;    
        } 
        printf( "%d\n" , ans  ) ;
    }
    return 0 ;
}

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

typedef long long ll;


int N, W;
ll v[110];
ll w[100010];
ll dp[110][100010];


int main(){

    cin >> N >> W;
    for(int i = 1; i <= N; i++){
        cin >> w[i] >> v[i];
    }

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= W; j++){
            if(j < w[i]){
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                continue;
            }

            dp[i][j] = max(dp[i-1][j - w[i]] + v[i], dp[i-1][j]);
        }
    }

    // for(int i = 1; i <= N; i++){
    //     for(int j = 1; j <= W; j++){
    //         cout << dp[i][j] << " ";
    //     }

    //     cout << endl;
    // }

    cout << dp[N][W] << endl;

    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  long double N, K;
  cin >> N >> K;
  long double sum = 0;
  for(int i = 1; i <= N; i++){
    if(i >= K){
      sum += (1.0/N);
    } else{
      int kaisuu = 0;
      int k = K;
      int t = i;
      while(t < k){
        t *= 2;
        kaisuu++;
      }
      sum += (1.0 / N) * pow(0.5, kaisuu);
    }
  }
  cout << sum <<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0;
    string S;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == '+'){
            cnt++;
        }else{
            cnt--;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

void push(int);
int pop(void);

int top,sta[1000];

int main()
{
  int a,b,i;
  top=0;
  char c[100];

  i=0;
  while(scanf("%s",c) != EOF)
    {
      if(c[0]=='+')
	{
	  a=pop();
	  b=pop();
	  push(a+b);
	}
      else if(c[0]=='-')
	{
	  a=pop();
	  b=pop();
	  push(b-a);
	}
      else if(c[0]=='*')
	{
	  a=pop();
	  b=pop();
	  push(a*b);
	}
      else
	{
	  push(atoi(c));
	}
      i++;
    }

  printf("%d\n",pop());
  return 0;
}

void push(int c)
{
  sta[++top]=c;
}

int pop(void)
{
  top--;
  return sta[top+1];
}



Measured memory_bytes: 2100
/**
 * @author: shashankchdhry
 * @made:   2020-04-02 20:34:32 
**/
#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    int temp = 0;
    int mx = 0;
    for (auto i:s)
    {
        if (i == 'I')
            temp++;
        else
            temp--;
        mx = max(mx, temp);
    }

    cout << mx << "\n";

    return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 

int main(){

int N, K;
cin >> N >> K;
int X, Y;
cin >> X >> Y;

int Z = max(0, (N - K));
int ans = X * min(N, K) + Y * Z;
print(ans);

}

Measured memory_bytes: 256
h, w = map(int, input().split())

A = []
A.append(['.'] * (w + 2))
for i in range(h):
    A.append(['.'] + list(input()) + ['.'])
A.append(['.'] * (w + 2))

ans = 'Yes'

for i in range(1, h - 1):
    for j in range(1, w - 1):
        if A[i][j] == '#':
            if A[i - 1][j] == '#' or A[i +1][j] == '#' or A[i][j + 1] == '#' or A[i][j - 1] == '#':
                continue
            else:
                ans = 'No'
                break
                
print(ans)

Measured memory_bytes: 3064