akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

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 { 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, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

template <typename T>
struct BIT {
    int N;
    vector<T> d;

    BIT(int size) {
        N = size;
        d.resize(N + 1);
    }

    void add(int i, T x = 1) {
        for (int x = i; i <= N; i += i & -i) {
            d[i] += x;
        }
    }

    T sum(int a) {
        T x = 0;
        for (ll i = a; i > 0; i -= i & -i) {
            x += d[i];
        }
        return x;
    }

    T sum(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

int main() {
    INIT;

    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    BIT<ll> b(N);
    mint res = 0;

    rep(i, N) {
        res += i - b.sum(A[i]);
        b.add(A[i]);
    }

    ll res2 = 0;
    mint sum = 0;
    rep(i, N) {
        reps(j, i, N) {
            if (A[i] > A[j]) res2++;
        }

        rep(j, N) {
            if (A[i] > A[j]) sum += 1;
        }
    }
    // cout << res << "," << res2 << endl;
    // cout << sum << endl;

    mint ans = mint(res2) * K + sum * K * (K - 1) / 2;
    // cout << res * K << endl;
    // cout << sum * K * (K - 1) / 2 << endl;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100013,INF=1<<30;
vector<pair<int,ll>> Ga[MAX];
ll dis[MAX];

void dijkstra(int u){
    dis[u]=0;
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> PQ;
    
    PQ.push(make_pair(0,u));
    while(!PQ.empty()){
        ll a=PQ.top().first;
        int b=PQ.top().second;
        PQ.pop();
        if(dis[b]<a) continue;
        for(int i=0;i<Ga[b].size();i++){
            int c=Ga[b][i].first;
            ll d=Ga[b][i].second;
            if(dis[c]>dis[b]+d){
                dis[c]=dis[b]+d;
                PQ.push(make_pair(dis[c],c));
            }
        }
    }
    return;
}//a,dが長さ
int to[MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    
    for(int i=0;i<MAX;i++) dis[i]=INF;
    
    for(int i=0;i<N;i++){
        cin>>to[i];
        int a=to[i];
        if(a==0) continue;
        Ga[i].push_back({i+a,0});
    }
    
    for(int i=0;i<N;i++){
        for(int j=1;j<=6;j++){
            if(to[i]==0) Ga[i].push_back({i+j,1});
        }
    }
    
    dijkstra(0);
    
    cout<<dis[N-1]<<endl;
    
    //for(int i=0;i<N;i++) cout<<i<<" "<<dis[i]<<endl;
}



Measured memory_bytes: 13292
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct unionfind{
  int par[100010]; // 親ノード  必要に応じて要素数を変えよう
  int rank[100010]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<=n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  int size(int x){
    return rank[root(x)];
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      swap(x,y);
    }
    rank[x]=rank[x]+rank[y];
    par[y]=x;
  }
};
struct edge{
    int from;
    int to;
    int cost;
    edge(int f,int t, int w) :from(f), to(t), cost(w) { }
};
bool comp(const edge& e1,const edge& es){
  return e1.cost<es.cost;
}
int main(){
  int i,s,t,w,v,e,ans=0;
  scanf("%d %d\n",&v,&e);
  vector<edge> g;
  unionfind tree(v);
  for(i=0;i<e;i++){
    scanf("%d %d %d\n",&s,&t,&w);
    g.push_back(edge(s,t,w));
  }
  sort(g.begin(),g.end(),comp);
  for(i=0;i<e;i++){
    if(tree.same(g[i].to,g[i].from)==0){
      ans=ans+g[i].cost;
      tree.unite(g[i].to,g[i].from);
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 4572
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string s; cin >> s;
	vi va(n), vb(n);
	va[a] = 1;
	FOR(i, a + 1, n) {
		if (s[i] == '#')continue;
		bool ok = false;
		if (i > 0)ok |= va[i - 1];
		if (i > 1)ok |= va[i - 2];
		va[i] = ok;
	}
	vb[b] = 1;
	FOR(i, b + 1, n) {
		if (s[i] == '#')continue;
		bool ok = false;
		if (i > 0)ok |= vb[i - 1];
		if (i > 1)ok |= vb[i - 2];
		vb[i] = ok;
	}
	if (c < d) {
		if (va[c] && vb[d])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		vi ra(n), rb(n);
		ra[c] = 1;
		RREP(i, c) {
			if (s[i] == '#')continue;
			bool ok = false;
			if (i + 1 <= c)ok |= ra[i + 1];
			if (i + 2 <= c)ok |= ra[i + 2];
			ra[i] = ok;
		}
		rb[d] = 1;
		RREP(i, d) {
			if (s[i] == '#')continue;
			bool ok = false;
			if (i + 1 <= d)ok |= rb[i + 1];
			if (i + 2 <= d)ok |= rb[i + 2];
			rb[i] = ok;
		}
		REP(i, n - 2) {
			if (s[i + 2] == '.' && va[i] && vb[i + 1]) {
				if (ra[i + 2] && rb[i + 1]) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3664
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        long[] w=new long[N];
        for(int i=0;i<N;i++){
            w[i]=sc.nextLong();
        }
        Arrays.sort(w);
        long[] v=new long[N];
        for(int i=0;i<N;i++){
            v[N-1-i]=w[i];
        }
        long border=v[A-1];
        int borderNum=0;
        for(int i=A-1;i>=0;i--){
            if(v[i]!=border){
                break;
            }
            borderNum++;
        }
        int p=borderNum;

        long result=0;
        for(int i=A;i<N;i++){
            if(v[i]!=border){
                break;
            }
            borderNum++;

        }
        if(v[A-1]==v[0]) {
            for (int i = A - 1; i < B; i++) {
                if (v[i] != border) {
                    break;
                }
                result += calcCombination(borderNum,p + i - A + 1);
            }
        }else{
            result += calcCombination(borderNum, p);

        }
        long sum=0;
        for(int i=0;i<A;i++){
            sum+=v[i];
        }
        System.out.println((double)sum/(double)A);
        System.out.println(result);

        return;


    }
    static long calcCombination( int n, int m ) {
        if( n < m || m < 0 ) {
            throw new IllegalArgumentException( "引数の値が不正です ( n : " + n + ", m : " + m + ")" );
        }
        long c = 1;
        m = ( n - m < m ? n - m : m );
        for( int ns = n - m + 1, ms = 1; ms <= m; ns ++, ms ++ ) {
            c *= ns;
            c /= ms;
        }
        return c;
    }
}

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

int main() {
  int n ,a,b,c,d;
  cin >>n;
  a=n/1000;
    b=n/100-a*10;
    c=n/10-a*100-b*10;
  d=n%10;

  if(b==c && (a==b || d==c)){
  cout << "Yes" <<endl;
   
  }
  
  else{
  cout << "No" <<endl;
  }
  
}

Measured memory_bytes: 256
/* Author:bhagatsunny96
         JGEC*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define endl "\n"
#define test long long int t; scanf("%lld",&t); while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
using namespace std;
ll gcd(ll a, ll b)
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)  
 {  
    return (a*b)/__gcd(a, b);  
 }
 ll power(ll x, unsigned ll y) 
 { 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
 }
 bool isPrime(ll num)
 {
    bool flag=true;
    for(ll i =2;i<=num/2;i++) 
    {
       if(num%i==0) 
       {
          flag=false;
          break;
       }
    }
    return flag;
}
bool isPalin(ll num)
{
    bool flag=false;
    ll digit,rev=0,n=num;
    do
     {
         digit = num % 10;
         rev = (rev * 10) + digit;
         num = num / 10;
     } while (num != 0);
     if(rev==n)
     flag=true;
     return flag;
}
ll sumofdigits(ll n)
{
    ll c=0;
    while(n>0)
    {
        c++;
        n/=10;
    }
    return c;
}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) 
{ 
    return (a.first > b.first); 
}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
string sortString(string &str) 
{ 
   sort(str.begin(), str.end()); 
   return str;
} 
void countSort(ll arr[], ll n, ll exp) 
{ 
	ll output[n];
	ll i, count[10] = {0}; 
	for (i = 0; i < n; i++) 
		count[ (arr[i]/exp)%10 ]++; 
	for (i = 1; i < 10; i++) 
		count[i] += count[i - 1]; 
	for (i = n - 1; i >= 0; i--) 
	{ 
		output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; 
		count[ (arr[i]/exp)%10 ]--; 
	} 
	for (i = 0; i < n; i++) 
		arr[i] = output[i]; 
} 
void radixsort(ll arr[], ll n) 
{
    ll mx = arr[0]; 
	for (ll i = 1; i < n; i++) 
		if (arr[i] > mx) 
			mx = arr[i];
	ll m =mx;
	for (ll exp = 1; m/exp > 0; exp *= 10) 
		countSort(arr, n, exp); 
} 
void print(ll arr[], ll n) 
{ 
    for (ll i = 0; i < n; i++) 
        cout << arr[i] << " "; 
} 
int main() 
{
    fIO
    ll n;
    cin>>n;
    ll ans=(ll)ceil((double)n/(double)2);
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int a,b,c,d,ans ;

int main(void){
    
    scanf ("%d%d%d%d",&a,&b,&c,&d) ;
    
    if ( a<=b ){
        ans += a ;
    } else {
        ans += b ;
    }
    
    if ( c<=d ){
        ans += c ;
    } else {
        ans += d ;
    }
    
    printf ("%d\n",ans) ;
    
    return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
    int N; cin >> N;
    long long a[15];
    a[0] = 1;
    long long x = 6;
    for (int i = 1; i < 8; i++)
    {
        a[i] = x;
        x *= 6;
    }
    x = 9;
    for (int i = 8; i < 15; i++)
    {
        a[i] = x;
        x *= 9;
    }

    vector<vector<long long>> dp(15, vector<long long>(100010, INF));
    for(int i = 0; i < 100010; i++) dp[0][i] = i;
    for (int i = 1; i < 15; i++)
    {
        for (int j = 0; j < 100010; j++)
        {
            dp[i][j] = dp[i-1][j];
            if(a[i] <= j) {
                dp[i][j] = min(dp[i][j], dp[i][j-a[i]] + 1);
            }
        }
    }
    cout << dp[14][N] << endl;

    return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		Scanner scanner = new Scanner(System.in);
	    String input = scanner.nextLine();
	    String[] inputArray = input.split(" ");
	    int abRange = Integer.parseInt(inputArray[0]);
	    int bcRange = Integer.parseInt(inputArray[1]);
	    int caRange = Integer.parseInt(inputArray[2]);
	    int shortRange = Math.min(caRange + abRange, Math.min(abRange+bcRange, bcRange + caRange));
	    System.out.println(shortRange);
	    scanner.close();
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

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

int main() {
	int n, m; scanf("%d%d", &n, &m);
	
	printf("%d\n", n * (n - 1) / 2 + m * (m - 1) / 2);
	return 0;
}


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

namespace ABC098A
{
    class Program
    {
        private static int max, a, b;

        static void Main(string[] args)
        {
            int a, b, x;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);


            x = a + b;

            if (x < a - b) x = a - b;
            if (x < a * b) x = a * b;

            Console.WriteLine(x);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;

  vector<int> x;
  vector<int> y;

  rep(i, n) {
    int a;
    cin >> a;
    if (a < 0) {
      x.push_back(-a);
    } else {
      y.push_back(a);
    }
  }

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

  int xx = x.size();
  int yy = y.size();

  int ans = INT_MAX;
  for(int i=0; i<=k; i++) {

    if (i<xx && k-i-2 >= 0 && k-i-2 < yy) {
      int mi = min(x.at(i), y.at(k-i-2));
      mi += x.at(i) + y.at(k-i-2);
      ans = min(ans, mi);
    }
  }

  if (k <= xx) {
    ans = min(ans, x.at(k-1));
  }
  if (k <= yy) {
    ans = min(ans, y.at(k-1));
  }

  cout << ans << endl;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define int long long

using namespace std;



int32_t main(){
	
     ios_base::sync_with_stdio(0); cin.tie(0);
     
     int a , b , c ; cin >> a >> b >> c ; 
  	a = a+b+c;
  if(a>=22) cout << "bust" << endl; 
  else cout << "win" << endl;
     
     return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n=0 ,x,x2;
	cin >> x;
	x2 = x;
	while (x > 0) {
		n += x % 10;
		x /= 10;
	}
	if(x2%n==0){
	
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	//system("pause");
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NK = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var dict = new Dictionary<int, int>();
            for (var i = 0; i < A.Length; i++)
            {
                if (dict.ContainsKey(A[i])) dict[A[i]]++;
                else dict[A[i]] = 1;
            }
            var vals = dict.Select(x => x.Value).ToArray();
            Array.Sort(vals);
            var answer = 0;
            for (var i = 0; i < vals.Length - K; i++)
            {
                answer += vals[i];
                vals[vals.Length - 1] += vals[i];
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 52892
using System;

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = int.Parse(line);

            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string C = Console.ReadLine();

            int ans = 0;

            for (int i = 0; i < N; i++)
            {
                if (A[i] == B[i] && A[i] == C[i])
                {

                }
                else if (A[i] != B[i] && B[i] == C[i])
                {
                    ans++;
                }
                else if (A[i] == B[i] && B[i] != C[i])
                {
                    ans++;
                }
                else if (A[i] != B[i] && A[i] == C[i])
                {
                    ans++;
                }
                else
                {
                    ans += 2;
                }
            }
                Console.WriteLine("{0}", ans);
        }
    }
}

Measured memory_bytes: 11092
//
// Created on 2020/05/02.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {

    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>ans;
    if(n % 2 == 1){
        for (int i = 1; i <= n / 2; ++i) {
            ans.push_back({i,(n+1)-i});
        }
        for (int j = 0; j < m; ++j) {
            cout<<ans[j].first<<" "<<ans[j].second<<endl;
        }
    }else{
        int r,l;
        r = 1;
        l = n -1;
        bool frag = false;
        while(r < l){
            if(l-r <= n / 2 && !frag){
                r ++;
                frag = true;
                continue;
            }
            ans.push_back({r,l});
            r++;
            l--;
        }

        for (int j = 0; j < m; ++j) {
            cout<<ans[j].first<<" "<<ans[j].second<<endl;
        }
    }

    return 0;
}


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

int main()
{
  int n,i,v;
  vector<int>a;
  
  v=1;
  cin>>n;
  a.resize(n);
  for(i=0;i<n;++i)
  {
    cin>>a[i];
    if(a[i]%2==0&&!(a[i]%3==0||a[i]%5==0))
    v=0;  
  }
  
  if(v==1)
  cout<<"APPROVED";
  else
  cout<<"DENIED";  
} 


Measured memory_bytes: 256
// IN THE NAME OF RIGHT
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;


ll x,y,a,b,c;
ll k,sum;
vector <ll> p,q,r;
multiset <ll> app;

int main(){
	cin>>x>>y>>a>>b>>c;
	for(int i=0;i<a;i++){
		cin>>k;
		p.push_back(k);
	}
	for(int i=0;i<b;i++){
		cin>>k;
		q.push_back(k);
	}
	for(int i=0;i<c;i++){
		cin>>k;
		r.push_back(k);
	}
	sort(p.begin(),p.begin()+p.size(),greater <int>());
	sort(q.begin(),q.begin()+q.size(),greater <int>());
	sort(r.begin(),r.begin()+r.size(),greater <int>());
	for(int i=0;i<x;i++){
		app.insert(p[i]);
	}
	for(int i=0;i<y;i++){
		app.insert(q[i]);
	}
	for(int i=0;i<r.size();i++){
		if(app.lower_bound(r[i])!=app.begin()){
			app	.insert(r[i]);
			app.erase(app.begin());
		}else{
			break;
		}
	}
	while(!app.empty()){
		sum+=*app.begin();
		app.erase(app.begin());
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 10996
n,m = map(int,input().split())
def prime(x):
  ret = []
  i = 1
  while i*i <= x:
    if x%i == 0:
      ret.append(i)
      if x != i*i:
        ret.append(x//i)
    i += 1
  return sorted(ret)
for i in prime(m)[::-1]:
  if i*n <= m:
    print(i)
    exit(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;cin>>a>>b;
  if (a%2 != b%2) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  long long d = (a+b)/2;
  int e = max(a,b) - min(a,b);
  if (a>=d && b>=d) {
    cout << min(a,b) + e/2 << endl;
  } else {
    cout << d << endl;
  }

}


Measured memory_bytes: 256
#=map(int,input().split())
S=input()
T=input()
ls=len(S)
lt=len(T)
ans=float('inf')
for i in range(ls-lt+1):
    ans_=0
    for j in range(lt):
        if S[i+j]!=T[j]:
            ans_+=1
    ans=min(ans,ans_)
print(ans)

Measured memory_bytes: 8984
#include<bits/stdc++.h>
using namespace std;
#define re register int
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline int
template<class D>I read(D &res){
	res=0;register D g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
const int INF=1e9;
int n,m,k,a[202000];
int main(){
	read(n);read(m);read(k);
	F(i,1,m)a[i]=k;
	F(i,m+1,n){
		if(k==INF)a[i]=1;
		else a[i]=k+1;
	}
	F(i,1,n)cout<<a[i]<<" ";
	return 0;
}


Measured memory_bytes: 1664
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n):
        a,b = LS()
        if a == b:
            return 0
        a = [int(c) for c in a]
        b = [int(c) for c in b]
        aa = [a]
        ad = set()
        ad.add(tuple(a))
        r = 0
        while True:
            r += 1
            na = []
            for a in aa:
                ti = 0
                for i in range(r-1,n):
                    if a[i] != b[i]:
                        ti = i
                        break
                sa = b[ti] - a[ti]
                for j in range(ti+1, n+1):
                    t = [(a[i] + sa) % 10 if ti <= i < j else a[i] for i in range(n)]
                    k = tuple(t)
                    if k in ad:
                        continue
                    if t == b:
                        return r
                    ad.add(k)
                    na.append(t)
            aa = na

    while True:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str,rr))


print(main())



Measured memory_bytes: 10716
#!/usr/bin/env pypy3

import collections


class UnionFind(object):

    def __init__(self, number_of_nodes):
        self.par = list(range(number_of_nodes))
        self.rank = [0] * number_of_nodes

    def root(self, node):
        if self.par[node] == node:
            return node
        else:
            r = self.root(self.par[node])
            self.par[node] = r
            return r

    def in_the_same_set(self, node1, node2):
        return self.root(node1) == self.root(node2)

    def unite(self, node1, node2):
        x = self.root(node1)
        y = self.root(node2)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def main():
    n, k, l = (int(x) for x in input().split())
    uf_roads = UnionFind(n)
    for _ in range(k):
        p, q = (int(x) - 1 for x in input().split())
        uf_roads.unite(p, q)
    uf_rails = UnionFind(n)
    for _ in range(l):
        r, s = (int(x) - 1 for x in input().split())
        uf_rails.unite(r, s)
    ctr = collections.Counter((uf_roads.root(i), uf_rails.root(i))
                              for i in range(n))
    ans = [ctr[(uf_roads.root(i), uf_rails.root(i))] for i in range(n)]
    print(" ".join(str(a) for a in ans))

if __name__ == '__main__':
    main()


Measured memory_bytes: 122840
#include<stdio.h>
int main(){
  int n,o=0,p=0,b1=0,b2=0,b3=0;
  char s;
  scanf("%d",&n);
  while(n){
    scanf(" %*c%c%*s",&s);//printf("%c",s);
    if(s=='I'){
      p+=b3;
      b3=b2;
      b2=b1;
      b1=1;
    }
    if(s=='U'){
      o++;
      if(o==3){
	printf("%d\n",p);
	p=o=b1=b2=b3=0;
	n--;
      }
    }
    if(s=='O'){
      p+=b3+b2+b1+1;
      b3=b2=b1=0;
    }
  }
  return 0;
}

 

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=50001;
const ll INF=1LL<<60;

int main(){

    int N;
    ll W;cin>>N>>W;
    
    ll ans=0;
    
    vector<ll> v(N),w(N),m(N);
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i]>>m[i];
    }
    
    vector<vector<ll>> dp(N+1,vector<ll>(50*N+1,INF));//価値iをつくる最小の重さ
    
    dp[0][0]=0;
    
    for(int i=1;i<=N;i++){
        for(int j=50*N;j>=0;j--){
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if(j-v[i-1]>=0) dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1]]+w[i-1]);
        }
        m[i-1]--;
        if(m[i-1]){
            for(int j=50*N;j>=0;j--){
                //dp[i][j]=min(dp[i][j],dp[i-1][j]);
                if(j-v[i-1]>=0) dp[i][j]=min(dp[i][j],dp[i][j-v[i-1]]+w[i-1]);
            }
            m[i-1]--;
        }
    }
    
    vector<int> ord(N);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int i,int j){
        return v[i] * w[j] > v[j] * w[i];
    });
    
    for(int j=0;j<=50*N;j++){
        if(dp[N][j]>W) continue;
        ll rem=W-dp[N][j];
        ll sum=j;
        for(int i=0;i<N;i++){
            int id=ord[i];
            ll use=min(rem/w[id],m[id]);
            sum+=v[id]*use;
            rem-=w[id]*use;
        }
        ans=max(ans,sum);
    }
    
    cout<<ans<<endl;
}




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

int main()
{
  int N, M;
  int a[305][305];
  
  cin >> N >> M;

  for(int i = 0; i < N; i++) {
    for(int j = 0; j < M; j++) {
      cin >> a[i][j]; --a[i][j];
    }
  }

  int l = 0, r = N + 1;

  while(l + 1 < r) {
    int m = (l + r) / 2;
    int cnt = 0;
    bool flag[305] = {};
    int it[305] = {};
    bool ch = true;

    while(ch && cnt < M) {
      int c[305] = {};
      
      ch = false;
      for(int i = 0; i < N; i++) {
	c[a[i][it[i]]]++;
      }
      for(int i = 0; i < M; i++) {
	if(c[i] > m) {
	  ch = true, cnt++, flag[i] = true;
	}
      }

      for(int i = 0; i < N; i++) {
	while(it[i] < M && flag[a[i][it[i]]]) it[i]++;
      }
    }
    if(cnt == M) l = m;
    else r = m;
  }
  
  cout << r << endl;

  return (0);
}
      


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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] nt = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = nt[0];
            long t = nt[1];

            long[] ti = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long ans = 0;

            for(long i = 1; i <= n; i++)
            {
                if(i == n)
                {
                    ans += t;
                }
                else
                {
                    ans += Math.Min(ti[i] - ti[i - 1], t);
                }

            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28832
# 2019/09/07

from bisect import bisect_left,bisect_right

n=int(input())
a=sorted(list(map(int,input().split())))
b=list(map(int,input().split()))
c=sorted(list(map(int,input().split())))

cnt=0
for bb in b:
    aa=bisect_left(a,bb)
    cc=n-bisect_right(c,bb)
    cnt+=aa*cc
print(cnt)


Measured memory_bytes: 23744
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a,b,c;
int main()
{
	a=read(); b=read(); c=read();
	writeln(std::min(a*b,c));
}

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

int main(){
  ll N, M;
  cin >> N >> M;
  ll H[N];
  for(int i=0;i<N;++i) {
  cin >> H[i];
  }
  Graph c(N);
  int a, b;
  int count = 0;
  for(int j=0;j<M;++j) {
  cin >> a >> b;
  c[a-1].push_back(b-1);
  c[b-1].push_back(a-1);
  }
  bool flag = true;
  for(int k=0;k<N;++k) {
    flag = true;
    for(auto next_k : c[k]) {
      if(H[next_k] >= H[k]) {
        flag = false;
        break;
      }
    }
  if(flag==true) ++count;
  }
  cout << count;
}

Measured memory_bytes: 9064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
# define MOD 1000000000+7
# define INF 1000000000
typedef long long ll;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {
	string x;
	cin >> x;
	if (x[0] == x[1] || x[1] == x[2] || x[2] == x[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

}



Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

alias Key = Tuple!(int, "cost", int, "mask");

void chmin(T)(ref T a, in T b) { if (a > b) a = b; }

long calc(int num, Key[] keys) {
    int n = cast(int)keys.length;

    // dp[i 番目の鍵][宝箱の鍵(ビットマスク)]
    auto dp = new long[][](n + 1, 1 << num);
    for (int i = 0; i < dp.length; i++) dp[i][] = int.max;

    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        int cost = keys[i].cost;
        int mask = keys[i].mask;
        for (int j = 0; j < (1 << num); j++) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][j | mask], dp[i][j] + cost);
        }
    }
    auto ans = dp[n][(1 << num) - 1];
    return ans == int.max ? -1 : ans;
}

void main() {
    int n, m; scan(n, m);
    Key[] keys;
    foreach (_; 0..m) {
        int a, b; scan(a, b);
        auto c = readints;
        int mask = 0;
        foreach (e; c) mask |= (1 << (e-1));
        keys ~= Key(a, mask);
    }
    writeln(calc(n, keys));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

int main(void)
{
	string cards;
	int m, h, s;

	while (cin >> cards, cards!="-"){
		cin >> m;
		s = 0;
		for (int i=0; i<m; i++){
			cin >> h;
			s += h;
		}
		s %= cards.size();
		cout<<cards.substr(s)+cards.substr(0,s)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#!/usr/bin/env python3
#Tenka1 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = [I() for _ in range(n)]
a.sort()
if n % 2:
    lower = a[:n//2]
    upper = a[n//2+1:]
    mid = a[n//2]
    x = 2*sum(upper) - 2*sum(lower) - mid + lower[-1]
    y = 2*sum(upper) - 2*sum(lower) + mid - upper[0]
    print(max(x,y))
else:
    lower = a[:n//2]
    upper = a[n//2:]
    x = 2*sum(upper) - upper[0]
    y = 2*sum(lower) - lower[-1]
    print(x-y)


Measured memory_bytes: 44508
def main():

    N = input()
    D = list(map(int,input().split()))
    M = max(D)
    countlist=[0] * (M + 1)
    ans=1

    for i in D:
        countlist[i]+=1

    if countlist[0]!=1 :
        ans = 0
    else :
        if D[0]!=0 :
            ans = 0
        else:
            for i in range(2,M+1):
                ans = (ans * (countlist[i-1]**countlist[i])) % 998244353

    print(ans) 

if __name__ == "__main__":
    main()

Measured memory_bytes: 14396
package main

import (
	"fmt"
)

func main() {

	var a,b,c,d int
	fmt.Scan(&a, &b, &c, &d)

	ans := f(b, c, d) - f(a-1, c, d)
	fmt.Println(ans)

}

func f(x, c, d int) int {
	res := x
	res -= x/c
	res -= x/d
	res += x/lcm(c,d)
	return res
}

func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b % a, a
	}
	return b
}
func lcm(a, b int) int {
	return a * b / gcd(a, b)
}


Measured memory_bytes: 1772
#include <iostream>
using namespace std;
 
long long N;
 
int func(long long n, bool has_3, bool has_5, bool has_7) {
  if(n>N) {
    return 0;
  }
  
  int res = 0;
  if (has_3==true && has_5==true && has_7==true) {
    res += 1;
  }
  
  res += func(n*10+3, true, has_5, has_7);
  res += func(n*10+5, has_3, true, has_7);
  res += func(n*10+7, has_3, has_5, true);
 
  return res;
}
 
int main (){
  cin >> N;
  
  cout << func(0, false, false, false) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int A_1,A_2,B_1,B_2;
	cin >> A_1 >> A_2 >> B_1 >> B_2;
	
	int answer = min(A_2,B_2) - max(A_1,B_1);
	
	if(answer<0){
		cout << 0 << endl;
	}else{
		cout << answer << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    
    String s=sc.next();
    int r=0;
    int b=0;
    char k[]=new char[s.length()];
    for(int i=0;i<s.length();i++){
      k[i]=s.charAt(i);
    }
    for(int i=0;i<k.length;i++){
      if(k[i]=='0') r++;
      else b++;
    }
    if(r>=b) System.out.println(b*2);
    else System.out.println(r*2);

    sc.close();
  }
}

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

const int N = 1e5 + 10;
bool mark[N];
int q, ps[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> q;
	for (int i = 1; i < N; i++)
		mark[i] = 1;
	mark[1] = 0;
	
	for (int i = 2; i < N; i++){
		if(!mark[i])
			continue;
		for (int j = i * 2; j < N; j += i)
			mark[j] = 0;
	}
	for (int i = 1; i < N; i++){
		ps[i] = ps[i - 1];
		if(i % 2 == 1)
			ps[i] += (mark[i] && mark[(i + 1) / 2]);
	}
	
	while(q){
		int l, r;
		cin >> l >> r;
		cout << ps[r] - ps[l - 1] << '\n';
		q--;
	}
}


Measured memory_bytes: 1152
#include<stdio.h>
int main(){

    int A, B, C,k;
    scanf("%d %d %d %d",&A, &B, &C, &k );

    if(A>=B && A>=C){
        for(k;k>0;k--){
            A=A*2;
        }

    }
    else if(B>=C){
        for(k;k>0;k--){
            B=B*2;
        }

    }
    else{
        for(k;k>0;k--){
            C=C*2;
        }
    }

printf("%d\n", A+B+C);

    return 0;
}

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

#define ll long long
#define mem(a,b) memset(a,b,sizeof(a))
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)

int n,m;
char s[202][202];
int a[30],cnt[4];

int main()
{
    cin>>n>>m;
    R(i,0,n) { scanf("%s",s[i]);}
    R(i,0,n)R(j,0,m) a[s[i][j]-'a'+1]++;
    F(i,1,26) cnt[a[i]%4]++;
    cnt[1]+=cnt[3],cnt[2]+=cnt[3];cnt[3]=0;
    if((n&1)&&(m&1))
    {
        int check2=(n/2)+(m/2);
        if((check2<cnt[2])||(check2-cnt[2])%2) puts("No");
        else if(cnt[1]!=1) puts("No");
        else puts("Yes");
    }
    else if((n%2==0)&&(m%2==0))
    {
        if(cnt[2]+cnt[1]) puts("No");
        else puts("Yes");
    }
    else
    {
        int check2;
        if(n&1) check2=m/2;else check2=n/2;
        //printf("%d %d %d\n",cnt[1],cnt[2],cnt[3]);
        if(cnt[1]) puts("No");
        else if((cnt[2]>check2)||(check2-cnt[2])%2) puts("No");
        else puts("Yes");
    }
    return 0;
}


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

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int MAXN=1e5+5;
int N;
vvi T;

vi path;
int sz[MAXN];

bool dfs_path(int u, int p) {
        if (u == N) {
                path.push_back(N);
                return true;
        }

        for (auto v : T[u]) {
                if (v == p) continue;
                if (dfs_path(v,u)) {
                        path.push_back(u);
                        return true;
                }
        }

        return false;
}

int dfs_sz(int u, int p) {
        sz[u] = 1;
        for (auto v : T[u]) {
                if (v == p) continue;
                sz[u] += dfs_sz(v,u);
        }
        return sz[u];
}

int main() {
        cin >> N;
        T = vvi(N+1,vi());
        for (int i=0; i<N-1; i++) {
                int a,b;
                cin >> a >> b;
                T[a].push_back(b);
                T[b].push_back(a);
        }

        dfs_path(1,-1);
        dfs_sz(1,-1);

        int white = sz[path[path.size()/2-1]];
        int black = N - white;

        /*cout << "PATH: ";
        for (int i=0; i<path.size(); i++)
                cout << path[i] << " ";
        cout << "\n";

        cout << "White gets subtree: " << path[path.size()/2-1] << "\n";
        cout << "White gets " << white << " nodes\n";
        cout << "Black gets the remaining " << black << " nodes\n";*/

        if (black > white)
                cout << "Fennec\n";
        else
                cout << "Snuke\n";

}

Measured memory_bytes: 11256
given = ["dreamer", "dream", "eraser", "erase"]
S = input()
while len(S) > 0:
    judge = [S.endswith(i) for i in given]
    if any(judge):
        target = given[judge.index(True)]
        S = S[:-len(target)]
        if len(S) == 0:
            print("YES")
            break
    else:
        print("NO")
        break

Measured memory_bytes: 3316
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <queue>
#include <time.h>

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);		//最大公倍数
ll lcm(ll m, ll n);		//最小公倍数

int main(void) {

	int ans = 0;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		ans += tmp - 1;
	}



	cout << ans << endl;

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  

#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 500;

int a[N][N];
int ans[N*N][4];

int main() {
	int h,w;cin>>h>>w;
	rep(i,h) rep(j,w) cin>>a[i][j];
	int n=0;
	rep(i,h) rep(j,w-1){
		if(a[i][j]%2==1){
			a[i][j+1]++;
			ans[n][0]=ans[n][2]=i+1;
			ans[n][1]=j+1;
			ans[n][3]=j+2;
			n++;
		}
	}
	rep(i,h-1){
		if(a[i][w-1]%2==1){
			a[i+1][w-1]++;
			ans[n][0]=i+1;
			ans[n][1]=ans[n][3]=w;
			ans[n][2]=i+2;
			n++;
		}
	}
	cout<<n<<endl;
	rep(i,n){
		rep(j,3) cout<<ans[i][j]<<' ';
		cout<<ans[i][3]<<endl;
	}
}


Measured memory_bytes: 6912
from itertools import permutations
from collections import deque
from collections import Counter
N, C = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(C)]
c = [list(map(int, input().split())) for _ in range(N)]

r0 = deque()
r1 = deque()
r2 = deque()
for i in range(N):
    for j in range(N):
        rest = (i+1+j+1) % 3
        if rest == 0:
            r0.append(c[i][j]-1)
        elif rest == 1:
            r1.append(c[i][j]-1)
        else:
            r2.append(c[i][j]-1)
c0 = Counter(r0)
c1 = Counter(r1)
c2 = Counter(r2)
ans = 10**10
for p in permutations([i for i in range(C)], 3):
    point = 0
    point += sum([d[k][p[0]]* v for k, v in c0.items()])
    point += sum([d[k][p[1]]* v for k, v in c1.items()])
    point += sum([d[k][p[2]]* v for k, v in c2.items()])
    ans = min(ans, point)
print(ans)


Measured memory_bytes: 7660
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;



int main()
{
	int A, B;
  	cin >> A >> B;
  	
  	int max[3];
  	max[0] = 2 * A - 1;
  	max[1] = A + B;
  	max[2] = 2 * B - 1; 
    
    sort(max, max + 3);
  	cout << max[2] << endl;
	
	
	return 0;
}

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

using namespace std;

int main(){

	int n, m;
	cin >> n >> m;
	int a[m][2];
	int b[n];

	for(int i = 0; i < m; i++){
		for(int j = 0; j < 2; j++){
			cin >> a[i][j];
		}
	}

	for(int i = 0; i < n; i++){
		b[i] = 0;
	}

	for(int i = 0; i < m; i++){
		for(int j = 0; j < 2; j++){
			b[a[i][j]-1]++;
		}
	}

	for(int i = 0; i < n; i++){
		cout << b[i] << endl;
	}


	return 0;
}

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

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

  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  int pair = 0;

  for(int i=0;i<n;i++) {
    int j = a[i];
    if(i + 1 == a[j-1]) pair++;
  }

  cout << pair / 2 << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
while True:
    s = input()
    if s == '#':
        break
    a, b, c, d = map(lambda x: int(x) - 1, input().split())
    cell = []
    for i, x in enumerate(s.split('/')):
        cell.append([])
        for ch in x:
            if ch == 'b':
                cell[i].append('b')
            else:
                cell[i] += list('.' * int(ch))
    cell[a][b] = '.'
    cell[c][d] = 'b'
    ans = []
    for i in range(len(cell)):
        jfen = ''
        cnt = 0
        for j in range(len(cell[i])):
            if cell[i][j] == 'b':
                if cnt > 0:
                    jfen += str(cnt)
                cnt = 0
                jfen += 'b'
            else:
                cnt += 1
        if cnt > 0:
            jfen += str(cnt)
        ans.append(jfen)
    print('/'.join(ans))



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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	// int n;
	// cin>>n;
	// int ans=0;
	// rep(i,n){
	// 	int a,b;
	// 	cin>>a>>b;
	// 	ans+=a*b;
	// }
	// cout<<(int)(ans*1.05)<<endl;
	int a,x,b;
	cin>>x>>a>>b;
	cout<<(abs(x-a)<abs(x-b)?'A':'B')<<endl;
	return 0;
}

Measured memory_bytes: 256
class BIT:
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.bisect_K = [1 << k for k in reversed(range(N.bit_length()))]

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def bisect(self, w):
        if w <= 0:
            return 0
        bit, N = self.tree, self.size
        i = 0
        for k in self.bisect_K:
            if i + k <= N and bit[i + k] < w:
                i += k
                w -= bit[i]
        return i + 1


class Multiset:
    def __init__(self, N):
        self.N = N
        self.bit = BIT(N)

    def insert(self, x):
        self.bit.add(x, 1)

    def erase(self, x):
        self.bit.add(x, -1)

    def lower_bound(self, x):
        return self.bit.bisect(self.bit.sum(x))

    def size(self):
        return self.bit.sum(self.N)


N, *A = map(int, open(0).read().split())

memo = {a: i for i, a in enumerate(sorted(set(A)), 1)}
M = len(memo)

ms = Multiset(M)
for b in (memo[a] for a in A):
    i = ms.lower_bound(b - 1)
    if i != 0:
        ms.erase(i)
    ms.insert(b)

print(ms.size())


Measured memory_bytes: 23436
A, B, C = gets.split.map(&:to_i)

def solve(a, b, c)
  if a % 2 == 1 || b % 2 == 1 || c % 2 == 1
    return 0
  end

  if a == b && b == c
    return -1
  end

  solve(b/2 + c/2, a/2 + c/2, a/2 + b/2) + 1
end

puts solve(A, B, C)


Measured memory_bytes: 3836
def main():
    c_mat = [[c for c in input()] for _ in range(2)]

    if c_mat[0][0] == c_mat[1][2] and c_mat[0][1] == c_mat[1][1] and c_mat[0][2] == c_mat[1][0]:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include<algorithm>

using namespace std;
int main() {
    //freopen("input.txt","r",stdin);
    char c; cin>>c;
    if(c=='A'){
        cout<<"T";
    }
    else if(c=='C'){
        cout<<"G";
    }

    else if(c=='G'){
        cout<<"C";
    }
    else{
        cout<<"A";
    }
	return 0;
}

Measured memory_bytes: 256