akhauriyash/Code-Regression huggingface dataset:
def solve():

    N, K = [int(i) for i in input().split()]
    xlist = [int(i) for i in input().split()]

    cost = float("inf")
    for i in range(N-K+1):
        j = i + K - 1
        cost = min(
            cost,
            abs(xlist[i] - 0) + abs(xlist[j] - xlist[i]),
            abs(xlist[j] - 0) + abs(xlist[i] - xlist[j])
        )
    print(cost)


if __name__ == "__main__":
    solve()


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  map<char,int32> mp;
  REP(i,n){
    char c;
    cin >> c;
    mp[c]++;
  }
  if(mp.size() == 3){
    ANS("Three");
  }else{
    ANS("Four");
  }
  return 0;
}

Measured memory_bytes: 256
class Main
  def self.run
    test_cases = read_inputs
    test_cases.each_with_index {|x, i|
      puts "Case #{i + 1}: #{x}"
    }
  end

  private

  def self.read_inputs
    test_cases = []
    while (x = gets.to_i) != 0 do
      test_cases << x
    end
    test_cases
  end
end

Main.run

Measured memory_bytes: 8824
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a[5], five = 0, seven;
	for(int i = 0; i < 3; i++){
		cin >> a[i];
	}
	qsort(a, 3, sizeof(int), comp);
	if(a[0] == 5 && a[1] == 5 && a[2] == 7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#define Re register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define SFOR(i,a,b,c) for(Re int i = a;i <= b;i+=c)
#define SROF(i,a,b,c) for(Re int i = a;i >= b;i-=c)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
namespace fastIO{
    #define BUF_SIZE 100000
    #define OUT_SIZE 100000
    #define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    #undef ll
    #undef OUT_SIZE
    #undef BUF_SIZE
};
using namespace fastIO;

int a,b;

int main(){
	read(a);read(b);
	printf("%d\n",a+b/2);
	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map as Map
import Data.Map (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

next c
	| c == 'z'  = 'a'
	| otherwise = Char.chr $ Char.ord c + 1

main :: IO ()
main = do
	(c:_) <- getLine
	putStrLn $ (next c : [])


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "random"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

const int N=310;

int n,m,l;
ii f[N][N];
vector<ii> ad[N];

main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);

    n=in,m=in,l=in;
    forinc(i,1,m){
        int u=in,v=in,c=in;
        if(c>l) continue;
        ad[u].pb({v,c});
        ad[v].pb({u,c});
    }

    forinc(i,1,n)
        forinc(j,1,n)
            f[i][j]=i==j?ii(0,-l):ii(n+1,0);
    forinc(i,1,n){
        using w=tuple<int,int,int>;
        priority_queue<w,vector<w>,greater<w>> q;
        q.push(mt(0,-l,i));
        int c,g,u;
        while(q.size()){
            tie(c,g,u)=q.top(); q.pop();
            //cout<<f[i][u].fi<<" "<<f[i][u].se<<"\n";
            if(f[i][u]<ii(c,g)) continue;
            //cerr<<c<<" "<<g<<" "<<u<<"\n";
            forv(v,ad[u]){
                int C,G;
                if(-g>=v.se) C=c,G=-g-v.se;
                else C=c+1,G=l-v.se;
                if(f[i][v.fi] > ii(C,-G)){
                    f[i][v.fi]=ii(C,-G);
                    q.push(mt(C,-G,v.fi));
                }
            }
        }
        //cout<<f[5][2].fi;
        ///return 0;
        //return 0;
    }

    forinc(i,1,in){
        int u=in,v=in;
        cout<<(f[u][v].fi>n?-1:f[u][v].fi)<<"\n";
    }
}


Measured memory_bytes: 4352
from sys import exit
n, m = map(int, input().split())
a = list(map(int, input().split()))

odd = []
even = []
for x in a:
	if x%2 == 0:
		even.append(x)
	else:
		odd.append(x)

if n%2 == 0:
	if len(odd) > 2:
		print("Impossible")
		exit()
	if len(odd) == 2:
		a = [odd[0]] + even + [odd[1]]
		b = [odd[0]+1] + even + [odd[1]-1]
		if b[-1] == 0:
			b.pop()
	else:
		a = even
		b = [1] + even
		b[-1] -= 1
		if b[-1] == 0:
			b.pop()

else:
	if len(odd) > 1:
		print("Impossible")
		exit()
	if m == 1:
		b = [1, n-1]
	else:
		a = odd + even
		b = [odd[0]+1] + even
		b[-1] -= 1
	if b[-1] == 0:
		b.pop()

print(*a)
print(len(b))
print(*b)

Measured memory_bytes: 3064
# frozen_string_literal: true

a, b, x = gets.split.map(&:to_f)

if x > a**2 * b / 2
  puts 90 - Math.atan(a**3 / (2 * a**2 * b - 2 * x)) * 180 / Math::PI
else
  puts 90 - Math.atan(2 * x / (a * b**2)) * 180 / Math::PI
end

Measured memory_bytes: 1788
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

class UnionFind
{
public:
	UnionFind(int size) : sz(size), v(sz){
		for(int i=0; i<v.size(); i++)
			v[i] = i;
	}

	int find(int id){
		if(id == v[id])
			return id;

		v[id] = find(v[id]);
		return v[id];
	}
	int size(){return sz;}
	void unite(int id1, int id2){
		id1 = find(id1);
		id2 = find(id2);
		v[max(id1, id2)] = min(id1, id2);
	}

private:
	int sz;
	vector<int> v;
};

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

	vector<int> p(N+1);
	for(int i=0; i<N; i++)
		cin >> p[i+1];

	vector<int> x(M), y(M);
	for(int i=0; i<M; i++)
		cin >> x[i] >> y[i];

	UnionFind uf(N+1);
	for(int i=0; i<M; i++)
		uf.unite(x[i], y[i]);

	int ret = 0;
	for(int i=0; i<N; i++){
		int index = i + 1;
		if(uf.find(index) == uf.find(p[index]))
			ret++;
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 1792
N,M=map(int,input().split())
A=[]
for i in range(N):
  a=[int(x) for x in input().split()]
  A.append(a)
  
def solve():
  res=[ 0 for x in range(M+1)]
  for i in range(N):
    res[A[i][0]]+=1
  ans=max(res)
  jud=res.index(ans)
  for j in range(N):
    A[j].remove(jud)
  return ans

minans=N
for i in range(M):
  minans=min(solve(),minans)
print(minans)

Measured memory_bytes: 4244
n,x,y = map(int,input().split())
ans = [0] * (n-1)
for i in range(n):
     for j in range(i+1,n):
          a = abs(x-i-1)
          b = abs(y-j-1)
          c = abs(a+b+1)
          if j-i < c:
               ans[j-i-1] += 1
          else:
               ans[c-1] += 1
for i in range(len(ans)):
     print(ans[i])

Measured memory_bytes: 3444
A = int(input())
B = int(input())
C = int(input())
X = int(input())

result = 0

for i in range(A+1):
    for j in range(B+1):
        i_j = 500*i + 100*j
        for k in range(C+1):
            if i_j + 50*k == X:
                result += 1

print(result)

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

int main(){
	int inp, a[4] = {};
	string in;
	while (true)
	{
		cin >> inp >> in;
		if (cin.eof() || inp == 0) { break; }
		if (in == ",A") { a[0]++; }
		else if (in == ",B") { a[1]++; }
		else if (in == ",AB") { a[2]++; }
		else { a[3]++; }
	}
	for(int i=0;i<4;i++){
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            if(N == 1)
            {
                WriteLine("Hello World");
            }
            else
            {
                var A = cin.ReadInt;
                var B = cin.ReadInt;
                WriteLine(A + B);
            }
        }

        static long GcdArray(long[] array)
        {
            var ans = array[0];
            for(var i=1; i<array.Length; i++)
            {
                ans = Gcd(ans, array[i]);
            }
            return ans;
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
N, K = map(int, input().split())

data = list(map(int, input().split()))

for x in range(K):
#	print(data)
	raise_data = [0] * (N + 1)
	for i, d in enumerate(data):
		raise_data[max(0, i - d)] += 1
		raise_data[min(N, i + d + 1)] -= 1
	
	height = 0
	ended = 0
	for i in range(N):
		height += raise_data[i]
		data[i] = height
		if height == N:
			ended += 1
	
	if ended == N:
#		print(x)
		break
	
print(*data)


Measured memory_bytes: 158880
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  string T;
  
  for(int i=0;i<S.size();i++){
    //cout<<90+N-26<<endl;
    S[i]=(S[i]-'A'+N)%26+'A';
  }
  cout<<S<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int h, w;
vector<vector<int> > G;
vector<vector<bool> > Used;
vector<int> mx = {0, 0, -1, 1}, my = {1, -1, 0, 0};
int main(){
    int x;
    sc(h) sc(w)
    G.resize(h);
    for (int i = 0; i < h; i++) G[i].resize(w);
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) sc(G[i][j])
    }
    vector<P> ans;
    for (int i = 0; i < h; i++){
        if (i % 2 == 0){
            for (int j = 0; j < w; j++){
                if (G[i][j] % 2 == 1){
                    if (j == w-1 && i != h-1){
                        ans.push_back(P(i+1, j+1));
                        ans.push_back(P(i+2, w));
                        G[i+1][w-1] += 1;
                    }else if (j != w-1){
                        ans.push_back(P(i+1, j+1));
                        ans.push_back(P(i+1, j+2));
                        G[i][j+1] += 1;
                    }
                }
            }
        }else{
            for (int j = w-1; j >= 0; j--){
                if (G[i][j] % 2 == 1){
                    if (j == 0 && i != h-1){
                        ans.push_back(P(i+1, j+1));
                        ans.push_back(P(i+2, 1));
                        G[i+1][0] += 1;
                    }else if (j != 0){
                        ans.push_back(P(i+1, j+1));
                        ans.push_back(P(i+1, j));
                        G[i][j-1] += 1;
                    }
                }
            }
        }
    }
    cout << ans.size() / 2 << endl;
    for (int i = 0; i < ans.size(); i++){
        if (i % 2 == 0) cout << ans[i].first << " " << ans[i].second << " ";
        else cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
from heapq import heapify, heappop, heappush

N, M = map(int, input().split())
A = list(map(lambda x:-1 * int(x), input().split()))

heapify(A)
for i in range(M):
    heappush(A, int(heappop(A) / 2))

print(-1 * sum(A))


Measured memory_bytes: 14180
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for (int i=(a-1);i>=(b);--i)
#define rrep(i,n) rrepd(i,n,0)
typedef long long ll;
typedef pair<int, int> P;


int main(int argc, const char * argv[]) {

  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n){
    cin >> d[i];
  }
  long ans = 0;
  rep(i,n-1){
    repd(j,i+1,n){
      ans += d[j] * d[i];
    }
  }
  cout << ans << endl;
  return 0;
  
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
int i() { int i; scanf("%d", &i); return i;}
int l() { ll l; scanf("%lld", &l); return l;}
vi ia(int n) {vi ret(n); rep(i, n) scanf("%d", &ret[i]); return ret;}
vl la(int n) {vl ret(n); rep(i, n) scanf("%lld", &ret[i]); return ret;}

void Main() {
  int N = i();
  int f = i();
  vi A = ia(N-1);

  ll ans = f-1;

  int mi = 1;
  forr(a, A) {
    //_p("mi: %d, a:%d\n", mi, a);
    if (a <= mi) continue;
    if (a == mi+1) {
      mi = mi + 1;
      continue;
    }
    int x = (a-1) / (mi+1);
    //_p("x: %d\n", x);
    ans += x;
  }
  cout << ans << endl;
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 768
# your code goes here
N = int(input())

ruiseki = 0
a = 0
enable = False
while ruiseki < N:
	a += 1
	ruiseki += a
	if ruiseki == N:
		enable = True

ans = []
if enable:
	if N == 1:
		ans = [[1],[1]]
	else:
		ans = [[1,2],[2,3],[1,3]]
		ruiseki = 3
		for i in range(a-2):
			tmp = []
			for ans_raw in ans:
				ruiseki += 1
				ans_raw.append(ruiseki)
				tmp.append(ruiseki)
			ans.append(tmp)

if enable:
	print('Yes')
	print(a+1)
	for ans_raw in ans:
		print(str(len(ans_raw)) + ' ' + ' '.join(map(str,ans_raw)))
else:
	print('No')


Measured memory_bytes: 9076
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		
		System.out.println(question1(input));
	}
	
	public static String question1(String input)
	{
		String result = input.substring(0, 4) + " " + input.substring(4);
		
		return result;
	}
}

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

int main() {
    string inte;
    cin >> inte;
    string ans = "No";

    if(inte[0] == inte[1] && inte[1] == inte[2]) {
        ans = "Yes";
    } else if(inte[1] == inte[2] && inte[2] == inte[3]) {
        ans = "Yes"; 
    }

    cout << ans << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 300005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int64 N,A,B;
void Solve() {
    read(N);read(A);read(B);
    if(A > B) {puts("0");return;}
    if(A == B) {puts("1");return;}
    if(N == 1) {puts("0");return;}
    out(A + B * (N - 1) - B - A * (N - 1) + 1);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
fun main() {
    println(solve())
}

val solve: () -> Any = {
    val (N, M) = readIntList()
    val H = readLongList()
    val setNG = mutableSetOf<Int>()
    repeat(M) {
        val (A, B) = readIntList()
        if (H[A-1] > H[B-1]) {
            setNG += B
        }
        else if (H[A-1] < H[B-1]) {
            setNG += A
        }
        else {
            setNG += A
            setNG += B
        }
    }
    N-setNG.size
}

val mod: Int = 1_000_000_007

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun <T> T.alsoPrintln() = also { println(this) }

fun Boolean.toYesOrNo(yes: String = "Yes", no: String = "No") = if (this) yes else no

Measured memory_bytes: 66432
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];

int main()
{
	boost
	ll n,i;
	double pro=1,sum=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		pro*=arr[i];
	}
	for(i=0;i<n;i++)
		sum+=pro/arr[i];
	cout<<fixed<<setprecision(9);
	cout<<pro/sum;
	return 0;
}

Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# 

S = input()
T = input()

ans = 0
for i in range(3):
    if S[i] == T[i]:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
int n;
int main(){
	cin>>n;
	if(n%10==9||n/10==9) cout<<"Yes";
	else cout<<"No";
 	return 0;
}

Measured memory_bytes: 256
program atcoder_contest_scheduling
  implicit none
  integer :: d, c(26) = 0, s(26, 365) = 0, t(365) = 0, u(365), m, n, p, q, i
  real(8) :: t1, t2
  call cpu_time(t1)
  call random_seed_clock()
  read(*,*) d
  read(*,*) c
  read(*,*) (s(:, i), i = 1, d)
  t = [(maxloc(s(:, i), 1), i = 1, d)]
  m = score()
  u = t
  do
    p = next_int(365)
    q = next_int(26)
    t(p) = q
    n = score()
    if (m < n) then
      m = n
      u(p) = q
    else
      t(p) = u(p)
    end if
    call cpu_time(t2)
    if (t2 - t1 > 1.975d0) exit
  end do
  write(*,'(i0)') (u(i), i = 1, d)
contains
  integer function score() result(res)
    integer :: last(26), i
    last = 0
    res = 0
    do i = 1, d
      last(t(i)) = i
      res = res + s(t(i), i) - sum(c * (i - last))
    end do
  end
  subroutine random_seed_clock()
    integer :: nseed, clock
    integer, allocatable :: seed(:)
    call system_clock(clock)
    call random_seed(size = nseed)
    allocate(seed(nseed))
    seed = clock
    call random_seed(put = seed)
    deallocate(seed)
  end
  integer function next_int(m) result(res)
    integer, intent(in)  :: m
    real(8) :: r
    call random_number(r)
    res = int(m * r) + 1
  end
end program atcoder_contest_scheduling

Measured memory_bytes: 3032
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

int main() {
	string s;
	cin >> s;
	int n = (int)s.size();

	ll ans = 0;
	rep(l, 0, n) rep(r, l, n) {
		ll add = atoll(s.substr(l, r - l + 1).c_str());
		ans += add * (1LL << max(0, l - 1)) * (1LL << max(0, n - r - 2));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
const int INF = 1e9;
const int MO = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#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 Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    CIN(N);CIN(A);CIN(B);
    cout<<min(A,B)<<" "<<max(0,B-(N-A))<<endl;
}


Measured memory_bytes: 256
from math import ceil, floor
k, a, l, r = input(), map(float, raw_input().split()), 2., 2.
for v in a[::-1]:
    l = ceil(l / v) * v
    r = floor(r / v) * v + v - 1
print '%d %d' % (l, r) if l < r else -1


Measured memory_bytes: 11340
import sys

n = int(sys.stdin.readline())
lst = list(map(int, sys.stdin.readline().split()))

lst.sort(reverse = True)

ans = lst[0]
cnt = 0
idx = 1

for _ in range(1, n-1):
    if cnt <= 1:
        ans += lst[idx]
        cnt += 1
    else:
        idx += 1
        cnt = 1
        ans += lst[idx]


print(ans)

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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


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

    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    
    vector<ll> dp(N,0);
    dp[0] = A[0];
    REP(i, 1, N) dp[i] = dp[i-1] + A[i];

    ll total = dp[dp.size()-1];

    ll diff = INF_LL;
    ll point = 0;

    rep(i,N)
    {
        if( abs( total - dp[i]*2 ) < diff )
        {
            diff = abs( total - dp[i]*2 );
            point = i;
        }
    }
    cout << abs(total-dp[point]-dp[point]) << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i=2; i<=N; ++i) cin >> A.at(i);

    int num[N+100] = {0}; //バケット
    for(int i=1; i<=N; ++i) num[A.at(i)]++;
    for(int i=1; i<=N; ++i) cout << num[i] << endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1000000007;
long long dp[111][4][4][4];
char s[111];

/*
dp[l][i][j][k] 表示长度为n，后三位分别为i,j,k的的个数

*/

bool pd(int x,int y,int z) {
    if(z==0 && y==1 && x==2) return false;
    if(z==0 && y==2 && x==1) return false;
    if(z==1 && y==0 && x==2) return false;
    return true;
}
bool pd1(int x,int y,int z) {
    if(z==0 && y==1 && x==2) return false;
    return true;
}

int main() {
    int n;
    scanf("%d",&n);

    for(int i=0;i<4;i++) {
        for(int j=0; j<4; j++) {
            for(int k=0; k<4; k++) {
                if(pd(i,j,k)) dp[3][i][j][k]=1;
            }
        }
    }


    for(int l=4;l<=n;l++) {
        for(int i=0;i<4;i++) {
            for(int j=0; j<4; j++) {
                for(int k=0; k<4; k++) {
                    if(pd(i,j,k)) {
                        for(int z=0; z<4; z++) {
                            if(pd(z,i,j) && pd1(z,i,k) &&pd1(z,j,k)) {
                                dp[l][i][j][k] += dp[l-1][z][i][j];
                                dp[l][i][j][k]=(dp[l][i][j][k]+maxn)%maxn;
                            }

                        }
                    }
                }
            }
        }
    }
    long long ans=0;
    for(int i=0;i<4;i++) {
        for(int j=0; j<4; j++) {
            for(int k=0; k<4; k++) {
                ans += dp[n][i][j][k];
                ans = (ans+maxn)%maxn;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  string c;
  cin >> c;
  
  if(c == "a" || c == "i" || c == "u" || c == "e" || c == "o"){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<numeric>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(lli i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

vector<int> t, s;
vector<bool> u;
vector<vector<int>> v;

void dfs(int m){
	rep(i, v[m].size()) if(u[v[m][i]]){
		u[v[m][i]] = false;
		t.push_back(v[m][i]);
		dfs(v[m][i]);
		break;
	}
	return;
}

int main(void){
	int n, m; cin >> n >> m;
	v.resize(n+1);
	u.assign(n+1, true);
	rep(i, m){
		int a, b; cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	u[1] = false;
	dfs(1);
	s = t;
	reverse(s.begin(), s.end());
	t.clear(); t.push_back(1);
	dfs(1);
	
	cout << s.size() + t.size() << endl;
	
	rep(i, s.size()) cout << s[i] << " ";
	rep(i, t.size()) cout << t[i] << (i == t.size()-1?"\n":" ");

	return 0;
}

Measured memory_bytes: 7160
import math

N = int(input())
X = list(map(int, input().split()))
max_xi = max(X)
min_xi = min(X)
ans = int(math.pow(99, 2)) * 100
for p in range(min_xi, max_xi + 1):
    total = 0
    for xi in X:
        total += int(math.pow(xi - p, 2))
    ans = min(ans, total)
print(ans)

Measured memory_bytes: 38768
#include <iostream>

using namespace std;

int main()
{
	int N, Y;
	cin >> N >> Y;
	for(int x=Y/10000;x>=0;x--)
		for (int y = (Y - x * 10000) / 5000; y >= 0; y--)
		{
			int z;
			z = N - x - y;
			if ((10000 * x + 5000 * y + 1000 * z) == Y)
			{
				cout << x <<" " << y << " " << z << endl;
				return 0;
			}

		}
	cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int ac=0,bc=0,cc=0;
    string x;cin>>x;
    for(char c:x){
        if(c=='a')ac++;
        else if(c=='b')bc++;
        else cc++;
    }
    int big=max(max(ac,bc),cc);
    int small=min(min(ac,bc),cc);
    if(big-small<=1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 3672
#include<stdio.h>
int main()
{
  long long int i,j,n,x,y;
  scanf("%lld", &n);
  int flag = 0;
  for(i=1;i<=3500;i++)
    {
      for(j=1;j<=3500;j++)
	{
	  x= n*i*j;
	  y= 4*i*j-n*j-n*i;
	  if(y>0)
	    {
	      if(x%y==0)
		{
		  printf("%lld %lld %lld",i,j,x/y);
		  flag = 1;
		  break;
		}
	    }
 
	}
      if (flag == 1) break;
    }
  return 0;
}

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

using namespace std;

const int MAXN = 200005;

int n, k, p[MAXN], minP[MAXN], maxP[MAXN], dp[MAXN];

int main() {
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; ++i)
        scanf("%d", &p[i]);

    set<int> s;
    for(int i = 0; i < n; ++i) {
        s.insert(p[i]);
        if (i >= k-2) {
            minP[i-k+2] = *s.begin();
            maxP[i-k+2] = *s.rbegin();
            s.erase(p[i-k+2]);
        }
    }

    dp[n-1] = 1;
    for(int i = n-2; i >= 0; --i)
        dp[i] = (p[i] < p[i+1]) ? (dp[i+1] + 1) : 1;

//    for(int i = 0; i < n; ++i)
//        printf("%d %d %d\n", dp[i], minP[i], maxP[i]);

    bool original = false;
//    bool last = (a[0] != 0);
    int ans = 0;

    for(int i = k-1; i < n; ++i) {
        if (dp[i-k+1] >= k) {
//            printf("original %d\n", i);
            original = true;
        } else if (i == k-1 || maxP[i-k+1] > p[i] || p[i-k] > minP[i-k+1]) {
//            printf("increase ans %d\n", i);
            ++ans;
        }
    }
    if (original)
        ++ans;

    printf("%d", ans);

    return 0;
}


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

const int N=3*1e5+5;

struct node{
	int x,y;
}s[N];

int h[N],l[N],ans,n,m,t,lmax,rmax,tot,la,lb;
bool a[N],b[N];

int main() {
	scanf("%d%d%d",&n,&m,&t);
	for(int i=1,x,y;i<=t;i++) {
		scanf("%d%d",&x,&y);
		h[x]++,l[y]++;
		s[i].x=x,s[i].y=y;
	}
	for(int i=1;i<=n;i++) {
		lmax=max(lmax,h[i]);
	}
	for(int i=1;i<=m;i++) {
		rmax=max(rmax,l[i]);
	}
	for(int i=1;i<=n;i++) {
		if(h[i]==lmax) a[i]=1,la++;
	}
	for(int i=1;i<=m;i++) {
		if(l[i]==rmax) b[i]=1,lb++;
	}
	for(int i=1;i<=t;i++) {
		if(a[s[i].x]&&b[s[i].y]) {
			tot++;
		}
	}
	if(tot==la*lb) printf("%d",lmax+rmax-1);
	else printf("%d",lmax+rmax);
}

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

using namespace std;

const int N = (int)3e3 + 5, mod = (int)1e9 + 7;
int n, m, rMost[N], dp[N][N], rPref[N], n0Pref[N];
string s;

int add(int _a, int _b) {
    _a += _b;
    if (_a >= mod) _a -= mod;
    return _a;
}

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

//    freopen("test.INP", "r", stdin);

    cin >> n >> m >> s;
    while (m --) {
        int l, r; cin >> l >> r;
        rMost[l] = max(rMost[l], r);
    }

    s = ' ' + s;
    for (int i = 1; i <= n; ++i) {
        rMost[i] = max(rMost[i], i);
        rPref[i] = max(rPref[i - 1], rMost[i]);
        n0Pref[i] = n0Pref[i - 1] + (s[i] == '0');
    }

    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int n0 = 0; n0 <= i; ++n0) if (dp[i][n0]) {
            int n1 = i - n0, rem0 = n0Pref[ rPref[i + 1] ] - n0, rem1 = rPref[i + 1] - n0Pref[ rPref[i + 1] ] - n1;
            if (rem0) dp[i + 1][n0 + 1] = add(dp[i + 1][n0 + 1], dp[i][n0]);
            if (rem1) dp[i + 1][n0] = add(dp[i + 1][n0], dp[i][n0]);
        }
    }

    int ans = 0;
    for (int n0 = 0; n0 <= n; ++n0) ans = add(ans, dp[n][n0]);
    cout << ans;

    return 0;
}
/*
110111

011111
101111
110111
111011

011111
101111
110111
111011
111101
111110
*/


Measured memory_bytes: 33920
#include<bits/stdc++.h>
#define magic ios_base::sync_with_stdio(false);cin.tie(nullptr)
using namespace std;
#define forn(i,n) for(int i=1;i<=n;i++)
#define forRn(i,n) for(int i=n;i>=1;i--)
#define forz(i,n) for(int i=0;i<n;i++)
#define forRz(i,n) for(int i=n-1;i>=0;i--)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define mod 1000000007
#define INF 1023456789
#define pii pair<int,int>

int arr[100005];
int main(void){
    magic;
    int N,K;
    cin>>N>>K;
    int ans = 0;
    while(N){
        N/=K;
        ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256
MAX = 10**6+100
MOD = 10**9+7
fact = [0]*MAX #fact[i]: i!
inv = [0]*MAX #inv[i]: iの逆元
finv = [0]*MAX #finv[i]: i!の逆元
fact[0] = 1
fact[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1
    
for i in range(2, MAX):
    fact[i] = fact[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

X, Y = map(int, input().split())
ans = 0

for i in range(X+1):
    if (X-i)%2==0 and (X-i)//2==Y-2*i:
        ans += C(Y-i, i)

print(ans)

Measured memory_bytes: 90384
#include <iostream>
#include <cstdio>
#include <map>
#define N 200005
#define PI pair<int, int>
#define F first
#define S second
using namespace std;

int n, m1, m2, a1[N], a2[N];
map<PI, int> v;
int f(int p, int q[]) {
	if (q[p] == p) return p;
	return q[p] = f(q[p], q);
}

int main()
{
	int i, t1, t2;
	cin >> n >> m1 >> m2;
	for (i = 1; i <= n; i++) a1[i] = i;
	for (i = 1; i <= n; i++) a2[i] = i;
	while (m1--) {
		scanf ("%d %d", &t1, &t2);
		t1 = f(t1, a1);
		t2 = f(t2, a1);
		if (t1 != t2) a1[t1] =t2;
	}
	while (m2--) {
		scanf ("%d %d", &t1, &t2);
		t1 = f(t1, a2);
		t2 = f(t2, a2);
		if (t1 != t2) a2[t1] =t2;
	}
	for (i = 1; i <= n; i++) {
		f(i, a1);
		f(i, a2);
		v[PI(a1[i], a2[i])]++;
	}
	for (i = 1; i <= n; i++) {
		printf("%d ", v[PI(a1[i], a2[i])]);
	}
    return 0;
}


Measured memory_bytes: 13568
#include <stdio.h>
int main()
{
  int a,b,d,r;
  double ax,bx,f;
  scanf("%d%d",&a,&b);
  ax=a;
  bx=b;
  f=ax/bx;
  d=a/b;
  r=a%b;
  printf("%d %d %f",d,r,f);
       return 0;
}

Measured memory_bytes: 636
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<ceil(log2(double(n)))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,rec=0,t1,t2,t3;
string s;
int main(){
	scanf("%d",&n);
	rb(j,1,n){
		cin>>s;
		int len=s.length();
		if(s[0]=='B'){
			if(s[len-1]=='A'){
				t1++;
			}
			else{
				t2++;
			}
		}
		if(s[len-1]=='A'){
			if(s[0]!='B') t3++;
		}
		for(int i=0;i<len-1;i++){
			if(s[i]=='A'&&s[i+1]=='B') rec++;
		}
	}
	if(t1){
		rec+=t1-1;
	}
	if(t1){
		if(t2){
			t2--;
			rec+=1;
		}
		if(t3){
			t3--;
			rec+=1;
		}
	}
	rec+=min(t2,t3);
	printf("%d\n",rec);
	return 0;
}


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

#define int long long

signed main() {
    int n, p;
    cin >> n >> p;
    int cnt[2] = {0};
    for(int i=0; i<n; ++i) {
        int a;
        cin >> a;
        cnt[a%2]++;
    }
    if(cnt[1]) cout << (1ll<<(n-1)) << endl;
    else cout << (p?0:1ll<<n) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string B;
  cin>>B;
  for(int X=0;X<B.size();X++){
    if(B[X]=='A'){
      B[X]='T';
    }
    else if(B[X]=='C'){
      B[X]='G';
    }
    else if(B[X]=='T'){
      B[X]='A';
    }
    else{
      B[X]='C';
    }
  }
  cout<<B<<endl;
}


Measured memory_bytes: 3620
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1

def main():
    n,a,b=map(int, input().split())
    mx=min(a,b)
    mn=max(a+b-n,0)
    print(mx,mn)

main()

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
typedef long long ll;
ll replace(ll n, ll k);
int main(){
    ll n,k;
    cin >> n  >> k;
    n = n % k;
    while (replace(n,k) != -1) {
        n = replace(n,k);
    }
    cout << n;
}

ll replace(ll n, ll k){
    if (abs(k - n) < n)return abs(k - n);
    else return -1; 
}

Measured memory_bytes: 256
Q = int(input())
L = []
for i in range(Q):
    L.append([int(x) for x in input().split()])
    
for i in range(Q):
    a = min(L[i])
    b = max(L[i])
    if a == b:
        ans = 2*a-2
    elif a+1 == b:
        ans = 2*a-2
    else:
        c = int((a*b)**0.5)
        if c**2 == a*b:
            c -= 1
        if c*(c+1) >= a*b:
            ans = 2*c-2
        else:
            ans = 2*c-1
    print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

char knowlist[101][101];

int main(void) {
	int n,nownum,now;
	int querynum;
	int query[100];
	int i,j;
	int hannin;
	while(1) {
		scanf("%d",&n);
		if(n==0)break;
		for(i=1;i<=n;i++) {
			for(j=1;j<=n;j++)knowlist[i][j]=0;
			/*knowlist[i][i]=1;*/
			scanf("%d",&nownum);
			for(j=0;j<nownum;j++) {
				scanf("%d",&now);
				knowlist[i][now]=1;
			}
		}
		scanf("%d",&querynum);
		for(i=0;i<querynum;i++)scanf("%d",&query[i]);
		hannin=-1;
		for(i=1;i<=n;i++) {
			for(j=0;j<querynum;j++) {
				if(!knowlist[i][query[j]])break;
			}
			if(j>=querynum) {
				if(hannin==-1)hannin=i; else {hannin=-1;break;}
			}
		}
		printf("%d\n",hannin);
	}
	return 0;
}

Measured memory_bytes: 0
N, K =map(int, input().split())
A = [int(a) - 1 for a in input().split()]
idx = 0
if K<=N:
    for i in range(K):
        idx = A[idx]
    print(idx + 1)
    exit() #全ての実行をここで終了

t = [-1] * N
t[0] = 0
for i in range(1, N):
    idx = A[idx]
    last = i
    if t[idx] != -1:
        break
    t[idx] = i

d = i - t[idx]
K = K - i
amari = K%d

for i in range(amari):
    idx = A[idx]
print(idx + 1)
    



Measured memory_bytes: 32268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp72 {
    class Program {
        static void Main(string[] args) {
            string Sa = Console.ReadLine();
            string Sb = Console.ReadLine();
            string Sc = Console.ReadLine();

            int nowIndex_a = 0;
            int nowIndex_b = 0;
            int nowIndex_c = 0;

            char now = 'a';
            char next = ' ';

            while (true) {
                //Console.WriteLine(now);

                if ((nowIndex_a >= Sa.Length && now == 'a') || (nowIndex_b >= Sb.Length && now == 'b') || (nowIndex_c >= Sc.Length && now == 'c')) {
                    Console.WriteLine(now.ToString().ToUpper());
                    break;
                }

                switch (now) {
                    case 'a':
                        next = Sa[nowIndex_a];
                        nowIndex_a++;
                        break;
                    case 'b':
                        next = Sb[nowIndex_b];
                        nowIndex_b++;
                        break;
                    case 'c':
                        next = Sc[nowIndex_c];
                        nowIndex_c++;
                        break;
                }
                
                now = next;
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
 ll n;
  cin >> n;
 const ll nmax=100;
 vvll cnt(nmax,vll(nmax,0));
 rep(i,0,n){
  long double b;
   cin >> b;
   ll a=(b*mod)+0.5;
   ll x=0,y=0;
   while(a%2==0){
    a/=2;
    x++; 
   }
   while(a%5==0){
    a/=5;
    y++; 
   }
   cnt[x][y]++;
 }
 
  ll ans=0;
  rep(i,0,nmax){
   rep(j,0,nmax){
    rep(k,0,nmax){
     rep(l,0,nmax){
      if(P(i,j)>P(k,l)) continue;
      if(i+k<18||j+l<18) continue; 
      if(i==k&&j==l) ans+=cnt[i][j]*(cnt[i][j]-1)/2;
      else ans+=cnt[i][j]*cnt[k][l]; 
     }
    }
   }
  }
  cout << ans << endl;
}  
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
ll gcd(ll a,ll b){
	return (b?gcd(b,a%b):a);
}
ll lcm(ll a,ll b){
	if(a==-1||b==-1)return -1;
	ll g=gcd(a,b);
	a/=g;
	if(a>(ll)2e18/b)return -1;
	return  a*b;
}
ll N,M,A[20],P[20];
ll f[(1<<20)],rui[(1<<20)];

void solve(vector<ll> v,ll k){
	if(k==N){
		return;
	}
	ll K=(1<<k);
	vector<ll> L,R;
	for(auto t:v){
		if(t&K)R.push_back(t);
		else L.push_back(t);
	}
	solve(R,k+1);
	for(auto t:R){
		rui[t]=f[t];
	}
	reverse(R.begin(),R.end());
	for(ll d=k+1;d<N;d++){
		for(auto t:R)if(t&(1<<d)){
			rui[t-(1<<d)]+=rui[t];
		}
	}
	for(auto t:R){
		f[t-K]-=rui[t];
	}
	solve(L,k+1);
}

ll lcms[(1<<20)];

int main(){
	cin>>N>>M;
	rep(i,N)cin>>A[i];
	rep(i,N)cin>>P[i];
	vector<ll> v;
	for(ll i=0;i<(1<<N);i++)v.push_back(i);
	lcms[0]=1;
	for(ll i=1;i<(1<<N);i++){
		for(ll j=0;j<N;j++)if(i&(1<<j)){
			lcms[i]=lcm(lcms[i-(1<<j)],A[j]);
			break;
		}
		if(lcms[i]==-1)f[i]=0;
		else f[i]=M/lcms[i];
	}
	solve(v,0);
	long double ans=0;
	for(ll i=0;i<(1<<N);i++){
		long double res=1;
		for(ll j=0;j<N;j++)if(i&(1<<j)){
			res*=0.01*(100.0-(long double)P[j]);
		}
		res=1-res;
		res*=f[i];
		ans+=res;
	}
	cout<<fixed<<setprecision(9)<<ans<<endl;
}




Measured memory_bytes: 68492