akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  long long N, M;
  cin >> N >> M;

  long long n_s = N;
  long long n_c = M;
  if (n_s >= M / 2) {
    cout << M / 2 << endl;
    return 0;
  }
  n_c = n_s * 2;
  M -= n_s * 2;

  cout << n_s + M / 4 << endl;

  return 0;
}

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

int main()
{
  int64_t N;
  cin >> N;
  vector<bool> R(N);
  char c;
  vector<int64_t> Rs(N + 1, 0);
  for (int i = 0; i < N; i++)
  {
    cin >> c;
    R[i] = (c == 'R');
    if (R[i])
    {
      Rs[i + 1]++;
    }
    Rs[i + 1] += Rs[i];
  }
  int64_t ans = Rs[N];
  for (int r = 0; r <= N; r++)
  {
    int64_t lrs = Rs[r];
    int64_t rrs = Rs[N] - Rs[r];
    int64_t lws = r - lrs;
    int64_t tmp = lws + max((int64_t)0, rrs - lws);
    ans = min(tmp, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4836
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

////const long long MOD = 2;
//
void solve(long long N, std::vector<long long> a){
    vec(b,N);
    ll M=0;
    for(ll i=N-1;i>=0;i--){
        ll tmp=0;
        for(ll j=2;;j++){
            if(j*(i+1)<=N){
                tmp+=b[(j*(i+1)-1)];
            }else break;
        }
        b[i]=(tmp%2)^a[i];
        if(b[i]==1)M++;
    }
    op(M);
    rep(i,N){
        if(b[i]==1)op(i+1)
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 3968
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll u(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll d(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll z(ll a){
  if(a<0)return -a;
  return a;
}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll gcd(ll a,ll b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(void){
  int a[4];
  FOR(4)scanf("%d",&a[i]);
  PRN(a[3]==1);
  return 0;
}


Measured memory_bytes: 256
use List::Util qw(max min sum);

my ($n,$m,$x) = split(/\s+/, <>);
my @c;
my @a;

for (1..$n) {
    ($c[$_], @{$a[$_]}) = split(/\s+/, <>);
}

my $ans = sum(@c)+10;
for my $p (1..(1<<$n)-1) {
    #print "pattern=$p\n";
    my @b = ();
    my $sum = 0;
    for my $i (1..$n) {
	if ($p & (1<<($i-1))) {
	    #print $i, " ";
	    $sum += $c[$i];
	    for my $j (1..$m) { $b[$j-1]+=@{$a[$i]}[$j-1]; }
	}
    }
    #print join(" ", @b), "\n";
    if (min(@b)>=$x) {$ans = min($ans, $sum);}
}

if ($ans <= sum(@c)) {
    print $ans, "\n";
} else {
    print "-1\n";
}


Measured memory_bytes: 5444
A, B, C, D = map(int,input().split())

def gcd(x,y):
    if x<y:
        x, y = y, x
    r = x%y
    while r!=0:
        x = y
        y = r
        r = x%y
    return y

def lcm(x,y):
    return (x*y)//gcd(x,y)

L = lcm(C,D)

lenB = B-(B//C+B//D-B//L)
A-=1
lenA = A-(A//C+A//D-A//L)
print(lenB-lenA)

Measured memory_bytes: 61668
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long result = 0;
			int before = 0;
			for (int i = 0; i < n; i++) {
				int tmp = sc.nextInt();
				if (tmp < before) {
					result += before - tmp;
				} else {
					before = tmp;
				}
			}
			System.out.println(result);
		}
	}
}


Measured memory_bytes: 58240
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int x = sc.nextInt(), a = sc.nextInt();
        pw.println(x < a ? 0 : 10);

        pw.close();
    }
}

Measured memory_bytes: 21204
import           Control.Monad
import           Data.List

main :: IO ()
main = do
    [n, m] <- fmap (map read . words) getLine :: IO [Int]
    cs     <- replicateM n $ fmap (map read . words) getLine :: IO [[Int]]
    print . solve m $ cs

solve :: Int -> [[Int]] -> Int
solve m cs = purchase m scs where scs = sort . map (\[a, b] -> (a, b)) $ cs

purchase :: Int -> [(Int, Int)] -> Int
purchase m ((a, b) : cs) =
    if m <= b then m * a else a * b + purchase (m - b) cs
purchase _ [] = 0


Measured memory_bytes: 113148
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する


int main() {
    int n;
    ll k;
    cin >> n >> k;
    ll d = 1;
    REP(i, 0, n) {
        if (d < k) {
            d += d;
        } else {
            d += k;
        }
    }
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)

/////////////////////////////////////////////////////////

ll mypow(int N){
  if(N == 0) return 1;
  if(N == 1) return 2;
  if(N % 2 == 0) return (mypow(N / 2) * mypow(N / 2)) % MOD;
  return (2 * mypow(N - 1)) % MOD;
}

void Main(){
  int N; cin >> N;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];
  sort(all(A));
  if(N % 2 == 1){
    bool ok = true;
    if(A[0] != 0) ok = false;
    rep(i, 1, N){
      if(A[i] != 2 * ((i + 1) / 2)) ok = false;
    }
    if(ok) cout << mypow((N - 1) / 2) << endl;
    else cout << 0 << endl;
  }else{
    bool ok = true;
    rep(i, 0, N){
      if(A[i] != 2 * (i / 2) + 1) ok = false;
    }
    if(ok) cout << mypow(N / 2)  << endl;
    else cout << 0 << endl;
  }
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 640
parseInt(x) = parse(Int128, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
  N = parseInt(readline())
  A = parseMap(split(readline()))
  A = sort(A,rev=true)
  #println(A)
  if N%2==0
    imax=div(N,2)
  else
    imax=div(N,2)+1
  end
  sum = 0
  for i in 1:imax
      if i == 1
        sum += A[i]
      else
        if N%2==0
          sum += 2*A[i]
        else
          if i != imax
            sum += 2*A[i]
          else
            sum += A[i]
          end
        end
      end
  end
  println("$sum")
end
main()


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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int A,B;
   string S;
   cin>>A>>B>>S;
   if(S[A]!='-'){
      cout<<"No";
      return 0;
   }
   for(int i=0;i<A;i++){
      if(0<=S[i]-'0'&&S[i]-'0'<=9){
      }
      else {
         cout<<"No";
         return 0;
      }
   }
   for(int i=A+1;i<S.size();i++){
      if(0<=S[i]-'0'&&S[i]-'0'<=9){
      }
      else {
         cout<<"No";
         return 0;
      }
   }
   cout<<"Yes";
   return 0; 
}


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

	public static void main(String[] args) {
		Main bs = new Main();
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		bs.babble(array);
	}
	public void babble(int[] a) {
		int count = 0;
		for (int j = 1; j < a.length; j++) {

			for (int i = a.length - 1; i >= j; i--) {
				if (a[i] < a[i - 1]) {
					int past = a[i];
					a[i] = a[i - 1];
					a[i - 1] = past;
					count++;
				}
			}
		}
		for(int i = 0; i < a.length; i++) {
			System.out.print (a[i]);
			if (i != a.length - 1) {
				System.out.print(" ");
			}else {
				System.out.println("");
			}
		}
		System.out.println(count);
	}
}



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

int main() {
	int a, b, c, d;;

	cin >> a >> b >> c >> d;

	if (max(a, b) - min(a, b) <= d&&max(b,c)-min(b,c)<=d) {
		cout << "Yes" << endl;
	}
	else if (max(a, c) - min(a, c) <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

int main() {
  vector<int> a(3);
  for (auto &e : a) cin >> e;

  sort(all(a));

  int ans = 0;
  for (int i = 0; i < sz(a) - 1; ++i) {
    ans += a.at(i + 1) - a.at(i);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 2e5 + 10;

pair < LL, LL > a[N], tmp;
LL c[N];
LL dp[100];

bool cmp(pair < LL, LL > A, pair < LL, LL > B) {
    return A.fir * (B.sec + 1) > B.fir * (A.sec + 1);
}

void solve() {

    int n; LL T;
    scanf("%d %lld", &n, &T);
    int cnt1 = 0, cnt2 = 0;
    rep(i, 1, n) {
        scanf("%lld %lld", &tmp.fir, &tmp.sec);
        if(tmp.fir == 0) c[cnt2++] = tmp.sec + 1;
        else a[cnt1++] = tmp;
    }

    sort(c, c + cnt2);
    sort(a, a + cnt1, cmp);

    rep(i, 1, 30) dp[i] = T + 1;
    dp[0] = 0;
    rep(i, 1, cnt2 - 1) c[i] += c[i - 1];

    rep(i, 0, cnt1 - 1) {
        dep(j, 1, 30) {
            dp[j] = min(dp[j], (a[i].fir + 1) * (dp[j - 1] + 1) + a[i].sec);
        }
    }

    int ans = 0;
    rep(i, 0, 30) {
        if(dp[i] > T) continue;
        int add = 0;
        if(cnt2) add = upper_bound(c, c + cnt2, T - dp[i]) - c;
        ans = max(ans, i + add);
    }
    printf("%d\n", ans);
    return ;
}

int main() {

    solve();

    return 0;
}

Measured memory_bytes: 6848
unittest
{
	assert( [ "10 0 15 0 30" ].parse.expand.solve == 270 );
	assert( [ "10 0 12 0 120" ].parse.expand.solve == 0 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hmhmk = input.front.split.to!( long[] );
	return tuple( hmhmk[ 0 .. 2 ], hmhmk[ 2 .. 4 ], hmhmk[ 4 ] );
}

auto solve( long[] hm1, long[] hm2, long k )
{
	auto a = hm1[ 0 ] * 60 + hm1[ 1 ];
	auto b = hm2[ 0 ] * 60 + hm2[ 1 ];
	return b - a - k;
}


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

int main() {
	int n,st[10],max,ans = 0,maxn = 0;
	cin >> n;
	cin >> st[0];
	max = st[0];
	for (int i = 1; i < n; i++) {
		cin >> st[i];
		if (max < st[i]) {
			max = st[i];
			maxn = i;
		}
	}
	for (int i = 0; i < n; i++) {
		if (maxn == i) ans = ans + st[i] / 2;
		else ans = ans + st[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int c1,c2,c3;
    c1=c2=c3=0;
    vi v(n);
    rep(i,n){
        cin>>v[i];
        if(v[i] == 1)c1++;
        else if(v[i] == 2)c2++;
        else c3++;
    }
    double dp[n+10][n+10][n+10];
    rep(i,n+10){
        rep(j,n+10){
            rep(k,n+10){
                dp[i][j][k] = 0;
            }
        }
    }
    rep(k,n+1){
        rep(j,n+1){
            rep(i,n+1){
                if(i == 0 && j == 0 && k == 0)continue;
                if(i + j + k > n)continue;
                double x1 = 1.0*i/(i+j+k);
                double x2 = 1.0*j/(i+j+k);
                double x3 = 1.0*k/(i+j+k);
                double x4 = 1.0*n/(i+j+k);
                if(i){
                    dp[i][j][k] += x1*dp[i-1][j][k];
                }
                if(j){
                    dp[i][j][k] += x2*dp[i+1][j-1][k];
                }
                if(k){
                    dp[i][j][k] += x3*dp[i][j+1][k-1];
                }
                dp[i][j][k] += x4;
                // cout<<i<<" "<<j<<" "<<k<<" "<<x4<<"\n";
            }
        }
    }
    cout<<fixed<<setprecision(12)<<dp[c1][c2][c3];
    return 0;
}

Measured memory_bytes: 232960
_n=gets.to_i
h=Hash.new(0)
res=0
a=gets.split.each_with_object([]) do |e, m|
  i = e.to_i
  m << i
  res+=i
  h[i]+=1
end
q=gets.to_i
q.times do
  b,c = gets.split.map &:to_i 
  if h.key?(b)
    v=h[b]
    if h.key?(c)
      h[c]+=v
    else
      h[c]=v
    end
    dec = v * b
    inc = v * c
    res-=dec unless dec.nil?
    res+=inc unless inc.nil?
    h.delete(b)
  end
  puts res
end


Measured memory_bytes: 25648
// THANK YOU MR SOLVING!!!!!!!!

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using std::sort;
using std::reverse;

using ll = long long;

#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())
#define push_back emplace_back
#define endl '\n'

class solver {
private:
    double TIME;

    static const ll INF = static_cast<ll>(1e9) + 7;
    static const int MAXN = static_cast<ll>(1e6) + 17;
    const int MAGIC = 62;

    int n, m, k;
    vector<string> s;

public:
    static bool FLAG;

    solver() {
        TIME = static_cast<double>(clock()) / CLOCKS_PER_SEC;
    }

    bool read() {
        if (!(cin >> n >> m >> k))
            return false;

        s.resize(n);

        forn (i, n)
            cin >> s[i];

        return true;
    }

    bool valid(int i, int j) {
        return 0 <= i && i < n && 0 <= j && j < m;
    }

    void solve() {
        vector< pair<int, int> > dd = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
        int I, J;

        forn (i, n)
            forn (j, m)
                if (s[i][j] == 'S')
                    I = i, J = j;

        int inf = INF;
        vector< vector<int> > D(n, vector<int>(m, inf));
        std::queue< pair<int, int> > Q;
        D[I][J] = 0;
        Q.push(std::make_pair(I, J));

        while (!Q.empty()) {
            I = Q.front().first;
            J = Q.front().second;
            Q.pop();

            for (auto d : dd)
                if (valid(I + d.first, J + d.second)) {
                    int i = I + d.first;
                    int j = J + d.second;

                    if (D[i][j] != inf || s[i][j] == '#')
                        continue;

                    D[i][j] = D[I][J] + 1;
                    Q.push(std::make_pair(i, j));
                }
        }

        int ans = inf;

        for (int i = 0; i < n; ++i)
            for (int j = 0; j < m; ++j)
                if (D[i][j] != inf) {
                    int t = min({i, j, n - i - 1, m - j - 1});

                    if (D[i][j] < k)
                        ans = min(ans, 1 + (t + k - 1) / k);
                    else
                        ans = min(ans, 1 + (D[i][j] + t - 1) / k);
                }

        cout << ans << endl;
    }

    ~solver() {
#ifdef SEREZHKA
        if (FLAG)
            cerr << "Time elapsed: " << static_cast<double>(clock()) / CLOCKS_PER_SEC - TIME << endl;
#endif
    }
};

bool solver::FLAG = true;

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    cerr << std::fixed << std::setprecision(5);

#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');
#else
    std::mt19937 rand(time(NULL));
#endif

    while (solver::FLAG) {
        solver solution;

        if (!solution.read())
            solver::FLAG = false;
        else
            solution.solve();
    }

    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    bool mn = false, pl = false;
    vector<int> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
        mn |= v[i] < 0;
        pl |= v[i] > 0;

    }

    if(!mn) {
        cout << N - 1 << endl;
        for(int i = 1; i < N; ++i) {
            cout << i << " " << i + 1 << endl;
        }
    } else if(!pl) {
        cout << N - 1 << endl;
        for(int i = N; i > 1; --i) {
            cout << i << " " << i - 1 << endl;
        }
    } else {
        int mxv = 0, mnv = 0;
        int mxpos, mnpos;
        for(int i = 0; i < N; ++i) {
            if(mxv <= v[i]) {
                mxv = v[i];
                mxpos = i + 1;
            }
            if(mnv >= v[i]) {
                mnv = v[i];
                mnpos = i + 1;
            }
        }

        cout << N - 1 + N << endl;
        if(abs(mxv) > abs(mnv)) {
            for(int i = 1; i <= N; ++i) {
                cout << mxpos << " " << i << endl;
            }
            for(int i = 1; i < N; ++i) {
                cout << i << " " << i + 1 << endl;
            }
        } else {
            for(int i = 1; i <= N; ++i) {
                cout << mnpos << " " << i << endl;
            }
            for(int i = N; i > 1; --i) {
                cout << i << " " << i - 1 << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
int INF = 1001001001;

int check(ll a) {
    return to_string(a).size();
} 

int main(){
    ll n;
    cin >> n;
    ll root = sqrt(n);
    int ans = INF;
    for (int i=1; i<=root; i++) {
        if (n%i==0) {
            ll a = i;
            ll b = n/i;
            int f = max(check(a), check(b));
            ans = min(ans, f);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int h, w;
	scanf("%d %d", &h, &w);
	int i, j;
	char s[2003][2003];
	for (i = 0; i < h; i++)
		scanf("%s", s[i]);
	int v[2003][2003];
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			v[i][j] = 0;
	int c;
	for (i = 0; i < h; i++)
	{
		c = 0;
		for (j = 0; j < w; j++)
		{
			if (s[i][j] == '#')
				c = 0;
			else
			{
				v[i][j] += c;
				c++;
			}
		}
	}
	c = 0;
	for (i = 0; i < h; i++)
	{
		c = 0;
		for (j = w - 1; j >= 0; j--)
		{
			if (s[i][j] == '#')
				c = 0;
			else
			{
				v[i][j] += c;
				c++;
			}
		}
	}
	for (j = 0; j < w; j++)
	{
		c = 0;
		for (i = 0; i < h; i++)
		{
			if (s[i][j] == '#')
				c = 0;
			else
			{
				v[i][j] += c;
				c++;
			}
		}
	}
	for (j = 0; j < w; j++)
	{
		c = 0;
		for (i = h - 1; i >= 0; i--)
		{
			if (s[i][j] == '#')
				c = 0;
			else
			{
				v[i][j] += c;
				c++;
			}
		}
	}
	int max = 0;
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			if (v[i][j] > max)
				max = v[i][j];
	printf("%d\n", max + 1);
	return 0;
}

Measured memory_bytes: 19712
#include <iostream>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
int check(int a[200][200],int s,int t,int i,int j){
	int count = 0;
	for(int n = i; n < s + i; n++){
		for(int m = j; m < t + j; m++){
      if(a[n][m] == 1){
				count += 1;
			}
		}
	}
	return count;

}
 void reset(int a[200][200]){
	 for(int i = 0;i < 200; i++){
		 for(int j = 0; j < 200;j++){
			 a[i][j] = 0;
		 }
	 }
 }
      

int main(){
	int n,w,h;
	int a[200][200] = {};
	int x,y,s,t;
	int max = 0;

	while(cin >> n){
		if(n == 0){
			break;
		}
		cin >> w >> h;
		max = 0;
		reset(a);
		for(int i = 0; i < n; i++){
			cin >> x >> y;
			a[x-1][y-1] = 1;
		}
		
		cin >> s >> t;

		for(int i = 0; i < w; i++){
			for(int j = 0;j < h;j++){
				if(max == 0 || max < check(a,s,t,i,j)){
					max = check(a,s,t,i,j);
				}
			}
		}
		cout << max << endl;
	}
}
    



 

Measured memory_bytes: 3144
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args){
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            if(a<b){
                Console.WriteLine("a < b");
            }
            if(a>b){
                Console.WriteLine("a > b");
            }
            if(a==b){
                Console.WriteLine("a == b");
            }
		}
    }
}

Measured memory_bytes: 8780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i=0; i<N; i++) {
        int ai;
        cin >> vec.at(i);
    }

    int sumA = 0;
    int sumB = 0;

    // Nが偶数の場合
    if (N % 2 == 0) {
        sort(vec.begin(), vec.end());
        reverse(vec.begin(),vec.end());
        for(int i=0; i<N/2; i++) {
            sumA += vec.at(2*i);
            sumB += vec.at(2*i+1);
        }
    }

    // Nが奇数の場合
    else{
        sort(vec.begin(), vec.end());
        reverse(vec.begin(),vec.end());
        for(int i=0; i<N/2; i++) {
            sumA += vec.at(2*i);
            sumB += vec.at(2*i+1);
        }
        sumA += vec.at(N-1);
    }

    cout << sumA - sumB << endl;
}

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

int main()
{
  int x;
  rep(i,5)
  {
    cin >> x;
    if(x == 0)
    {
      cout << i+1 << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3588
package main

import "fmt"

type Edge struct {
	x, y int
}

type Node struct {
	froms []int
}

var nodes [100000]Node
var cache [100000]int

func findLongestPath(i int) int {
	if cache[i] > 0 {
		return cache[i]
	}

	result := 0
	for _, j := range nodes[i].froms {
		p := findLongestPath(j) + 1
		if p > result {
			result = p
		}
	}
	cache[i] = result
	return result
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	for i := 0; i < n; i++ {
		nodes[i].froms = make([]int, 0, 0)
	}

	nonTerminatingNodeFlags := make([]bool, n, n)
	for i := 0; i < m; i++ {
		var x, y int
		fmt.Scan(&x, &y)
		nodes[y-1].froms = append(nodes[y-1].froms, x-1)
		nonTerminatingNodeFlags[x-1] = true
	}

	nodeNumbers := make([]int, 0, 0)
	for i, b := range nonTerminatingNodeFlags {
		if !b {
			nodeNumbers = append(nodeNumbers, i)
		}
	}

	result := 0
	for _, i := range nodeNumbers {
		p := findLongestPath(i)
		if p > result {
			result = p
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 23936
#include<stdio.h>
int main(){
	int m,f,r,goukei;
	for(;;){
		scanf("%d%d%d",&m,&f,&r);
		if(m==-1 && f==-1 && r==-1){
			break;
		}
		goukei=m+f;
		if(goukei>=80){
			printf("A\n");
		}
			else if(m==-1){
				printf("F\n");
		}
			else if(f==-1){
				printf("F\n");
		}
		else if(goukei<80 && goukei>=65 ){
			printf("B\n");
		}
		else if(goukei<65 && goukei>=50 ){
			printf("C\n");
		}
		else if(r>=50){
			printf("C\n");
		}
		else if(goukei<50 && goukei>=30 ){
			printf("D\n");
		}
		else if(goukei<30){
			printf("F\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2120
//#pragma GCC optimize("O3,unroll-loops")
//#pragma loop_opt(on)
#include <bits/stdc++.h>
//#include <bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MAX = 1e6+5;
constexpr ll INF = 2134567890;
constexpr ll MOD = 998244353;

ll fpow(ll b, ll a, ll MOD = MOD) {
    b %= MOD;
    ll r = 1;
    for(; a; b=b*b%MOD, a>>=1)
        a&1 && (r = r*b%MOD);
    return r;
}

signed main() {
    FAST;

    int n, m;
    cin >> n >> m;
    bool can = true;
    vector<int> v(n, -1);
    Fr(i, 0, m) {
        int si, ci;
        cin >> si >> ci;
        si--;
        if (v[si] == -1 || v[si] == ci) v[si] = ci;
        else can = false;
    }
    int ans = -1;
    if (can && (n == 1 || v[0] != 0)) {
        ans = 0;
        Fr(i, 0, n) ans = ans*10 + max(v[i], int(!i&&n!=1));
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

string res[4] = {"NA", "YYMM", "MMYY", "AMBIGUOUS"};

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int a = (s[0] - '0') * 10 + (s[1] - '0');
	int b = (s[2] - '0') * 10 + (s[3] - '0');
	int cnt = 0;
	cnt = (1 <= a && a <= 12) * 2 + (1 <= b && b <= 12);
	cout << res[cnt] << endl;
	return 0;
}



Measured memory_bytes: 256
# coding:utf-8


def main():
    N = int(input())
    # N, M = map(int, input().split())
    task = []
    for i in range(N):
        Ai, Bi = map(int, input().split())
        task.append([Ai, Bi])
    time = 0
    task.sort(key=lambda x: x[1])
    # print(task)
    ans = True

    for i in range(N):
        Ai, Bi = task[i]
        time += Ai
        if time > Bi:
            ans = False
            break

    if ans:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	string S;
	cin >>S;
	string K="keyence";
	int l=0;
	while(S.at(l)==K.at(l)) {
		l++;
		if (l==K.size())
			break;
	}
	if (7==l) {
		cout <<"YES" <<endl;
		return 0;
	}
	int r=0;
	while(S.at(S.size()-1-r)==K.at(K.size()-1-r)) {
		r++;
		if (r==K.size())
			break;
	}
	if (7<=l+r) {
		cout <<"YES" <<endl;
		return 0;
	}
	cout <<"NO" <<endl;
	return 0;
}



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

#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}

int F[123456],ans;

signed main(){
  int n,k;cin>>n>>k;
  for(int i=1;i<=k;i++){
    (F[i]+=i)%=MOD;
    for(int j=i+i;j<=k;j+=i)F[j]+=MOD-F[i];
  }
  for(int i=1;i<=k;i++)ans+=pw(k/i,n)*(MOD+F[i])%MOD;
  cout<<ans%MOD<<endl;
}


Measured memory_bytes: 4384
package main

import (
	"fmt"
)
// QuickSort is sort algorithm
func quickSort(values []int) (ret []int) {
	if len(values)<2 {
		return values
	}
	pivot := values[0]
	
	left := []int{}
	right := []int{}
	for _,v := range values[1:] {
		if v>pivot {
			right = append(right, v)
		} else {
			left = append(left, v)
		}
	}
	left = quickSort(left)
	right = quickSort(right)
	ret = append(left, pivot)
	ret = append(ret, right...)
	return 
}	

func main() {
	var n,k int
	fmt.Scan(&n,&k)
	p := make([]int, n)
	for i:=0;i<n;i++ {
		fmt.Scan(&p[i])
	}
	p = quickSort(p)
	sum := 0
	for i:=0;i<k;i++ {
		sum += p[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 6284
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0, l = s.size(); i < l / 2; ++i) {
        if (s[i] != s[l - i - 1])
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="SUN")
    cout<<7;
  if(s=="MON")
    cout<<6;
  if(s=="TUE")
    cout<<5;
  if(s=="WED")
    cout<<4;
  if(s=="THU")
    cout<<3;
  if(s=="FRI")
    cout<<2;
  if(s=="SAT")
    cout<<1;
  return 0;
}
  
  
  
  
  

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int i, N, Q, l, r, c[100000], cnt = 0, ans[100000];
	char S[100000];
	memset(c, 0, sizeof(c));

	scanf("%d %d", &N, &Q);
	scanf("%s", S);

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

	for (i = 0; i < Q; i++) {
		scanf("%d %d", &l, &r);
		ans[i] = c[r - 1] - c[l - 1];
	}

	for (i = 0; i < Q; i++) printf("%d\n", ans[i]);

	return 0;
}

Measured memory_bytes: 1664
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c)
    {
        cout << "Yes" << endl;
        return 0;
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	char ar[5];
	cin>>ar;

	ll i,j,k=0;
	for(i=0;i<4;i++){
		if(ar[i]==ar[i-1]){
			k=1;
			break;
		}
	}
	if(k) cout<<"Bad";
	else cout<<"Good";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	int n, m, x;
	cin >> n >> m >> x;
	int c[n];
	int a[n][m];
	int flag = 0;
	//int arr[15] = {0};
	zip(i, 0, n)
	{
		cin >> c[i];
		zip(j, 0, m)
		{
			cin >> a[i][j];
		}
	}
	int ans = 1e9;
	for (int mask = 0; mask < (1 << n); mask++)
	{
		int sum = 0;
		int arr[m] = {0};
		for (int i = 0; i < n; i++)
		{
			if (mask & (1 << i))
			{
				sum += c[i];
				zip(j, 0, m)
				{
					arr[j] += a[i][j];
				}
			}
		}
		zip(i, 0, m)
		{
			if (arr[i] >= x)
			{
				if (i == m - 1)
				{
					int var = 0;
				}
			}
			else
			{
				sum = 0;
				break;
			}
		}
		if (sum != 0)
		{
			ans = min(ans, sum);
		}
	}
	if (ans == 1e9)
	{
		cout << -1 << en;
	}
	else
	{
		cout << ans << en;
	}

	// map<int,int>madar;
	// int ans = 0;
	// vii v;
	// int need[m] = {0};
	// zip(i, 1, n + 1)
	// {
	// 	v.pb({c[i], i});
	// }
	// sort(all(v));
	// zip(i, 0, v.size())
	// {
	// 	int xx = v[i].ss;
	// 	ans += v[i].ff;
	// 	zip(j, 1, m + 1)
	// 	{
	// 		need[j] += a[xx][j];
	// 	}
	// 	zip(j, 1, m + 1)
	// 	{
	// 		if (need[j] >= x)
	// 		{
	// 			if (j == m)
	// 			{
	// 				cout << ans << en;
	// 				return 0;
	// 			}

	// 		}
	// 		else
	// 		{
	// 			break;
	// 		}
	// 	}
	// }




	return 0;
}



Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;

const int maxn = 200000+5;
struct P
{
	int x;
	int y;
};

inline bool operator < (const struct P & a, const struct P & b)
{
	return a.x < b.x || (a.x==b.x && a.y<b.y);
}

P mem[55];
P K[maxn];
map<P, int> M;
int n;
int cnt = 0;
int Max= 0;

bool cmp(const P a ,const P b)
{
	return a.x < b.x || (a.x==b.x && a.y < b.y);
}

void Print()
{
	cout << "show1" << endl;
	for(int i = 0; i < cnt; i++)
	{
		printf("%d %d\n", K[i].x, K[i].y);
	}
}

int solve()
{
	sort(mem, mem+n, cmp);
	for(int i = 0; i < n; i++)
		for(int j = i+1; j < n; j++, cnt++)
		{
			K[cnt].x = mem[i].x - mem[j].x;
			K[cnt].y = mem[i].y - mem[j].y;
			P np = K[cnt];
			if(!M.count(np))
			{
				M[np] = 1;
			}
			else M[np]++;
		}

	for(int i = 0; i < cnt; i++)
	{
		if(M[K[i]] > Max) Max = M[K[i]]; 
	}
	return Max;
}

int main()
{	
	scanf("%d", &n);
	for(int i = 0; i < n; i++) 
	{
		scanf("%d %d", &mem[i].x, &mem[i].y);
	}
	printf("%d\n", n-solve());
	//Print();
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */


int main(){
    int n, m; cin >> n >> m;
    vector<int> x(n), y(m), z(m); rep(i, n) cin >> x[i];

    rep(i, n) y[x[i] % m]++;

    sort(all(x));
    for(int i = 0; i < n-1; ){
        if(x[i] == x[i+1]){
            z[x[i] % m]++;
            i += 2;
        }
        else i++;
    }

    int ans = 0;
    for(int k = 0; k <= m / 2; k++){
        if(k == 0 || k * 2 == m) ans += y[k] / 2;
        else{
            if(y[k] >= y[m-k]) ans += y[m-k] + min((y[k]-y[m-k])/2, z[k]);
            else ans += y[k] + min((y[m-k]-y[k])/2, z[m-k]);
        }
    }
    
    out(ans);
}

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

enum {
    TOP = 0,
    FRONT,
    RIGHT,
    LEFT,
    BACK,
    BOTTOM
};

class dice {
public:
    dice(int top, int front) 
        : v_(6)
    {
        int right[7][7] = {};
        // change 
        right[1][2] = 3; right[1][3] = 5; right[1][4] = 2; right[1][5] = 4;
        right[2][1] = 4; right[2][3] = 1; right[2][4] = 6; right[2][6] = 3;
        right[3][1] = 2; right[3][2] = 6; right[3][5] = 1; right[3][6] = 5;
        right[4][1] = 5; right[4][2] = 1; right[4][5] = 6; right[4][6] = 2;
        right[5][1] = 3; right[5][3] = 6; right[5][4] = 1; right[5][6] = 4;
        right[6][2] = 4; right[6][3] = 2; right[6][4] = 5; right[6][5] = 3;
        v_[TOP] = top;
        v_[FRONT] = front;
        v_[BOTTOM] = 7 - top;
        v_[BACK] = 7 - front;
        v_[RIGHT] = right[top][front];
        v_[LEFT] = 7 - v_[RIGHT];
    }
    dice(vector<int> const& v)
    : v_(v)
    {}

    dice roll(int dir) {
        vector<int> res(6);
        for(int i=0; i<6; ++i) {
            res[i] = v_[rot[dir][i]];
        }
        return dice(res);
    }

    int get(int idx) {
        if(idx < 0 || 6 <= idx) {
            return -1;
        }
        return v_[idx];
    }

private:
    std::vector<int> v_;
    int rot[6][6] = {{4, 0, 2, 3, 5, 1},  // south 
                     {3, 1, 0, 5, 4, 2},  // east
                     {2, 1, 5, 0, 4, 3},  // west
                     {1, 5, 2, 3, 0, 4},  // north 
                     {0, 2, 4, 1, 3, 5},  // right(not move)
                     {0, 3, 1, 4, 2, 5}}; // left(not move)
};

int main() {
    int n;
    while(cin >> n, n) {
        int res = 1;
        dice d(1, 2);
        for(int i=0; i<n; ++i) {
            string s;
            cin >> s;
            if(s[0] == 'N') {
                d = d.roll(3);
            } else if(s[0] == 'S') {
                d = d.roll(0);
            } else if(s[0] == 'W') {
                d = d.roll(2);
            } else if(s[0] == 'E') {
                d = d.roll(1);
            } else if(s[0] == 'R') {
                d = d.roll(4);
            } else {
                d = d.roll(5);
            }
            res += d.get(TOP);
        }
        cout << res << endl;
    }
}



Measured memory_bytes: 2996
#include <iostream>
#include <set>

using namespace std;

int main()
{
    int N; cin >> N;
    set<int> Set;
    
    for(int i = 0; i < N; ++i)
    {
        int Command; cin >> Command;
        int Val; cin >> Val;
        
        if(Command == 0)
        {
            Set.insert(Val);
            cout << Set.size() << endl;
        }
        else 
        {
            cout << (Set.find(Val) != Set.end()) << endl;
        }
        
    }
    
    
    return 0;
}


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

#define MAX 200002


int n;

vector<long long int> A;
vector<long long int> B;


multiset<long long int> ma;
multiset<long long int> mb;

map<long long int, int> mp;

int belong[MAX];

inline int root(int b){
	if (belong[b] == -1){
		return b;
	}
	belong[b] = root(belong[b]);
	return belong[b];
}
void merge(int a, int b){
	a = root(a);
	b = root(b);
	if (a == b)return;
	belong[a] = b;
}
int main(){
	memset(belong, -1, sizeof(belong));
	cin >> n;
	long long int xa = 0;
	long long int xb = 0;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		A.push_back(a);
		xa ^= a;
		ma.insert(a);
	}
	ma.insert(xa);
	int shif = 0;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		B.push_back(a);
		xb ^= a;
		mb.insert(a);
		if(A[i]!=B[i])mp[a] = 0;
		if (A[i] != B[i])mp[A[i]] = 0;
		if (A[i] != B[i])shif++;
	}
	mb.insert(xb);
	if (xa != xb){
		mp[xa] = 0;
		mp[xb] = 0;
	}
	int ii = 0;
	for (auto it = mp.begin(); it != mp.end(); it++){
		(*it).second = ii;
		ii++;
	}
	if (ma != mb){
		puts("-1");
		return 0;
	}
	int same = 0;
	A.push_back(xa);
	B.push_back(xb);
	for (int i = 0; i < A.size(); i++){
		if (A[i] != B[i]){
			A[i] = mp[A[i]];
			B[i] = mp[B[i]];
		}
	}
	for (int i = 0; i < A.size(); i++){
		if (A[i] != B[i])
		merge(A[i], B[i]);
	}
	int sz = mp.size();
	int ans = 0;
	for (int i = 0; i < sz; i++){
		if (belong[i] == -1){
			ans++;
		}
	}
	if (xa == xb&&mp.count(xa)==0){
		ans += shif;
		cout << ans << endl;
	}
	else{
		ans += shif;
		ans--;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 19188
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main (void){
	
	int count=0,i;
	
	char buff1[256];
	char buff2[256];
	
	scanf("%s",buff1);
	
	while(1){
	scanf("%s",buff2);
	
	if(strcmp(buff2, "END_OF_TEXT")==0)break;
	for(i=0;buff2[i] != '\0';i++){
		buff2[i] = tolower(buff2[i]);
	}
	if(strcmp(buff2,buff1) == 0){
		count++;
	}else{
		;
	}
	
	}
	printf("%d\n",count);
	
return 0;
}

Measured memory_bytes: 552
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  for (;;) {
    int h, w;
    cin >> h >> w;
    if (h == 0) break;

    for (int y = 0; y < h; y++) {
      if (y == 0 || y == h - 1) {
	for (int x = 0; x < w; x++) putchar('#');
      }
      else {
	putchar('#');
	for (int x = 0; x < w - 2; x++) putchar('.');
	putchar('#');
      }
      putchar('\n');
    }
    putchar('\n');
  }

  return 0;
}

Measured memory_bytes: 1108
import sys

l = []
for i in sys.stdin:
    l.append(i.split())

for i in range(0,len(l)-1):
    if int(l[i][0]) == -1 or int(l[i][1]) == -1:
        print('F')
    elif int(l[i][0]) + int(l[i][1]) >= 80:
        print('A')
    elif int(l[i][0]) + int(l[i][1]) < 80 and int(l[i][0]) + int(l[i][1]) >= 65:
        print('B')
    elif (int(l[i][0]) + int(l[i][1]) < 65 and int(l[i][0]) + int(l[i][1]) >= 50) or int(l[i][2]) >= 50:
        print('C')
    elif int(l[i][0]) + int(l[i][1]) < 50 and int(l[i][0]) + int(l[i][1]) >= 30:
        print('D')
    else:
        print('F')


Measured memory_bytes: 5616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;
typedef long long LL;

int main(void) {
	LL n, k, a = 1;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		if (a * 2 < a + k) {
			a *= 2;
		} else {
			a += k;
		}
	}
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256