akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-


def bubble_sort(cards, num):
    for tail in range(num-1, 0, -1):
        for right in range(0, tail):
            left = right + 1
            if cards[left][1] < cards[right][1]:
                cards[right], cards[left] = cards[left], cards[right]

    print(list_to_str(cards))


def selection_sort(cards, num):
    for head in range(num):
        min_i = head

        for target in range(head+1, num):
            if cards[target][1] < cards[min_i][1]:
                min_i = target
        cards[head], cards[min_i] = cards[min_i], cards[head]

    print(list_to_str(cards))


def is_stable(before, after, num):
    for i in range(num):
        for j in range(i+1, num):
            for a in range(num):
                for b in range(a+1, num):
                    if before[i][1] == before[j][1]\
                    and before[i] == after[b]\
                    and before[j] == after[a]:
                        return 'Not stable'
    return 'Stable'


def list_to_str(l, delimiter=' '):
    # The default delimiter is one space.
    return delimiter.join([str(v) for v in l])


if __name__ == '__main__':
    num = int(input())
    cards = input().split()
    cards_for_bubble = cards.copy()
    cards_for_selection = cards.copy()

    bubble_sort(cards_for_bubble, num)
    print(is_stable(cards, cards_for_bubble, num))

    selection_sort(cards_for_selection, num)
    print(is_stable(cards, cards_for_selection, num))

Measured memory_bytes: 7856
#include <stdio.h>

int main(void){
  int n , y;
  scanf("%d %d",&n,&y);
  int ans1 = -1, ans2 = -1, ans3 = -1;
  
  for(int i = 0;i <= n;i ++){
   int  j = n - i;
   for(int k = 0;k <= j;k ++){
     if(10000*i + 5000*(j-k) + 1000*k == y){
       ans1 = i;
       ans2 = (j - k);
       ans3 = k;
       i = n+1;
       j = n+1;
       k = n+1;
     }
   }
  }
  printf("%d %d %d\n",ans1 , ans2 , ans3);
  
  return 0;
}

  

Measured memory_bytes: 128
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class UnionFind
{
    private int[] data;
    public UnionFind(int size)
    {
        data = new int[size];
        for (int i = 0; i < size; i++) data[i] = -1;
    }
    public bool Unite(int x, int y)
    {
        x = Root(x);
        y = Root(y);
        if (x != y)
        {
            if (data[y] < data[x])
            {
                var tmp = y;
                y = x;
                x = tmp;
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    public bool IsSameGroup(int x, int y) => Root(x) == Root(y);
    public int Root(int x) => data[x] < 0 ? x : data[x] = Root(data[x]);
    public int getMem(int x) => -data[Root(x)];
}

public class hello
{
    public static int MOD = 1001;
    public static int[] fibo;
    public static void Main()
    {
        fibo = getFibo();
        string line0;
        for (; (line0 = Console.ReadLine()) != null;)
        {
            string[] line = line0.Trim().Split(' ');
            var n = int.Parse(line[0]);
            var d = int.Parse(line[1]);
            getAns(n, d);
        }
    }
    static void getAns(int n, int d)
    {
        var a = new int[n];
        Array.Copy(fibo, a, n);
        Array.Sort(a);
        var uf = new UnionFind(n + 1);
        for (int i = 0; i < n - 1; i++)
            if (Abs(a[i] - a[i + 1]) < d) uf.Unite(i, i + 1);
        var hs = new HashSet<int>();
        for (int i = 0; i < n; i++) hs.Add(uf.Root(i));
        Console.WriteLine(hs.Count());
    }
    static int[] getFibo()
    {
        var pre0 = 1;
        var pre1 = 1;
        var a = new int[1000];
        for (int i = 0; i < 1000; i++)
        {
            a[i] = (pre0 + pre1) % MOD;
            pre0 = pre1;
            pre1 = a[i];
        }
        return a;
    }
}



Measured memory_bytes: 18560
#!/usr/bin/env python3

import heapq

n, m, *a = map(int, open(0).read().split())

a = [*map(lambda x: -x, a)]
heapq.heapify(a)
for _ in range(m):
    heapq.heappush(a, -(-heapq.heappop(a) >> 1))
print(-sum(a))


Measured memory_bytes: 19988
////*24-AUG-19*///
//Why do we fall?//
// So we can learn to pick ourself up!//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;

typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(b.fi==a.fi)return (a.se>b.se);
    return (b.fi>a.fi);
}
signed main()
{
    fastio;
    R(h);
    int a=1;
    int ans=0;
    while(h!=0)
    {
        h=h/2;
        ans=ans+a;
        a=a*2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
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; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)




signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    char c[n];
    rep(i,n)cin >> c[i];
    intl r = 0;
    rep(i,n){
        if(c[i] == 'R')r++;
    }
    intl cnt = 0;
    rep(i,r){
        if(c[i] == 'R')cnt++;
    }
    cout << r - cnt << endl;
    return 0;
}


Measured memory_bytes: 3832
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
#include <atcoder/dsu>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
#define rreps(i, s, n) for (int i = n - 1; (int)(s) <= i; --i)
// reps(s,n)[::-1]
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
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;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;
class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* _sep, const char* _term) : sep(_sep), term(_term) {}
        template <class... Args> void operator()(const Args&... args) const { print(args...); }
        template <typename T> void pvec(const T& vec, size_t sz) const {
            for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
        }
        template <typename T> void pmat(const T& mat, size_t h, size_t w) {
            for (size_t i = 0; i < h; i++)
                for (size_t j = 0; j < w; j++) std::cout << mat[i][j] << (j == w - 1 ? term : sep);
        }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail> void print(const T& head, const Tail&... tail) const {
            std::cout << head, print_rest(tail...);
        }
        template <class T, class... Tail> void print_rest(const T& head, const Tail&... tail) const {
            std::cout << sep << head, print_rest(tail...);
        }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints print;

void solve() {
    int n, m;
    cin >> n >> m;
    atcoder::dsu d(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        d.merge(a, b);
    }
    VV<int> G = d.groups();
    print()((int)G.size() - 1);
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 8976
import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

arr1 = [a, b, c, d, e]
arr2 = [b, c, d, e]
f = 0
for x, y in itertools.product(arr1, arr2):
  if abs(x - y) > k:
    f += 1
if f == 0:
  print('Yay!')
else:
  print(':(')


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> cnt(n,0);
    for(int i=n-1; i>=0; i--){
        int sum = 0;
        for(int j=i*2+1; j<n; j+=(i+1)){
            //cout << j << endl;
            if(j>n) break;
            sum += cnt[j];
        }
        if(sum%2==0 && a[i]==0) cnt[i]=0;
        else if(sum%2==0 && a[i]==1) cnt[i]=1;
        else if(sum%2==1 && a[i]==0) cnt[i]=1;
        else if(sum%2==1 && a[i]==1) cnt[i]=0;
    }

    int m = 0;
    vector<int> ans;
    rep(i,n){
        if(cnt[i]==1){
            m++;
            ans.push_back(i+1);
        }
    }

    cout << m << endl;
    for(auto x: ans){
        cout << x << endl;
    }
}

Measured memory_bytes: 5424
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    static void Main(string[] args)
    {
		string[] input = Console.ReadLine().Split(' ');
		int N = int.Parse(input[0]);
		int X = int.Parse(input[1]);

		string[] inputL = Console.ReadLine().Split(' ');
		List<int> list = new List<int>();
        for(int i = 0; i < N; i++)
		{
			list.Add(int.Parse(inputL[i]));
		}

		int loc = 0;
		int cnt = 1;
		for(int i = 0; i < N; i++)
		{
			loc = loc + list[0];
			list.RemoveAt(0);
			if (loc <= X)
			{
				cnt++;
			}
		}
		
		
		


			/*while (loc <= X && list.Count > 0)
			{
				loc = loc + list[0];
				cnt++;
				list.RemoveAt(0);
				if (list.Count == 0)
				{
					cnt++;
				}


			}*/


			Console.WriteLine(cnt);
		


	}
}




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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;


int main() {
    int n,m;cin>>n>>m;
    vector<int>x(m),dif(m-1);

    rep(i,m){
        cin>>x[i];
    }

    sort(x.begin(),x.end());

    rep(i,m-1){
        dif[i]=abs(x[i+1]-x[i]);
    }

    sort(dif.begin(),dif.end());

    int ans=0;

    rep(i,m-n){
        ans+=dif[i];
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
 

int main()
{
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2])
    {
        cout<<"No\n";
    }
    else
        cout<<"Yes\n";

    return 0;   
}
 
 


Measured memory_bytes: 256
def assign_color
  color_id = 1
  $n.times do |i|
    if $color[i].nil?
      $s << i
      while !$s.empty?
        u = $s.pop
        dfs(u, color_id)
      end
      color_id += 1
    end
  end
end

def dfs(u, color_id)
  # 再帰だとstack level too deep (SystemStackError) が出てしまうので、
  # スタックを用いる。
  # puts "unit: #{u}, #{$color.join(' ')}"
  $color[u] = color_id
  $g[u].each do |v|
    if $color[v].nil?
      $s << v
    end
  end
end


$n, m = gets.split.map(&:to_i)
$g = Array.new($n) { Array.new() }
m.times do
  u, f = gets.split.map(&:to_i)
  $g[u] << f
  $g[f] << u
end

$s = []
$color = Array.new($n, nil)
assign_color

q = gets.to_i
q.times do
  s, t = gets.split.map(&:to_i)
  if $color[s] == $color[t]
    puts 'yes'
  else
    puts 'no'
  end
end


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < n; i++)

int main(){
    int H, N;
    cin >> H >> N;
    vector<int> A(N);
    rep(i, N) cin >> A.at(i);
    int sum = 0;
    rep(i, N) sum += A.at(i);
    if(H <= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    vector< int > a(N);
    cin >> a;
    
    whole(sort, a);
    a.erase(whole(unique, a), a.end());
    
    cout << (a.size() == N ? "YES" : "NO") << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main()
{
  int a,b;
  cin>>a>>b;
  --a;
  --b;
  cout<<(b+a-1)/a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
int main()
{
          ios_base::sync_with_stdio(0);
          cin.tie(0);

          int t=1;
          //cin>>t;
          while(t--)
          {
                    int n;
                    cin>>n;
                    string s;
                    int r=0,w=0;
                    cin>>s;
                    for(int i=0;i<n;++i)
                    {
                         if(s[i]=='W')
                              w++;
                         else
                              r++;
                    }
                    if(r==0 || w==0)
                         cout<<0;
                    else
                    {
                         string sub = "WR";
                         int count=0;
                         for(int i=n-1;i>=0;--i)
                         {
                              if(s[i]=='R')
                                   count++;
                              else
                                   break;
                         }
                         int red=0;
                         for(int i=0;i<r;++i)
                         {
                              if(s[i]=='R')
                                   red++;
                         }
                         int white=0;
                         for(int i=n-1;i>n-w;--i)
                         {
                              if(s[i]=='W')
                                   white++;
                         }
                         if(red==0)
                              cout<<min(w,r);
                         else
                         {
                              cout<<min(r-red,w-white);
                         }
                         //cout<<min(min(w,r),count);
                    }
          }
          return 0;
}


Measured memory_bytes: 3728
n,m,k=map(int,input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
A=[0]
B=[0]
p=0
q=0
ans=0

for i in range (n):
  p+=a[i]
  A.append(p)
for i in range (m):
  q+=b[i]
  B.append(q)

import bisect
for i in range (n+1):
  if A[i]<=k:
    index = bisect.bisect_right(B, k-A[i])
    ans = max(ans, index+i-1)
    
  if A[i]>k:
    break
 
print(ans)
  



Measured memory_bytes: 47380
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (long i = long(s); i < long(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long;
using ull = unsigned long long;
using namespace std;

long mmin(long a, long b){
    if(a < b) return a;
    else return b;
}
long mmax(long a, long b){
    if(a < b) return b;
    else return a;
}

const ll inf = 100100100100;

int main(){
    ll a, b, q; cin >> a >> b >> q;
    vector<ll> s(a); rep(i,a) cin >> s[i];
    vector<ll> t(b); rep(i,b) cin >> t[i];

    rep(i,q){
        ll x; cin >> x;
        ll ss = lower_bound(all(s),x)-s.begin();
        ll tt = lower_bound(all(t),x)-t.begin();

        ll aa = s[ss]-x; if(ss == a) aa = inf;
        ll ab = t[tt]-x; if(tt == b) ab = inf;
        ll a1 = mmax(aa,ab);
        ll ba = x-s[ss-1]; if(ss == 0) ba = inf;
        ll bb = x-t[tt-1]; if(tt == 0) bb = inf;
        ll a2 = mmax(ba,bb);
        ll cc = 2*aa + bb;
        ll cd = 2*ab + ba;
        ll a3 = mmin(cc,cd);
        ll dc = 2*bb + aa;
        ll dd = 2*ba + ab;
        ll a4 = mmin(dc,dd);
        ll ans = mmin(mmin(a1,a2),mmin(a3,a4));
        cout << ans << endl;
    }
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 500500;

LL L[MAX], R[MAX];
LL U[MAX], D[MAX];

bool intersect(LL x1, LL y1, LL x2, LL y2)
{
	if (y1 < x2) return false;
	if (y2 < x1) return false;
	return true;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	LL n, a, b, c, d;
	cin>>n>>a>>b>>c>>d;

	L[0] = R[0] = a;
	FOR (i, 1, n)
	{
		L[i] = L[i-1] + c;
		R[i] = R[i-1] + d;
	}

	U[n-1] = D[n-1] = b;
	RFOR(i, n-1, 0)
	{
		D[i] = D[i+1] + c;
		U[i] = U[i+1] + d;
	}

	FOR (i, 0, n)
	{
		if (intersect(L[i], R[i], D[i], U[i]))
		{
			cout<<"YES"<<endl;
			return 0;
		}
	}

	cout<<"NO"<<endl;
}


Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n, k;
  cin >> n >> k;
  int maxv = (n - 1) * (n - 2) / 2;
  if (k > maxv) {
    puts("-1");
    return 0;
  }
  int m = (n - 1) * (n - 2) / 2 - k + n - 1;
  int cur = 0;
  cout << m << endl;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if(cur >= m) break;
      cout << i << " " << j << endl;
      cur++;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include <numeric>
#include<climits>
#include<cfloat>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

using namespace std;
typedef pair<int,bool> Pair;

int main(){

	int N;
	vector<double> v(50);
	double sum = 0.0;

	cin >> N;

	for(int i = 0; i < v.size(); ++i) v[i] = 1001;

	for(int i = 0; i < N; ++i) cin >> v[i];

	sort(v.begin(),v.end());	

	sum = (v[0]+v[1])/2.0;

	for(int i = 2; i < N; ++i) sum = (sum + v[i])/2.0;

	cout << sum << endl;

  return 0;

}

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

int main() {
  string palavra1, palavra2;

  cin>>palavra1>>palavra2;

  int lcsDP[palavra1.length()+1][palavra2.length()+1];

  for (int i=0; i<=palavra1.length(); i++){ 
    for (int j=0; j<=palavra2.length(); j++){ 
      if (i == 0 || j == 0) 
        lcsDP[i][j] = 0; 
      else if (palavra1[i-1] == palavra2[j-1]) 
        lcsDP[i][j] = lcsDP[i-1][j-1] + 1; 
      else
        lcsDP[i][j] = max(lcsDP[i-1][j], lcsDP[i][j-1]); 
    } 
  }


  int i = palavra1.length(), j = palavra2.length(); 
  int ultimo = lcsDP[i][j]; 

  char lcsString[ultimo+1]; 
  lcsString[ultimo] = '\0'; 
  while (i > 0 && j > 0){ 
    if (palavra1[i-1] == palavra2[j-1]){ 
      lcsString[ultimo-1] = palavra1[i-1];
      i--; 
      j--; 
      ultimo--;
    } else if (lcsDP[i-1][j] > lcsDP[i][j-1]){
      i--; 
    }else{
      j--; 
    }
  } 
  
  
  cout<<lcsString<<endl;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    ll n = s.size();
    ll m = 1;
    vec<ll> t(2019); t[0] = 1;
    ll ans = 0,cur = 0;
    rep(i,n){
        cur = ((cur + (s[n-i-1] - '0')*m)%2019 + 2019)%2019;
        m = m*10%2019;
        ans+= t[cur];
        t[cur]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3732
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	d := scanInts(n)
	c := make([]int, n)

	ma := 0
	for i := 0; i < n; i++ {
		c[d[i]]++
		ma = max(ma, d[i])
	}

	if c[0] != 1 || d[0] != 0 {
		fmt.Fprintln(wr, 0)
		return
	}

	ans := 1
	for i := 0; i < ma; i++ {
		ans *= mpow(c[i], c[i+1])
		ans %= mod
	}

	fmt.Fprintln(wr, ans)
}

const mod = 998244353

func mpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n){
                cout<<"Yes"<<endl;
                goto Exit;
            }
        }
    }
    cout<<"No"<<endl;
    
    Exit:
        ;
}

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


int main(){
	string s,t;
	int ans=1e5;
	cin>>s>>t;
	for(int i=0; i<s.size()-t.size()+1; i++){
		int cnt=0;
		string aux = s.substr(i, t.size());
		for(int j=0; j<t.size(); j++){
			if(aux[j]!=t[j])cnt++;
		}
		ans = min(ans, cnt);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3584
s = input()
t = input()

scnt = len(s)
tcnt = len(t)

change = 10**3

for i in range (0, scnt - tcnt + 1):
  cnt = 0
  for j in range(tcnt):
    if s[i+j] != t[j]:
      cnt += 1
  if change > cnt:
    change = cnt

print(change)

Measured memory_bytes: 9052
import sys

#fp = open("input.txt", "r")
fp = sys.stdin

def countMaxLength(li):
    cnt = 1
    prev = -1
    max_cnt = 1
    for i in li:
        if i == prev + 1:
            cnt += 1
        else:
            if cnt > max_cnt:
                max_cnt = cnt
            cnt = 1
        prev = i
        
    if cnt > max_cnt:
        max_cnt = cnt
    return max_cnt

def countMaxLengthWithWildCard(li, n):
    cnt = 1
    prev = -1
    res = []
    for i in li:
        if i == prev + 1:
            cnt += 1
        else:
            ele = []
            ele.append(cnt)
            ele.append( i == prev + 2 )
            res.append(ele)
            cnt = 1
        prev = i
    ele = []
    ele.append(cnt)
    ele.append(li[-1] == n)
    res.append(ele)

    max_cnt = 1
    for i in xrange(len(res)-1):
        cnt = res[i][0] + res[i+1][0] + 1 if res[i][1] else res[i][0]
        if cnt > max_cnt:
            max_cnt = cnt
    cnt = res[-1][0] if res[-1][1] else res[-1][0] + 1
    if cnt > max_cnt:
        max_cnt = cnt
    return max_cnt

while True:
    condition = map(int, fp.readline()[:-1].split(" "))
    if condition[0] + condition[1] == 0:
        break

    n = condition[0]
    k = condition[1]

    li = []
    flg = False
    for i in xrange(k):
        num = int(fp.readline()[:-1])
        if num == 0:
            flg = True
        else:
            li.append(num)

    li.sort()

    if flg:
        print countMaxLengthWithWildCard(li, n)
    else:
        print countMaxLength(li)

Measured memory_bytes: 8800
N = int(input())
A = list(map(int,input().split()))
dic = {}
for a in A:
    if a in dic:
        dic[a] += 1
        if N % 2 == 1 and a == 0:
            print(0)
            exit()
        elif dic[a] > 2:
            print(0)
            exit()
    else:
        dic[a] = 1
        if N % 2 == 1:
            if a % 2 == 1 or a >= N:
                print(0)
                exit()
        elif N % 2 == 0:
            if a % 2 == 0 or a >= N:
                print(0)
                exit()

ans = (2 ** (N // 2)) % ((10 ** 9) + 7)
print(ans)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    ll a = 100;

    int n = 0;

    while(a < x){
        ++n;
        a *= 1.01;
    }

    cout << n << endl;

    return 0;
    
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define vi vector < ll  int >
        #define CLR(a) memset((a),0,sizeof(a))
        #define mp make_pair
        #define hell 1000000007`
using namespace std;
const int N = 100000;


void solve()
{

        ll i,j=0,r=200,p,q,k=1,ans=0,d,y=0,x,n,h,flag=0,m=0,id,c,h1,h2,a1,b1,w;
        cin>>n;
        string s;
        cin>>s;
        if(n>=3200) cout<<s;
        else cout<<"red";






}


    signed main()
        {
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int t=1;
            //cin>>t;
            while(t--)
            solve();
        }


Measured memory_bytes: 256
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#include<map>
#include<set>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010;
int main()
{
    string s;
    cin>>s;
    int res=0;
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R') cout<<3<<endl;
    else if(s[0]=='R'&&s[1]=='R'||s[1]=='R'&&s[2]=='R') cout<<2<<endl;
    else if(s[0]=='S'&&s[1]=='S'&&s[2]=='S') cout<<0<<endl;
    else cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n,m;
int c[21];
ll dp[21][50001];

int main(){
	cin >> n >> m;
	rep(i,m)cin >> c[i];
	rep(i,21)rep(j,50001)dp[i][j] = INF;
	dp[0][0] = 0;
	rep(i,m){
		rep(j,50001)dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
		rep(j,50001){
			if(j+c[i] <= 50000)dp[i + 1][j + c[i]] = min(dp[i + 1][j]+1,dp[i][j+c[i]]);
		}
	}
	// rep(i,m){
	// 	rep(j,10)cout << dp[i][j] << " ";
	// 	cout << endl;
	// }
	cout << dp[m][n] << endl;
}


Measured memory_bytes: 11300
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String a =sc.next();
		String b=sc.next();



		char[] chara = a.toCharArray();
		char[] charb = b.toCharArray();

		for(int i=0;i<chara.length;i++) {
			for(int j=0;j<charb.length;j++) {

				if((int)chara[i]<(int)charb[j]) {
					System.out.print("Yes");
					return;
				}

			}
		}
		int aruhabetoA =0;
		int aruhabetoB =0;
		if(chara.length<charb.length) {
			for(int i=0;i<26;i++) {
				for(int j=0;j<chara.length;j++) {
					if(chara[j]==97+i) {
						aruhabetoA++;
					}
				}
				for(int j=0;j<charb.length;j++) {
					if(charb[j]==97+i) {
						aruhabetoB++;
					}
				}
				if(aruhabetoA>aruhabetoB) {
					System.out.print("No");
					return;
				}
				aruhabetoA =0;
				aruhabetoB =0;
			}

		}
		else {
			System.out.print("No");
			return;
		}
		System.out.print("Yes");

	}

}


Measured memory_bytes: 23636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    for(int i = 1; i < s.size(); i++){
        if(s[i-1]==s[i])  s[i-1] = '0';
    }
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i]!='0') cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 512
N,M = map(int,input().split())
conflict = []
for _ in range(M):
    a,b = map(int,input().split())
    conflict.append((a,b))

conflict.sort(key=lambda x: x[1])
count = 0
t = -1
for a,b in conflict:
    if t <= a:
        count += 1
        t = b
print(count)

Measured memory_bytes: 57960
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}


int main(){
    int n,k;
    cin >> n >> k;
    int ans=0;
    while(n!=0){
        n/=k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $k);

if ($a <= $k) {
    $k = $k - $a;
    $a = 0;
    if ($b <= $k) {
        $b = 0;
    } else {
        $b = $b - $k;
    }
} else {
    $a = $a - $k;
}
echo "$a $b";


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

using namespace std;

using int64 = long long;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

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

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

  int n, m;
  cin >> n >> m;
  auto orders = Make2DVector(n, m, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> orders[i][j];
      orders[i][j]--;
    }
  }

  vector<int> indexes(n, 0);
  vector<int> removed(m, 0);
  int ans = INT32_MAX;
  for (int k = 0; k < m; k++) {
    vector<int> counter(m);
    int max_value = -1;
    int max_arg = -1;
    for (int i = 0; i < n; i++) {
      int type = orders[i][indexes[i]];
      counter[type]++;
      if (UpdateMax(max_value, counter[type])) {
        max_arg = type;
      }
    }

    UpdateMin(ans, max_value);

    removed[max_arg] = 1;

    if (k == m - 1) break;
    
    for (int i = 0; i < n; i++) {
      while(removed[orders[i][indexes[i]]]) indexes[i]++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    vector<int>v;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    cout<<v[n/2]-v[(n/2)-1];
}


Measured memory_bytes: 892
#include <stdio.h>

int main(void)
{
	int i, n;
	scanf("%d", &n);
	for(i=n;i<=999;i++) {
		if(i/100 == i/10%10 && i/100 == i%10) {
			printf("%d\n", i);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main() {
  int N;
  cin >> N;
  int t=N,c=0;
  // ここにプログラムを追記
  while(t>0)c+= t%10,t = t/10;
  if(N%c == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[301][301][301];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
string r;
//char r[2];

P u[1];
queue<int> q;
stack<int> s;
//set<int> s;
map<int,int> p;

vector<P> v[333];


bool as(P a,P b)
{
  if(a.x!=b.x)
  return a.x<b.x;
  return a.y>b.y;
}

int f(int n,int m,int k)
{
  if(o[n][m][k]>=0) return o[n][m][k];
  for(int h=0;h<v[k].size();h++)
  {
    if((v[k][h].y==1&&m>=v[k][h].x)||(v[k][h].y==2&&(n>=v[k][h].x||m<v[k][h].x))||(v[k][h].y==3&&n<v[k][h].x))
    return o[n][m][k]=0;
  }
  if(k==a)
  {
    return o[n][m][k]=1;
  }
  int p=f(n,m,k+1);
  p+=f(n,k,k+1),p%=mod;
  p+=f(m,k,k+1),p%=mod;
  return o[n][m][k]=p;
}

int main()
{
  memset(o,-1,sizeof(o));
  scanf("%d %d",&a,&b);
  for(int t=1;t<=b;t++)
  {
    scanf("%d %d %d",&n,&m,&k);
    v[m].push_back({n,k});
  }
  x=(long long)f(0,0,1)*3%mod;
  printf("%lld",x);
}
//7




Measured memory_bytes: 106752
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long M = sc.nextLong();
    long num = 0;
    if(2 * N > M) {
      num = M / 2;
    } else {
      num = N;
      M -= 2 * N;
      num += M / 4;
    }
    System.out.println(num);
  }
}

Measured memory_bytes: 22612
def minHeapify x
  l = 2*x
  r = 2*x+1
  if l <= $n && $heap[l][0] < $heap[x][0]
    minimum = l
  else
    minimum = x
  end
  if r <= $n && $heap[r][0] < $heap[minimum][0]
    minimum = r
  end
  if minimum != x
    $heap[x], $heap[minimum] = $heap[minimum], $heap[x]
    minHeapify(minimum)
  end
end
 
def extract
  key = $heap[1]
  $heap[1] = $heap[$n]
  $n -= 1
  minHeapify(1)
  key
end
 
def insert key
  $n += 1
  $heap[$n] = key
  i = $n
  while i > 1 && $heap[i/2][0] > $heap[i][0]
    $heap[i], $heap[i/2] = $heap[i/2], $heap[i]
    i /= 2
  end
end

def dijkstra(n, l, pos, route, cost_d, cost_e)
  done = (n+1).times.map{ [false] * (l+1) }
  while true
    p = extract
    e, s, r = p
    return e if s == n
    next if done[s][r]
    done[s][r] = true
    route[s].each do |t|
      insert [e + cost_e[s][t], t, r]
      if r >= cost_d[s][t]
        insert [e, t, r - cost_d[s][t]]
      end
    end
  end
end

loop do
  n, m, l = gets.split.map(&:to_i)
  break if n == 0
  $heap = []
  $n = 0
  route = (n+1).times.map{ [] }
  cost_d = (n+1).times.map{ [0] * (n+1) }
  cost_e = (n+1).times.map{ [0] * (n+1) }
  m.times.map do
    s, t, d, e = gets.split.map(&:to_i)
    route[s] << t
    route[t] << s
    cost_d[s][t] = cost_d[t][s] = d
    cost_e[s][t] = cost_e[t][s] = e
  end
  insert [0, 1, l]
  p dijkstra(n, l, 1, route, cost_d, cost_e)
end

Measured memory_bytes: 13164
require 'matrix'
while gets
    a = $_.split.map(&:to_f)
    v1, v2, v3, v4 = a.each_slice(2).to_a.map{|xy| Vector[*xy]}
    puts (v1 - v2).inner_product(v3 - v4).abs < 1.0e-10 ? "YES" : "NO"
end

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
const ll mod = 998244353;
ll power(ll x, ll y, ll p) {
	ll res = 1ll;
	x = x % p;
	while (y) {
		if (y & 1ll)res = (res * x) % p;
		y = y >> 1ll;
		x = (x * x) % p;
	}
	return res;
}
signed main(){
  int r;
  cin>>r;
  cout<<r*r;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long 
#define mod 1000000007

int main()
{
	ll n,k;
	cin>>n>>k;
	ll a[n+10];
	for(ll i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	for(int i=n-1;i>=n-k;i--)
	{
		sum+=a[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<ll, int> line;
	rep(i,n){
		ll a;
		cin >> a;
		line[a]++;
	}
	ll mx1 = 0, mx2 = 0;
	for(auto p : line){
		if(p.second < 2) continue;
		if(p.first >= mx1){
			mx2 = mx1;
			mx1 = p.first;
			p.second -= 2;
		}
		if(p.second < 2) continue;
		if(p.first >= mx2){
			mx2 = p.first;
		}
	}
	ll ans = mx1 * mx2;
	cout << ans << endl;
	return 0;
}

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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

			//// 文字列の入力
			//string s = Console.ReadLine();

			//// 整数の入力
			//long n = long.Parse(Console.ReadLine());

			//// 文字列配列の入力
			//string[] inputStrArray = Console.ReadLine().Split(' ');

			//// 整数配列の入力
			//var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

			int n = int.Parse(Console.ReadLine());

			var ts = new List<long>();
			var xs = new List<long>();
			var ys = new List<long>();

			ts.Add(0);
			xs.Add(0);
			ys.Add(0);

			for (int i = 0; i < n; ++i) {
				var inputLongArray = Console.ReadLine().Split(' ').Select(k => long.Parse(k)).ToArray();
				ts.Add(inputLongArray[0]);
				xs.Add(inputLongArray[1]);
				ys.Add(inputLongArray[2]);
			}

			string result = "Yes";

			for (int i = 0; i < n; ++i) {
				if (n - i -1 < 0) {
					break;
				}

				var t = ts[n - i];
				var x = xs[n - i];
				var y = ys[n - i];
				var t2 = ts[n - i - 1];
				var x2 = xs[n - i - 1];
				var y2 = ys[n - i - 1];

				var difft = t - t2;
				var diffx = x - x2;
				var diffy = y - y2;

				if (diffx + diffy > difft) {
					result = "No";
					break;
				}

				if (difft % 2 == 0) {
					if ((diffx + diffy) % 2 == 0) {
						continue;
					} else {
						result = "No";
						break;
					}
				} else {
					if ((diffx + diffy) % 2 != 0) {
						continue;
					} else {
						result = "No";
						break;
					}
				}
			}


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 22708
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

string s;
bool table[100];

inline bool check(string s,char a){
  for(int i=0;i<(int)s.length();i++){
    if(s[i]!=a)return 0;
  }
  return 1;
}
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
   cin>>s;
   for(int i=0;i<(int)s.length();i++){
     table[s[i]-'a']=1;
   }
   string ss;
   int ans=999999999;
  for(char now='a';now<='z';now++){
    if(!table[now-'a'])continue;
    ss=s;
    string t="";
    int nowans=0;
    while(!check(ss,now)){
      for(int i=0;i<(int)ss.length()-1;i++){
        if(ss[i]==(char)now || ss[i+1]==(char)now){
          t+=now;
        }else{
          t+=ss[i];
        }
      }
      ss=t;
      t="";
      nowans++;
    }
    ans=min(ans,nowans);
  }
  cout<<ans<<"\n";
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>



int main(){
    
    int a, b;
    while(
          (scanf("%d",&a)) !=EOF){
    scanf("%d",&b);
    int sum=a+b;
    int i, count=0;
    for(i=1;sum>=i;i*=10){
        count++;
    }
    printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 600