akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<int> v;
bool checked[5005][5005];
set<i_i> st;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    v.resize(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++) {
        st.insert({v[i], i});
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            if(checked[i][j]) continue;
            checked[i][j] = true;
            int now = 2;
            int a = v[j];
            int LAST = j;
            while(true) {
                a += v[j] - v[i];
                auto itr = st.lower_bound({a, 0});
                if(itr != st.end() && (*itr).first == a) {
                    now++;
                    checked[LAST][(*itr).second] = true;
                    LAST = (*itr).second;
                } else break;
            }
            chmax(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 27508
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[][] A = new int[3][3];
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        A[i][j] = sc.nextInt();
      }
    }
    int N = sc.nextInt();
    int[] b = new int[N];
    for(int n = 0; n < N; n++){
      b[n] = sc.nextInt();
      for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
          if(A[i][j] == b[n]){
            A[i][j] = 0;
          }
        }
      }
    }
    String ans = "No";
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        if((A[i][0] + A[i][1] + A[i][2] == 0) || (A[0][j] + A[1][j] + A[2][j] == 0) || (A[0][0] + A[1][1] + A[2][2] == 0) || (A[0][2] + A[1][1] + A[2][0] == 0)){
          ans = "Yes";
        }
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
#include <algorithm>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, 0, n){
        cin >> h[i];
    }
    int dp[n+1];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    rep(i, 2, n){
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2]);
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
import std.stdio;
void main() {
	for (;;) {
		int a, b, r;
		char o;
		"%d %c %d\n".readf(&a, &o, &b);
		if (o == '?') break;
		r = o == '+' ? a + b
			: o == '-' ? a - b
			: o == '*' ? a * b
			: o == '/' ? a / b
			: 0;
		r.writeln;
	}
}

Measured memory_bytes: 2492
s = [0, 0]

gets.to_i.times do
  cards = gets.split
  if cards.uniq.size == 1
    s[0] += 1
    s[1] += 1
    next
  end
  judge = cards.sort
  s[judge[1] == cards[1] ? 1 : 0] += 3
end

puts "#{s[0]} #{s[1]}"

Measured memory_bytes: 8856
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

X,K,D=get_i
if X.abs>K*D
    puts X.abs-K*D
    exit
end
n=K-X.abs/D
if n.even?
    puts X.abs%D
else
    puts D-X.abs%D
end

Measured memory_bytes: 14352
#include<iostream>
using namespace std;
int main()
{
int a1,b1,c1;
cin>>a1>>b1>>c1;
if(a1==b1 && a1!=c1)
{
cout<<"Yes";
}
else if(b1==c1 && c1!=a1)
{
 cout<<"Yes";
}
else if(a1==c1 && a1!=b1)
{
 cout<<"Yes";
}
else
{
 cout<<"No";
}
return 0;
}

Measured memory_bytes: 888
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(n):
  if a[i]%2 != 0:
    continue
  elif a[i]%2 == 0:
    while True:
      if a[i]%2 != 0:
        break
      else:
        a[i] //= 2
        count += 1
print(count)

Measured memory_bytes: 4148
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int N,M;
    cin >> N >> M;
    int ans;
    int time=M*1900+(N-M)*100;
    ans=time*pow(2,M);
    cout << ans << endl;
}

Measured memory_bytes: 256
// #pragma GCC diagnostic error "-std=c++11"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const ll inf = 0x3f3f3f3f3f;
vector<string>v;
ll n,l;
string s;
int main(){
	cin>>n>>l;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		v.push_back(s);
	}
	sort(v.begin(),v.end());
	for(auto it:v)
	cout<<it;
	return 0;
}

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

using namespace std;

const int MAXN=2e5;

int n,k,a[MAXN+1];
long long sum=0;

int main() {
	scanf("%d %d",&n,&k);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1; i<=n-k; ++i) sum+=a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n;
    cin>>n;
    int a[n+1], b[n+1],c[n],sum=0;
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<=n;i++) cin>>b[i];
    for(i=1;i<n;i++) cin>>c[i];
    for(i=1;i<=n;i++)
    {
        sum+=b[a[i]];
        if(i>1)
        {
            if(a[i-1]==a[i]-1) sum+=c[a[i-1]];
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int root[200000];
int getRoot(int v){ return root[v] == -1 ? v : root[v] = getRoot(root[v]); }

int main(){
	int N, M, K;
	while(cin >> N >> M >> K){
		vector<int> c(N);
		for(auto& t : c) cin >> t;
		vector<pair<int, pair<int,int>>> edge(M);
		for(auto& e : edge){
			cin >> e.second.first >> e.second.second >> e.first;
			--e.second.first;
			--e.second.second;
		}
		sort(edge.begin(), edge.end());
		fill(root, root+N+K, -1);
		long long res = 0;
		int cnt = 0;
		for(auto& e : edge){
			int src = e.second.first;
			int dst = e.second.second;
			int p = getRoot(c[src] == 0 ? src : N + c[src] - 1);
			int q = getRoot(c[dst] == 0 ? dst : N + c[dst] - 1);
			if(p != q){
				root[q] = p;
				res += e.first;
				++cnt;
			}
			if(cnt == K-1) break;
		}
		cout << (cnt == K-1 ? res : -1) << endl;
	}
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n;
map<long long,int> mp;
int main()
{
	scanf("%d",&n);
	long long sum=0,res=0;
	mp[0]++;
	for (int i=0;i<n;i++)
	{
		long long x;
		scanf("%lld",&x);
		sum+=x;
		res+=mp[sum];
		mp[sum]++;
	}
	printf("%lld",res);
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	int64 A, B;
	cin >> A >> B;
	cout << max({A*2-1, B*2-1, A+B}) << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  ll one = min(s, min(h*2, q*4));
  ll two = min(d, 2*one);
  ll ans = n/2*two + n%2*one;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int[] n = new int[3];
		for(int i = 0;i < n.length;i++){
			n[i] = saori.saori_hayami();
		}
		Arrays.sort(n);
		System.out.println(n[0] + n[1]);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23124
def main():
  s = input()

  if is_easy(s):
    print("Yes")
  else:
    print("No")

def is_easy(str):
  odd = ["R", "U", "D"]
  even = ["L", "U", "D"]
  rtn = True

  odds = []
  evens = []

  for i in range(len(str)):
    if i % 2 == 0:
      odds.append(str[i])
    else:
      evens.append(str[i])

  for i in range(len(odds)):
    if not odds[i] in odd:
      rtn = False
  for i in range(len(evens)):
    if not evens[i] in even:
      rtn = False
  return rtn

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
//q069.cpp
//Tue Sep  1 20:19:27 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	vector<int> prime(100100,1);
	for (int i=2;i<100100;i++){
		if (prime[i]==1){
			for (int j=i*2;j<100100;j=j+i){
				prime[j] = 0;
			}
		}
	}

	vector<int> a(100010,0);
	rep(i,100010){
		if (i%2==1 && prime[i] && prime[(i+1)/2]){
			a[i] = 1;
		}
	}
	a[1] = 0;

	vector<int> rui(100001,0);
	for (int i=1;i<100001;i++){
		rui[i] = rui[i-1]+a[i];
	}

	rep(i,q){
		int l,r;
		cin >> l >> r;
		cout << rui[r]-rui[l-1] << endl;
	}

}

Measured memory_bytes: 4544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int K; string S;
    cin >> K >> S;
    int N = sz(S);
    if(N <= K) cout << S << endl;
    else{
        rep(i, K) cout << S[i];
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,s,e) for(int i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

typedef struct {
  int parent;
  int parent_color;
  vector<int> children;
}TNode;

int main() {
  int N; cin >> N;
  vector<int> AA,BB,CC;
  vector<TNode> tree(N);

  tree[1].parent = 0;
  tree[1].parent_color = 0;

  FOR(i,1,N) {
    int A, B; cin >> A >> B;
    AA.push_back(A);
    BB.push_back(B);
    tree[A].children.push_back(B);
    tree[B].parent=A;
  }
  int col_max = 0;
  FOR(i,1,N) {
    int col = 1;
    for(auto n:tree[i].children) {
      if(tree[i].parent_color == col) ++col;
      tree[n].parent_color=col;
      chmax(col_max, col);
      ++col;
    }
  }
  cout << col_max << endl;
  rep(i,N-1) {
    cout << tree[BB[i]].parent_color << endl;
  }
}

Measured memory_bytes: 6000
using System;

namespace BubbleSort
{
    class Program
    {
        static void Main(string[] args)
        {
            var arrayLength = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Split(' ');

            var array = new int[arrayLength];
            for (var i = 0; i < line.Length; i++)
            {
                array[i] = int.Parse(line[i]);
            }

            var counter = 0;
            bool flag = true;
            for (var sortIndex = 0; flag; sortIndex++)
            {
                flag = false;
                for (var i = array.Length - 1; i > sortIndex; i--)
                {
                    if (array[i] < array[i - 1])
                    {
                        var swap = array[i];
                        array[i] = array[i - 1];
                        array[i - 1] = swap;
                        flag = true;
                        counter++;
                    }
                }
            }
            var output = new string[array.Length];
            for (var index = 0; index < array.Length; index++)
            {
                output[index] = array[index].ToString();
            }
            Console.WriteLine(string.Join(" ", output));
            Console.WriteLine(counter);
        }
    }
}



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

int main() {
  int N;
  int t=1000000000;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int m;
    int p=0;//割った回数
    int q=m;
    cin >> m;//入力した数
    for (int j=0; j<m; j++){
      if (q%2==1)
        break;
      else{
        q/=2;
        p++;
      }
    }
    if(t>p)
      t=p;
    else
      continue;
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <tuple>
 
using namespace std;
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES" : "NO")
#define mod(a, b) (b + (a % b)) % b
#define MOD (int)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

void add_self (int& a, int b){ a += b; if(a >= MOD) a -= MOD; }
//-------------------------------------------------------------------------------------------------------//

void solve(){
    int n;
    cin >> n;
    vi a(n);
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        a[x - 1] = i;
    }
    for(int i = 0; i < n; i++) cout << a[i] << ' ';
}
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 1280
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)
h = []
for i in range(x):
    if(i + 1>k) : break
    for j in range(y):
        if((i + 1)*(j + 1)>k): break
        for l in range(z):
            if((i + 1)*(j + 1)*(l + 1)>k): break
            h.append(a[i] + b[j] +c[l])
h.sort(reverse = True)
for i in range(k):
    print(h[i])

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w)), ans;
  rep(i, h) rep(j, w) cin >> a[i][j];

  rep(i, h - 1) rep(j, w) {
    if (a[i][j] % 2 == 1) {
      ans.push_back({i + 1, j + 1, i + 2, j + 1});
      // cout << i + 1 << " " << j + 1 << " " << i + 2 << " " << j + 1 << endl;
      a[i][j]--;
      a[i + 1][j]++;
    }
  }
  rep(i, w - 1) {
    if (a[h - 1][i] % 2 == 1) {
      ans.push_back({h, i + 1, h, i + 2});
      // cout << h - 1 << " " << i + 1 << " " << h - 1 << " " << i + 2 << endl;
      a[h - 1][i]--;
      a[h - 1][i + 1]++;
    }
  }

  cout << ans.size() << endl;
  rep(i, ans.size()) rep(j, 4) printf("%d%c", ans[i][j], (j == 3 ? '\n' : ' '));
  // rep(i, h) rep(j, w)
  //     fprintf(stderr, "%d%c", a[i][j], (j == w - 1 ? '\n' : ' '));
  return 0;
}


Measured memory_bytes: 11156
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, ans = 0;
    cin >> n;
    vector<int> a(2 * n);
    rep(i, 0, 2 * n){
        cin >> a[i];
    }
    sort(all(a));
    rep(i, 0, n){
        ans += a[2 * i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
function main(input) {
    const args = input.split('\n');
    const N = args[0],
          nums = args.slice(1, args.length - 1);

    console.log(nums.filter((n, i) => nums.indexOf(n) === i).length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <stdio.h>
int main(void){
	int n,k,m=1;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++){
		int a=2*m,b=m+k;
		m=a<b?a:b;
	}
	printf("%d",m);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<queue>
using namespace std;
int inf=(1<<31)-1;
class road{
public:
    int to,distance;
    road(int a,int b):to(a),distance(b){
        
    }
};
class player{
public:
    int time;
    int k;
    int place;
    player(int a,int b,int c):time(a),k(b),place(c){
        
    }
};
class room{
public:
    int mk;
    int k;
    vector<road> rouka;
    room():mk(inf){
        
    }
};
bool operator<(const player &a,const player &b){
    return a.time<b.time;
}
bool operator>(const player &a,const player &b){
    return a.time>b.time;
}
int main(){
    int N,M,X;
    cin>>N>>M>>X;
    room *map;
    map= new room[N+1];
    for(int i=1;i<N+1;++i) {
        cin>>map[i].k;
        --map[i].k;
    }
    int a,b,c;
    for(int i=0;i<M;++i){
        cin>>a>>b>>c;
        map[a].rouka.push_back(road(b,c));
        map[b].rouka.push_back(road(a,c));
    }
    priority_queue<player,vector<player>,greater<player> >que;
    que.push(player(0,0,1));
    while(true){
        player dummy=que.top();que.pop();
        if(dummy.place==N){
            cout<<dummy.time<<endl;
            break;
        }
        if(map[dummy.place].k!=0){
            dummy.k=map[dummy.place].k*X;
        }
        if(map[dummy.place].mk<=abs(dummy.k)){
            continue;
        }else{
            map[dummy.place].mk=abs(dummy.k);
        }
        for(vector<road>::iterator p=map[dummy.place].rouka.begin(),fi=map[dummy.place].rouka.end();p!=fi;++p){
            int nk=(dummy.k>0)?max(dummy.k-p->distance,0):min(dummy.k+p->distance,0);
            if(map[p->to].mk<=abs(nk))continue;
            if(map[p->to].k*nk>=0){
                que.push(player(dummy.time+p->distance,nk,p->to));
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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

struct edge {
  int to;
  ll cost;
  edge(int t, ll c): to(t), cost(c) {};
};

using P = pair<ll, int>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  ll K;
  cin >> H >> W >> K;
  vector<int> X(2), Y(2);
  rep(i, 2) {
    cin >> X[i] >> Y[i];
    X[i]--; Y[i]--;
  }
  vector<string> S(H);
  rep(i, H) cin >> S[i];

  auto pos2int = [&](int x, int y) {
    return x * W + y;
  };

  int N = 4*H*W;
  vector<vector<edge>> G(N);
  vector<ll> d;
  vector<int> par;
  rep(i, H) rep(j, W) {
    rep(k, 4) rep(l, 4) {
      if(k == l) continue;
      G[pos2int(i, j)*4+k].emplace_back(pos2int(i, j)*4+l, -1);
    }
    rep(k, 4) {
      int nx = i+dx[k];
      int ny = j+dy[k];
      if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
      if(S[nx][ny] == '@') continue;
      G[pos2int(i, j)*4+k].emplace_back(pos2int(nx, ny)*4+k, 1);
    }
  }

  auto dijkstra = [&](int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    d = vector<ll>(N, longinf);
    par = vector<int>(N, -1);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()) {
      P p = que.top();
      que.pop();
      int v = p.second;
      if(d[v] < p.first) continue;

      for(int i=0; i<(int)G[v].size(); ++i) {
        edge e = G[v][i];
        if(e.cost == -1) {
          if(d[e.to] > (d[v] + K - 1) / K * K) {
            d[e.to] = (d[v] + K - 1) / K * K;
            que.push(P(d[e.to], e.to));
            par[e.to] = v;
          }
        } else {
          if(d[e.to] > d[v] + e.cost) {
            d[e.to] = d[v] + e.cost;
            que.push(P(d[e.to], e.to));
            par[e.to] = v;
          }
        }
      }
    }
  };
  dijkstra(pos2int(X[0], Y[0])*4);
  ll ans = longinf;
  rep(k, 4) ans = min(d[pos2int(X[1], Y[1])*4+k], ans);
  cout << (ans == longinf ? -1 : (ans+K-1)/K) << endl;
  return 0;
}


Measured memory_bytes: 465900
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll K;
ll n;
ll N[2021];
ll ans;
ll M;
ll dp[101][101];
ll cnt;
ll cntt;
ll A,B,C,D;
map<int, const char*>m;
map<int, const char*>::iterator ite;
string S;
 
 
 
int main(){
    cin >> S;
    n = S.size();
    ll b = 1;
    ll a = 0;
    ll l = 0;
    for(int i=0;i<n;i++){
        int k = S[n-i-1] - '0';
        l = (b * k + a)%2019;
        N[l] +=1;
        a = l;
        b = (10*b)%2019;
        
    }
    N[0] += 1;
    for(int i=0;i<2019;i++){
        ans += N[i]*(N[i]-1)/2;
    }
    
    cout << ans << endl;
    
}
 

Measured memory_bytes: 3780
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double d;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n,ans=0;
    cin>>n;
    oset<int>os;
    rep(i,1,n){
        int b;
        cin>>b;
        ans+=(os.order_of_key(b)==0);
        os.insert(b);
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
int main(){
    int flag=0;
    while(1){
        int n,a,b,c,d,r,aa,bb,cc,dd;
        scanf("%d",&n);
        if(n==0) return 0;
        if(flag) printf("\n");
        flag=1;
        scanf("%d %d %d %d",&a,&b,&c,&d);
        r=10*a+50*b+100*c+500*d-n;
        aa=a-(r%50)/10;
        bb=b-(r%100-r%50)/50;
        cc=c-(r%500)/100;
        dd=d-r/500;
        if(aa>0) printf("10 %d\n",aa);
        if(bb>0) printf("50 %d\n",bb);
        if(cc>0) printf("100 %d\n",cc);
        if(dd>0) printf("500 %d\n",dd);
    }
}

Measured memory_bytes: 600
fun main(args: Array<String>){
    val input = readLine()!!.map { it.toInt() }.toTypedArray()
    val result = D0929A(input).judge()
    println(result)
}

class D0929A(
  val ints: Array<Int>
){
    fun judge(): String{
        return ints.map { it.xor(8).toChar() }
                   .joinToString("")
    }
}

Measured memory_bytes: 31852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n,k;cin>>n>>k;
    vl b(n);rep(i,n)cin>>b[i];
    ll ans=LINF;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    for(int bit=0;bit<(1<<n);bit++){
        ll cnt=__builtin_popcountll(bit);
        if(cnt<k)continue;
        ll mx=0;
        ll cost=0;
        for(int i=0;i<n;i++){
            if((bit>>i)&1){
                if(mx>=b[i]){
                    cost+=mx-b[i]+1;
                    mx++;
                }
            }
            chmax(mx,b[i]);
        }
        //cout<<bit<<" "<<cost<<endl;
        chmin(ans,cost);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
        2, 3, 4, 6, 2, 1, 5, 2

pos soln- 1  1  2  4  1  4  3
opt soln- 1  1   2    1   1

method - 
 min(|2-3|, |2-4|) + min(|3-4|, |3-6|) + min(|2-4|, |6-4|) + min(|2-1|, |2-5|) + min(|1-5|, |2-1|)
    ||
*/


#include<bits/stdc++.h>
#include<iostream>

using namespace std;

int main(void){
    int n;
    cin >> n;
    int height[n];
    int arr[n];

    for(int i=0; i<n; ++i){
        cin >> height[i];
        arr[i] = INT_MAX;
    }
    
    arr[0] = 0;
    for(int i = 0; i<n; ++i) {
        for(int j = i+1; j< i+3; ++j) {
            if(j < n) {
                arr[j] = min(arr[j], arr[i]+abs(height[i]-height[j]));
            }
        }
    }

    cout << arr[n-1];
    return 0;
}

Measured memory_bytes: 1024
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;


int solve() {
    ll a,p;cin>>a>>p;
    cout << (3*a + p)/2 << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 256
#include <stdio.h>
int main()
{    int n, i;
   for(n = 1; n <=9; n = n + 1)

 {
      for(i = 1; i <= 9; i = i + 1)
 {
      printf("%dx%d=%d\n", n, i, n*i);
      }

        }
           return 0;
}



Measured memory_bytes: 2044
import sys
sys.setrecursionlimit(10**6)

n,m=map(int,input().split())
a=set()
for ii in range(m):
  a.add(int(input()))
#print(a)
b=[-1]*(n+2)

def delta_n(ii):
  if b[ii]>=0:
    return b[ii]

  if ii>n or ii in a:
    r=0
  elif ii==n:
    r=1
  else:
    r=delta_n(ii+1)+delta_n(ii+2)
  #print(ii,r)
  b[ii]=r
  return r

print(delta_n(0)%(7+10**9))

Measured memory_bytes: 494324
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string myStr = Console.ReadLine();

// 1文字の文字列をchar型へ（その1）
//
char c = myStr[0];
    c++;
      Console.WriteLine(c);
      
    }
    
  }

}

Measured memory_bytes: 25564
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

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

ll lcm(ll a, ll b){
	return (a*b) / gcd(a, b);
}

ll cnt[100005];

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

	memset(cnt,0,sizeof(cnt));

	ll n,sum = 0,q,i,j;

	cin >> n;

	for(i=0;i<n;i++)
	{
		ll x;
		cin >> x;
		sum += x;
		cnt[x]++;
	}

	cin >> q;

	for(i=0;i<q;i++)
	{
		ll x,y;

		cin >> x >> y;

		sum -= (cnt[x] * x);
		sum += (cnt[x] * y);
		cnt[y] += cnt[x];
		cnt[x] = 0;

		cout << sum << endl;
	}
	
}

Measured memory_bytes: 4424
n = gets(chomp:true).to_i

nums = []
n.times do
  nums << gets(chomp:true).to_i
end

count = 0

nums.each do |num|

  num != 2 && num.even? && next

  if num == 2 
    count += 1
    next 
  end

  flag = true
  (2..Math.sqrt(num).to_i).each do |sqrtnum|
    sqrtnum == 0 && next
    if num % sqrtnum == 0
      flag = false
    end
  end

   flag && count += 1
  
end

puts count


Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
using namespace std;

int main() {
	int N, K;
	string s;
	cin >> N >> K;
	cin >> s;
	if (s[K - 1] == 'A')
		s[K - 1] = 'a';
	if (s[K - 1] == 'B')
		s[K - 1] = 'b';
	if (s[K - 1] == 'C')
		s[K - 1] = 'c';
	cout << s << endl;
}

Measured memory_bytes: 256
n=gets.chomp.to_i
freq=Array.new(n){{}}
n.times do |i|
  s=gets.chomp
  s.chars.each do |c|
    if freq[i].has_key?(c)
      freq[i][c]+=1
    else
      freq[i][c]=1
    end
  end
end

t=''
('a'..'z').each do |c|
  ok, num=true, 10000
  n.times do |i|
    if freq[i].has_key?(c)
      num=[num, freq[i][c]].min
    else
      ok=false
    end
  end
  t+=c*num if ok
end

puts t

Measured memory_bytes: 1916
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    string s,t;
    cin>>s>>t;
    cout<<t<<s<<endl;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll> > v;
    v.resize(n);
    rep(i, n) { cin >> v[i].first >> v[i].second; }
    sort(v.begin(), v.end());
    ll ans = 0;
    rep(i, n) {
        if (v[i].second >= m) {
            ans += v[i].first * m;
            cout << ans << endl;
            return 0;
        } else {
            ans += v[i].first * v[i].second;
            m -= v[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) a[i]--;
    bool flag = false;
    int tmp = 0, cnt = 1;
    rep(i, 0, n){
        tmp = a[tmp];
        if(tmp == 1){
            flag = true;
            break;
        }
        cnt++;
    }
    if(flag) cout << cnt << endl;
    else cout << -1 << endl;
    return 0;
        
    
}


Measured memory_bytes: 3792
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//大きい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return bNum - aNum;}

long long _gcd(long long a,long long b){
    long long c;
    while(b!=0){c=a%b;a=b;b=c;}
    return a;
    
}
long long _lcm(long long a,long long b){long long c=_gcd(a,b);a/=c;return a*b;}

int main(void){
    int N;
    int cnt=0;
    scanf("%d",&N);
    int rng[N];
    for(int i=0;i<N;i++){
        scanf("%d",&rng[i]);
    }
    int j=0,k=1;
    while(j<N){
        if(rng[j]==k){
            cnt++;
            k++;
            j++;
        }else{
            j++;
        }
    }
    if(cnt==0){
        printf("-1");
        return 0;
    }else{
        printf("%d",N-cnt);
    }
}


Measured memory_bytes: 896
s = input()
if s[0] == 'A' and s[2:-1].count('C') == 1:
    for i in range(1,len(s)):
        if s[i].islower() == True:
            continue
        else:
            if s[i] == 'C':
                continue
            else:
                print('WA')
                exit()
else:
    print('WA')
    exit()
print('AC')

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

int main() {

  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  double dx = abs(x1 - x2);
  double dy = abs(y1 - y2);

  double ans = dx * dx + dy * dy;
  ans = sqrt(ans);

  printf("%.8f", ans);
  printf("\n");

  return 0;

}


Measured memory_bytes: 3288
import sys
x,n=map(int,input().split())
if n==0:
  print(x)
  sys.exit()
p=list(map(int,input().split()))
if not(x in p):
  print(x)
  sys.exit()
p.sort()
r=[]
for i in range(len(p)):
  if p[-1]>x: r.append(p.pop())
p.reverse()
r.reverse()
d=1
while True:
  if not(x-d in p):
    print(x-d)
    break
  elif not(x+d in r):
    print(x+d)
    break
  d+=1

Measured memory_bytes: 61756
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define ld long double
#define inf 1000000000
#define N 100005
int n; ll s,a[N],b[N],ans;
int main(){
	scanf("%d%lld",&n,&s);
	rep (i,1,n) scanf("%lld%lld",&a[i],&b[i]);
	int l=1,r=n; ans=0;
	while (l<=r){
		if (s<=a[l]){ ans+=a[r]-s; break; }
		if (s>=a[r]){ ans+=s-a[l]; break; }
		if (b[l]>=b[r]){
			ans+=a[r]-a[l];
			while (l<r && b[l]>=b[r]){ b[l]+=b[r]; r--; }
		} else{
			ans+=a[r]-a[l];
			while (l<r && b[l]<b[r]){ b[r]+=b[l]; l++; }
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
n,m = list(map(int, input().split()))
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

for r in range(n-m+1):
    for c in range(n-m+1):
        flg=True
        for i in range(m):
            for j in range(m):
                if a[r+i][c+j] != b[i][j]:
                    flg=False
                    break
            if not flg:
                break
        if flg:
            print('Yes')
            exit()

print('No')

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 200010;
const double eps = 1e-6;

int n;
int a[N];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", a + i);
        a[i] -= i;
    }
    sort(a + 1, a + 1 + n);

    int b = a[(n + 1) / 2];

    LL res = 0;
    for(int i = 1; i <= n; i++) res += abs(b - a[i]);
    cout << res << endl;
    return 0;
}


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

int color(int a,int b){
	if(!(a==b)){
		return 1;
	}
	else {
		return 0;
	}
}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	int cnt=0;
	cnt+=color(a,b);
	cnt+=color(b,c);
	cnt+=color(a,c);
	if(cnt==0){
		cout<<1<<endl;
	}
	else{
		cout<<cnt<<endl;
	}

	return 0;
}


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

struct Card {
  char suit;
  char value;
};

void bubbleSort(Card c[], int n) {
    Card tmp;
    for (int i=0; i<n; i++) {
        for (int j=n-1; j>i; j--) {
            if (c[j].value < c[j-1].value) {
                tmp = c[j];
                c[j] = c[j-1];
                c[j-1] = tmp;
            }
        }
    }
    
}

void selectionSort(Card c[], int n) {
    Card tmp;
    int minIdx;
    for (int i=0; i<n; i++) { // 0...4
        minIdx = i;
        for (int j=i; j<n; j++) { // 3...1
            if (c[j].value < c[minIdx].value) {
                minIdx = j;
            }
        }
        tmp = c[i];
        c[i] = c[minIdx];
        c[minIdx] = tmp;
    }
}

bool isStable(Card cBubble[], Card cSort[], int n) {
    for (int i=0; i<n; i++) {
        if (cBubble[i].suit != cSort[i].suit) {
            return false;
        }
    }
    return true;
}

void print(Card c[], int n) {
    for (int i=0; i<n; i++) {
        cout << c[i].suit << c[i].value;
        if (i != n-1) {
            cout << ' ';
        } else {
            cout << endl;
        }
    }
}

int main() {
    int n;
    Card cBubble[36], cSelection[36];
    cin >> n;
    // Add input to bubble sort target
    for (int i=0; i<n; i++) {
        cin >> cBubble[i].suit >> cBubble[i].value;
    }
    // Copy to selection sort target
    for (int i=0; i<n; i++) {
        cSelection[i] = cBubble[i];
    }
    
    bubbleSort(cBubble, n);
    selectionSort(cSelection, n);
    
    print(cBubble, n);
    cout << "Stable" << endl;

    print(cSelection, n);
    if (isStable(cBubble, cSelection, n)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}


Measured memory_bytes: 3092