akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoder
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var sr = new InputReader(Console.In);
            //var sr = new InputReader(new StreamReader(new MemoryStream(Encoding.Unicode.GetBytes("input.txt"))));
            using (var sw = Console.Out)
            //using (var sw = new StreamWriter("output.txt"))
            {
                Solve(sr, sw);
            }
        }


        internal static void Solve(InputReader sr, TextWriter sw)
        {
            var param = sr.NextSplitInts();
            var dateTImeNow = param[0];
            var waitTime = param[1];
            var ans = (dateTImeNow + waitTime) % 24;

         
            sw.WriteLine(ans);
        }

        internal class InputReader : IDisposable
        {
            private bool isDispose;
            private readonly TextReader sr;

            public InputReader(TextReader stream)
            {
                sr = stream;
            }

            public void Dispose()
            {
                //Dispose(true);
                GC.SuppressFinalize(this);
            }

            public string NextString()
            {
                var result = sr.ReadLine();
                return result;
            }

            public int NextInt32()
            {
                return int.Parse(NextString());
            }

            public long NextInt64()
            {
                return long.Parse(NextString());
            }

            public string[] NextSplitStrings()
            {
                return NextString()
                    .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            }

            public int[] NextSplitInts()
            {
                return NextString()
                    .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(int.Parse).ToArray();
            }

            public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
            {
                return NextSplitStrings()
                    .Select(s => func(s, CultureInfo.InvariantCulture))
                    .ToArray();
            }

            public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
            {
                return str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(s => func(s, CultureInfo.InvariantCulture))
                    .ToArray();
            }

            //protected void Dispose(bool dispose)
            //{
            //    if (isDispose) return;
            //    if (dispose)
            //    {
            //        sr.Close();
            //    }
            //    isDispose = true;
            //}

            //~InputReader()
            //{
            //    Dispose(false);
            //}
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector <int> a(n);
  int s = 0;
  REP(i, n) {
	cin >> a[i];
	s ^= a[i];
  }
  REP(i, n) {
	cout << (s ^ a[i]) << (i == n - 1 ? "\n" : " ");
  }
  return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;
void QA(bool x){
  if(x) cout<<"Yes";
  else cout<<"No";
  return;
}

int main() {
  int a,b; cin>>a>>b;
  QA(a%2==1&&b%2==1);
}



Measured memory_bytes: 3680
A, B, C, D, E, F = map(int, input().split())
ans_sw = 1
ans_s = 0
for a in range(F//(100*A)+1):
  for b in range(F//(100*B)+1):
    if 100*A*a + 100*B*b > F or 100*A*a+100*B*b == 0:
      continue
    for c in range((A*a+B*b)*E+1):
      for d in range((A*a+B*b)*E+1):
        sw = 100*A*a+100*B*b+C*c+D*d
        s = C*c+D*d
        if 0 < sw <= F and s <= (A*a+B*b)*E and ans_s/ans_sw < s/sw:
          ans_s = s
          ans_sw = sw
if ans_sw == 1:
  print(100*A ,0)
else:
  print(ans_sw, ans_s)


Measured memory_bytes: 41948
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder = new StringBuilder();
        String[] columns;
        int a1 = 0;
        int a2 = 0;
        int res = 0;

        while (true) {
            String line = reader.readLine();
            columns = line.split(" ");
            a1 = Integer.parseInt(columns[0]);
            a2 = Integer.parseInt(columns[1]);
            if (a1 == 0 && a2 == 0) {
                break;
            }

            res = pattern(a1, a2);
            builder.append(res)
                   .append("\n");
        }
        System.out.print(builder);
    }

    public static int pattern(int a1, int a2) {
        int list = 0;
        for (int x = 1; x <= a1; x++) {
            for (int y = x + 1; y <= a1 ; y++) {
                for (int z = y + 1; z <= a1; z++) {
                    if (x + y + z == a2) {
                        list += 1;
                    }
                }
            }
        }
        return list;
    }
}

Measured memory_bytes: 24568
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[100010];
    A[N] = 0;
    A[0] = 0;
    int cost = 0;
    for(int i = 1;i <= N;i++){
        cin >> A[i];
        cost += abs(A[i] - A[i-1]);
    }
    cost += abs(A[N]);
    
    for(int i = 1;i <= N;i++){
        if(A[i-1] >= A[i] && A[i] >= A[i+1])cout << cost;
        else if(A[i-1] <= A[i] && A[i] <= A[i+1])cout << cost;
        else if(A[i-1] > A[i] && A[i+1] > A[i])cout << cost - abs(min(A[i-1], A[i+1])-A[i])*2;
        else cout << cost - abs(max(A[i-1], A[i+1])-A[i])*2;
        cout << endl;
    }
}




Measured memory_bytes: 1664
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s1 = br.readLine().split(" ");
		int h = Integer.parseInt(s1[0]);
		int w = Integer.parseInt(s1[1]);
		int n = Integer.parseInt(s1[2]);
		String[] s2 = br.readLine().split(" ");
		int r = Integer.parseInt(s2[0]);
		int c = Integer.parseInt(s2[1]);
		String s = br.readLine();
		String t = br.readLine();
		br.close();

		int x = c;
		for (int i = 0; i < n; i++) {
			char cs = s.charAt(i);
			char ct = t.charAt(i);
			if (cs == 'L') {
				x--;
			}
			if (x < 1) {
				System.out.println("NO");
				return;
			}
			if (ct == 'R' && x < w) {
				x++;
			}
		}

		x = c;
		for (int i = 0; i < n; i++) {
			char cs = s.charAt(i);
			char ct = t.charAt(i);
			if (cs == 'R') {
				x++;
			}
			if (x > w) {
				System.out.println("NO");
				return;
			}
			if (ct == 'L' && x > 1) {
				x--;
			}
		}

		x = r;
		for (int i = 0; i < n; i++) {
			char cs = s.charAt(i);
			char ct = t.charAt(i);
			if (cs == 'U') {
				x--;
			}
			if (x < 1) {
				System.out.println("NO");
				return;
			}
			if (ct == 'D' && x < h) {
				x++;
			}
		}

		x = r;
		for (int i = 0; i < n; i++) {
			char cs = s.charAt(i);
			char ct = t.charAt(i);
			if (cs == 'D') {
				x++;
			}
			if (x > h) {
				System.out.println("NO");
				return;
			}
			if (ct == 'U' && x > 1) {
				x--;
			}
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 25580
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int table[][7] = {
	{0,300,500,600,700,1350,1650},
	{6,0,350,450,600,1150,1500},
	{13,7,0,250,400,1000,1350},
	{18,12,5,0,250,850,1300},
	{23,17,10,5,0,600,1150},
	{43,37,30,25,20,0,500},
	{58,52,45,40,35,15,0}
};

int main()
{
	int to, from;
	int d, hd, md,sd;
	int a, ha, ma,sa;
	while (cin >> d, d) {
		cin >> hd >> md;
		cin >> a >> ha >> ma;
		d--, a--;

		to = 19 * 60 * 60 + 30 * 60;
		from = 17 * 60 * 60 + 30 * 60;
		sd = hd * 60 * 60 + md * 60;
		sa = ha * 60 * 60 + ma * 60;

		if (from <= sd && to >= sa || from >= sd && to >= sa || from <= sd && to <= sa) {
			if (table[a][d] <= 40) {
				int ans = table[d][a] / 2;
				if (ans % 50 != 0)ans += 25;
				cout << ans << endl;
			}
			else cout << table[d][a] << endl;
		}
		else
			cout << table[d][a] << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

struct Node{
    ll cost;
    int parent;  // index of parent node
    int index;   // index in node list
    vector<pair <int,ll> > connect;
};

int reach[100001];

void dfs(vector<Node> &node, int index){

    //cout << "ind:" << index << endl;

    for(int i = 0; i < node[index].connect.size(); i++){
        int next_index = node[index].connect[i].first;
        ll  next_cost = node[index].connect[i].second;
        if(reach[next_index] == 0){
            reach[next_index] = 1;
            node[next_index].cost = node[index].cost + next_cost;
            node[next_index].parent = index;
            dfs(node, next_index);
        }
    }


}

int main(){

    int N;
    cin >> N;

    vector<Node> node(N+1);
    for(int i = 0; i <= N; i++){
        node[i].cost = 0;
        node[i].parent = -1;
        node[i].index = i;
    }
    for(int i = 0; i < N-1; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        node[a].connect.push_back( make_pair(b, c));
        node[b].connect.push_back( make_pair(a, c));
    }

    int Q, K;
    cin >> Q >> K;
    reach[K] = 1;
    dfs(node,K);

    //cout << "dfs" << endl;
    for(int i = 0; i < Q; i++){
        int a, b;
        cin >> a >> b;
        cout << node[a].cost + node[b].cost << endl;
    }

}

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

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

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

  bool ok = false;
  for (int i = a; i <= a * b; i += a)
    if (i % b == c) ok = true;

  puts(ok ? "YES" : "NO");

  return 0;
}

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

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

	vector<int> p = { 3, 5, 7, 11, 13, 17 };

	int count = 0;
	for (int i = 0; i < p.size(); ++i)
	{
		for (int j = i+1; j < p.size(); ++j)
		{
			for (int k = j+1; k < p.size(); ++k)
			{
				if (p[i] * p[j] * p[k] <= N)
				{
					++count;
				}
				else
				{
					break;
				}
			}
		}
	}

	for (int i = 0; i < p.size(); ++i)
	{
		for (int j = i+1; j < p.size(); ++j)
		{
			if (p[i] * p[i] * p[i] * p[j] <= N)
			{
				++count;
			}
			else
			{
				break;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val Array(n,m,l) = readLine.split(" ").map(_.toInt)
  val buf1 = ArrayBuffer.empty[Array[Long]]
  val buf2 = ArrayBuffer.empty[Array[Long]]

  for( i <- 0 until n) buf1 += readLine.split(" ").map(_.toLong)
  for( i <- 0 until m) buf2 += readLine.split(" ").map(_.toLong)

  val m1 = buf1.toArray
  val m2 = buf2.toArray

  val m3 = for(i <- 0 until n) yield for(j<- 0 until l)
    yield (0 until m).foldLeft(0L) { (sum,k) => sum + m1(i)(k) * m2(k)(j) }

  m3.foreach(row => println(row.mkString(" ")))
}

Measured memory_bytes: 78280
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		Scanner cin = new Scanner(System.in);
		int K = cin.nextInt();
		int S = cin.nextInt();
		cin.close();
		int count =0;
		for(int X=0;X<=K;X++){
			for(int Y=0;Y<=K;Y++){
				int Z = S-X-Y;
				if(Z>=0&&Z<=K){
					count++;
				}

			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  string s;
  cin >> s;
  int w;
  cin >> w;
  for (int i = 0; i < s.size(); i += w) { cout << s[i]; }
  cout << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 256
import numpy as np

h, w, k = map(int, input().split())
st = []
for _ in range(h):
    l = list(input())
    l = [l[i] for i in range(w)]
    st.append(l)
st = np.array(st)
st = np.where(st=='#', 1, 0)

cnt = 0
for i in range(2**w-1):
    tmp = [1] * w
    for j in range(w):
        if i >> j & 1:
            tmp[j] = 0
    for j in range(2**h-1):
        ker = np.array([tmp]*h)
        for x in range(h):
            if j >> x & 1:
                ker[x,:] = 0
        if np.sum(st * ker) == k:
            cnt+=1
print(cnt)

Measured memory_bytes: 27284
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;

ll mod_pow(ll x,ll n) {
	if (n == 0) return 1;
	ll res = mod_pow(x*x % mod, n / 2);
	if (n & 1) res = res * x % mod;
	return res;
}

ll comb(ll n, ll x) {
	ll ret = 1,k=1;
	FOR(i, 0, x)ret = (ret * (n - i))%mod;
	FOR(i, 1, x + 1)k = (k*i+ mod)%mod;
	k = mod_pow(k, mod - 2);
	ret = (ret*k + mod) % mod;
	return ret;
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	ll N,A,B;
	cin >> N>>A>>B;
	
	ll ans = 1;

	ans = mod_pow(2LL, N);

	ll a = comb(N,A);
	ll b = comb(N, B);
	
	cout << (ans-a-b+2*mod-1)%mod << endl;
	return 0;
}


Measured memory_bytes: 760
#include <stdio.h>

int main(){
  int h,w;
  int i,j;

  while(1){

    scanf("%d %d",&h,&w);
    if(h ==0 && w == 0)break;


    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(i == 0 || i == h-1)printf("#");
        else if((i > 0 && i < h-1) && (j == 0 || j == w-1))printf("#");
        else if((i > 0 && i < h-1) && (j > 0 && j < w-1))printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
}



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

int main()
{
  int a, b, ans=0;
  cin >> a >> b;
  for(int i=0;i<2;i++){
    if(a<b){
      ans+=b;
      b--;
    }else{
      ans+=a;
      a--;
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> vector<T> make_vec(size_t n) { return vector<T>(n); }
template<typename T, typename... Args> auto make_vec(size_t n, Args... args) {
    return vector<decltype(make_vec<T>(args...))>(n, make_vec<T>(args...));
}
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value>::type fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<!is_same<T, U>::value>::type fill_v(U& u, const V... v) {
    for (auto& e : u) fill_v<T>(e, v...);
}

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

    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    ll d = abs(a - b);
    if (v*t >= d + w*t) cout << "YES\n";
    else cout << "NO\n";
}


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

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a != b || b != c || c != a) && (a == b || b == c || c == a)) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

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



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

signed main() {
    int N,M; cin >> N >> M;
    int sum=0;
    int kakuritu=1;
    rep(i,M){
        sum+=1900;
        kakuritu*=2;
    }
    rep(i,N-M){
        sum+=100;
    }
    cout << sum*kakuritu << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] arr = new int[n];
		int[] dp = new int[n];
		
		for(int i = 0;i < n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.fill(dp, 0);
		
		if(n == 1) {
			System.out.println(arr[0]);
			return;
		}
		
		dp[1] = Math.abs(arr[1] - arr[0]);
		
		for(int i = 2;i < n;i++) {
			int a = dp[i-1] + Math.abs(arr[i] - arr[i-1]);
			int b = dp[i-2] + Math.abs(arr[i] - arr[i-2]);
			dp[i] = Math.min(a, b);
		}
		
		System.out.println(dp[n-1]);
		return;
		
	}
}


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

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
const ll INF = 1001001000100010;
const ld PI = 3.14159265358979323846;


int main() {
// 入力
    int N,M; 
    cin >> N>>M;
    vector<pair<int,int>> path(M);
    rep(i,M){
        cin>>path[i].first>>path[i].second;
    }
    


    // 初期順列
    vector<int> order(N+1);
    rep3(i,N) order[i] = i;

    int count=0;
    bool judge_all;
    bool judge[10];


    // 探索
    
    do {
        if(order[1]!=1){
            continue;
        }
        judge_all=true;
        rep4(i,2,N){
            judge[i]=false;
        }
        rep(i,M){
            rep4(j,2,N){
            if(((path[i].first==order[j-1])&&(path[i].second==order[j]))||((path[i].first==order[j])&&(path[i].second==order[j-1]))){
                judge[j]=true;
            }
            }

        }
        rep4(i,2,N){
            if(!judge[i]){
                judge_all=false;

            }
        }
        if(judge_all){
            count++;
        }

        
    } while (next_permutation(order.begin(), order.end()));

    // 答えを出力
    cout << count << endl;
return 0;
}



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

const int mod = 1e9+7;

int32_t main(){

   int h , w;
   cin >> h >> w;

   for(int x=0;x<w+2;x++)
    cout << "#";    cout << endl;

    for(int x=0;x<h;x++){
        string s;   cin >> s;
        cout << "#" << s << "#" << endl;
    }

   for(int x=0;x<w+2;x++)
    cout << "#";    cout << endl;

    return 0;
}

Measured memory_bytes: 256
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def kolorowe_grafy():
    N = wczytaj_liste()[0]
    lista_krawedzi = []
    listy_krawedzi = [[]]
    for i in range(N-1):
        lista_krawedzi.append(wczytaj_liste())
        listy_krawedzi.append([])
    for w1, w2 in lista_krawedzi: 
        listy_krawedzi[w1-1].append(w2)
        listy_krawedzi[w2-1].append(w1)
        
    do_przejrzenia = [1]
    kolory_zabronione = {1: 0}
    indeks_przegladanego = 0 
    kolor_tenczy = {}
    while indeks_przegladanego < len(do_przejrzenia): 
        aktualnie_przegladany = do_przejrzenia[indeks_przegladanego]
        kolor = 1
        if kolor == kolory_zabronione[aktualnie_przegladany]:
            kolor += 1
        for sasiad in listy_krawedzi[aktualnie_przegladany-1]: 
            if sasiad not in kolory_zabronione: 
                kolory_zabronione[sasiad] = kolor
                kolor_tenczy[(aktualnie_przegladany,sasiad)]=kolor
                kolor_tenczy[(sasiad,aktualnie_przegladany)]=kolor
                kolor += 1
                
                if kolor == kolory_zabronione[aktualnie_przegladany]:
                    kolor += 1
                do_przejrzenia.append(sasiad)
        indeks_przegladanego += 1
    maximum = 0
    for w1, w2 in lista_krawedzi:
        maximum = max(kolor_tenczy[(w1,w2)], maximum)
    print(maximum)
    for w1, w2 in lista_krawedzi:
        print(kolor_tenczy[(w1,w2)])

kolorowe_grafy()

Measured memory_bytes: 123604
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 100000000000000000; // = 10^17
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
//前処理テーブルの大きさ指定
const int MAX = 1200000; // = 10^6 + 2*(10^5)
//ちなみに、1024MBで持てる最大長の配列は10^8程度

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる。
  ll cost; // e.costでその辺の重みにアクセスできる。
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける。
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す。
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す。
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}

//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  ll A;
  double B;
  cin >> A >> B;
  ll C = B * 100 + 0.0001;
  A *= C;
  cout << A / 100 << endl;
}

Measured memory_bytes: 3732
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

signed main()
{
  ll N;
  map< ll, ll > A;

  cin >> N;

  bool ans = true;
  REP(i, N)
  {
    ll ai;
    cin >> ai;
    if (A[ai])
    {
      ans = false;
      break;
    }
    else
    {
      A[ai] = 1;
    }
  }
  cout << (ans ? "YES" : "NO") << endl;
}

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

#define inf 0x3f3f3f3f
#define endl '\n'
const int N = 1e5+5;
int n, k;
int a[N];
int dp[N];

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

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

    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);

    for(int i = 2; i < n; i++){
        dp[i] = inf;
        for(int j = 1; j <= min(i, k); j++){
            dp[i] = min(dp[i-j] + abs(a[i] - a[i-j]), dp[i]);
        }
    }

    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,x = map(int,ipt().split())
    a = [int(i) for i in ipt().split()]
    ans = 0
    if a[0]+a[1] > x:
        ans += a[0]+a[1]-x
        a[1] = max(0,x-a[0])
    for i in range(1,n-1):
        ai = a[i]
        ai1 = a[i+1]
        if ai+ai1 > x:
            ans += ai+ai1-x
            a[i+1] = x-ai
    print(ans)



    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 20836
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,b,f,r,v,a[5][4][11];
	cin >> n;
	for(int i=1;i<=4;i++){
		for(int j=1;j<=3;j++){
			for(int k=1;k<=10;k++){
				a[i][j][k]=0;
			}
		}
	}
	for(int i=1;i<=n;i++){
		cin >> b >> f >> r >> v;
		a[b][f][r]+=v;
	}
	for(int i=1;i<=4;i++){
		for(int j=1;j<=3;j++){
			for(int k=1;k<=10;k++){
				cout << ' ' << a[i][j][k];
				if(k==10) cout << endl;
			}
		}
		if(i!=4){
			for(int l=0;l<20;l++){
				cout << '#';
			}
			cout << endl;
		}
	}
}
	


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

using namespace std;

const int N = 1e5+77;

typedef long long ll;

typedef pair<ll,ll> pll;
vector<pll> G[N];

ll d[N];
ll pref[N];

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n ,q;
	cin >> n >> q;

	vector<ll> qrs;
	ll v;

	if(q == 0)
		qrs.push_back(n);

	for(int i=0;i<q;i++) {
		cin >> v;
		while(qrs.size() > 0 and qrs[qrs.size()-1] >= v)
			qrs.pop_back();
		qrs.push_back(v);
	}

	for(int i=0;i<(int)qrs.size();i++) {
	
		ll val = qrs[i];
		ll last = i > 0 ? qrs[i-1] : n;
		ll pelne = val/last;
		ll zostalo = val - last*pelne;
		G[i].push_back(pll(i-1, pelne));

		while(zostalo) {
			//cout << "dla zostalo " << zostalo << endl;
			int pos = lower_bound(qrs.begin(), qrs.end(), zostalo+1)-qrs.begin()-1;
			if(pos < 0) pos = 0;
			if(pos >= (int)qrs.size()) pos = qrs.size()-1;

			//cout << "znalazlem " << qrs[pos] << endl;

			if(qrs[pos] <= zostalo and pos < i) {
				pelne = zostalo/qrs[pos];
				zostalo = zostalo - qrs[pos] * pelne;
				G[i].push_back(pll(pos, pelne));
			} else {
				G[i].push_back(pll(-1, zostalo/n));
				G[i].push_back(pll(-2, zostalo%n));
				zostalo = 0;
			}
		}
	}

	/*for(int i=0;i<(int)qrs.size();i++) {
		cout << "qrs[" << i << "] = " << qrs[i] << endl;
		for(int j=0;j<(int)G[i].size();j++) 
			cout << "dodaje " << G[i][j].first << " ( " << G[i][j].second << ") razy " << endl;
	}*/

	d[qrs.size()-1] = 1;
	for(int i=qrs.size()-1;i>=0;i--) {
		//cout << "d[" << i << "] = " << d[i] << endl;
		for(pll w: G[i])  {
			if(w.first >= 0)
				d[w.first] += d[i]*w.second;
			else if(w.first == -1) {
				pref[n] += d[i]*w.second;
			} else {
				pref[w.second] += d[i];
				//cout << "dodaje " << d[i] << " do " << w.second << endl;
			}
						
		}	
	}

	for(int i=n;i>=1;i--)
		pref[i] += pref[i+1];
	
	for(int i=1;i<=n;i++)
		cout << pref[i] << "\n";
}


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

int type = 26;

int main() {
	int D;
	cin >> D;
	// 不開催により低下する満足度
	int dec = 0;
	vector<int64_t> c(type);
	vector<int64_t> l(type, 0);
	rep(i, type) {
		cin >> c.at(i);
		dec += c.at(i);
	}
	// 開催により増加する満足度
	vector<vector<int64_t>> s(D, vector<int64_t>(type));
	rep(i, D) {
		rep(j, type) {
			cin >> s.at(i).at(j);
		}
	}

	vector<int64_t> t(D);
	rep(i, D) {
		cin >> t.at(i);
		t.at(i)--;
	}

	int a=0, b=0, x, y, z;
	rep(i, D) {
		// i日目に開催するtype
		x = t.at(i);
		// 開催による増加
		a += s.at(i).at(x);
		// 不開催による減少
		b += (dec - c.at(x)*(i-l.at(x)+1));
		l.at(x) = i+1;
		a -= b;
		// 暫定満足度
		cout << a << endl;
	}
}


Measured memory_bytes: 3716
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    int n;
    cin >> n;
    vector<string> vec(n);
    rep(i, n)
    {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    cout << vec.size() << endl;
    return 0;
}

Measured memory_bytes: 9612
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int32_t f(const int32_t n) {
  return (n % 2 == 0) ? n / 2 : 3 * n + 1;
}

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

  int32_t s;
  cin >> s;
  int32_t value = s;
  int32_t m = -1;
  vector<bool> lookup(1000000 + 1, false);
  lookup[value] = true;
  for (int32_t i = 2; i < 1000002; ++i) {
    value = f(value);
    if (lookup[value]) {
      m = i;
      break;
    } else {
      lookup[value] = true;
    }
  }
  cout << m << endl;

  return 0;
}


Measured memory_bytes: 384
n = int(input())
L = [[[0]*10  for i in range(3)] for j in range(4)]
for i in range(n):
	b, f, r, v = list(map(int, input().split()))
	L[b-1][f-1][r-1] += v
for i in range (4):
	for j in range(3):
		for k in range(10):
			print(" {}".format(L[i][j][k]), end="")
		print()
	if i != 3:
		print("#" *20)
		


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

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

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

    ll A,B,C,D; cin >> A >> B >> C >> D;

    while(true){
        C -= B;
        if(C <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if(A <= 0){
            cout << "No" << endl;
            return 0;
        }
    }

    return 0;

}

Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  vector<ll>vec(4);
  rep(i,4)cin>>vec[i];
  sort(vec.begin(),vec.end());
  vl a={1,4,7,9};
  if(vec==a)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    static final int MOD=1000000007;


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] bingo = new int[3][3];


        for(int i=0;i<3;i++)for(int j=0;j<3;j++)bingo[i][j]=sc.nextInt();
        int n=sc.nextInt();
        for(int i=0;i<n;i++){
            int b=sc.nextInt();
            for(int j=0;j<3;j++){
                for(int k=0;k<3;k++){
                    if(bingo[j][k]==b)bingo[j][k]=-1;
                }
            }
        }


        for(int i=0;i<3;i++){
            if(bingo[i][0]==-1&&bingo[i][1]==-1&&bingo[i][2]==-1) {
                System.out.println("Yes");
                return;
            }
            if(bingo[0][i]==-1&&bingo[1][i]==-1&&bingo[2][i]==-1){
                System.out.println("Yes");
                return;
            }
        }
        if(bingo[0][0]==-1&&bingo[1][1]==-1&&bingo[2][2]==-1){
            System.out.println("Yes");
            return;
        }
        if(bingo[2][0]==-1&&bingo[1][1]==-1&&bingo[0][2]==-1){
            System.out.println("Yes");
            return;
        }

        System.out.println("No");



    }
}




Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define MOD ll(1e9 + 7)
using namespace std;

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

int cnt[64][2];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("path.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll t;
        cin >> t;
        for (int l = 0; l < 62; l++) {
            int x = 0;
            if (((1LL << l) & t) > 0)
                x = 1;
            ans += cnt[l][x ^ 1] * ((1LL << l) % MOD);
            ans %= MOD;
            cnt[l][x]++;
        }
    }
    cout << ans;

    return 0;
}


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

using pii = pair<int, int>;
constexpr double eps = 1e-10;

struct edge {
    int to, rev, cap;
    double cost;
    edge(int t, int c, double ct, int r) : to(t), rev(r), cap(c), cost(ct) {}
};
using graph = vector<vector<edge>>;

void add_edge(graph& g, int from, int to, int cap, double cost) {
    g[from].emplace_back(to, cap, cost, g[to].size());
    g[to].emplace_back(from, 0, -cost, g[from].size() - 1);
}

double min_cost_flow(graph& g, int s, int t, int f) {
    using P = pair<double, int>;
    const double inf = 1e18;
    double res = 0;
    vector<double > h(g.size()), dist(g.size());
    vector<int> prevv(g.size()), preve(g.size());
    while(f > 0) {
        priority_queue<P, vector<P>, greater<>> que;
        fill(begin(dist), end(dist), inf);
        dist[s] = 0;
        que.emplace(0, s);
        while(!que.empty()) {
            const auto cur_d = que.top().first;
            const int v = que.top().second;
            que.pop();
            if(dist[v] < cur_d) continue;
            for(int i = 0; i < (int)g[v].size(); ++i) {
                auto& e = g[v][i];
                if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to] + eps) {
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v;
                    preve[e.to] = i;
                    que.emplace(dist[e.to], e.to);
                }
            }
        }
        if(dist[t] == inf) return -1;
        for(int v = 0; v < (int)g.size(); ++v) {
            h[v] += dist[v];
        }

        auto d = f;
        for(int v = t; v != s; v = prevv[v]) {
            d = min(d, g[prevv[v]][preve[v]].cap);
        }
        f -= d;
        res += d * h[t];
        for(int v = t; v != s; v = prevv[v]) {
            auto& e = g[prevv[v]][preve[v]];
            e.cap -= d;
            g[v][e.rev].cap += d;
        }
    }
    return res;
}

int main() {
    int n; cin >> n;
    int ix, iy; cin >> ix >> iy;
    vector<int> sx(n), sy(n), gx(n), gy(n);
    for(int i = 0; i < n; ++i) {
        cin >> sx[i] >> sy[i] >> gx[i] >> gy[i];
    }

    double ans = 0;
    for(int i = 0; i < n; ++i) {
        ans += hypot(gx[i] - sx[i], gy[i] - sy[i]);
    }
    graph g(n * 2 + 2);
    const int src = n * 2, sink = n * 2 + 1;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            add_edge(g, i, j + n, 1, hypot(sx[j] - gx[i], sy[j] - gy[i]));
        }
        add_edge(g, src, i, 1, 0);
        add_edge(g, i + n, sink, 1, 0);
    }
    ans += min_cost_flow(g, src, sink, n);

    cout << fixed << setprecision(10) << ans << endl;
}



Measured memory_bytes: 10040
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[] args) {
		//BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		String str=sc.nextLine();
		if(str.length()==2)
			System.out.println(str);
		else
		{
			for(int i=str.length()-1;i>=0;i--)
				System.out.print(str.charAt(i));
			System.out.println();
		}
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define al(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define pb push_back
#define inin(x) int x; cin>>x;
#define ll long long

typedef pair<int, int> pii;

struct Calendar
{
	long long year;
	long long month;
	long long day;
	long long dat[2][13];
	Calendar(long long y, long long m, long long d)
	{
		year = y;
		month = m;
		day = d;
		dat[0][0] = dat[1][0] = 0;
		dat[0][1] = dat[1][1] = 31;
		dat[0][2] = dat[1][2] = 28;
		dat[0][3] = dat[1][3] = 31;
		dat[0][4] = dat[1][4] = 30;
		dat[0][5] = dat[1][5] = 31;
		dat[0][6] = dat[1][6] = 30;
		dat[0][7] = dat[1][7] = 31;
		dat[0][8] = dat[1][8] = 31;
		dat[0][9] = dat[1][9] = 30;
		dat[0][10] = dat[1][10] = 31;
		dat[0][11] = dat[1][11] = 30;
		dat[0][12] = dat[1][12] = 31;
		dat[1][2] = 29;
	}
	int uruu()
	{
		if (year % 4 == 0)
		{
			if (year % 400 != 0 && year % 100 == 0)
			{
				return 0;
			}
			else
			{
				return 1;
			}
		}
		return 0;
	}
	int uruu(long long y)
	{
		if (y % 4 == 0)
		{
			if (y % 400 != 0 && y % 100 == 0)
			{
				return 0;
			}
			else
			{
				return 1;
			}
		}
		return 0;
	}
	long long pday(long long d)
	{
		day += d;
		for (;; month++)
		{
			if (month >= 13)
			{
				year++;
				month = 1;
			}

			if (dat[uruu()][month] < day)
			{
				day -= dat[uruu()][month];
			}
			else
			{
				break;
			}
		}
		pmonth(0);
		return d;
	}
	long long pmonth(long long m)
	{
		month += m;
		for (;; year++)
		{
			if (month > 12)
			{
				month -= 12;
			}
			else
			{
				break;
			}
		}
		return m;
	}
	long long pyear(long long y)
	{
		year += y;
		return y;
	}
	long long dif(Calendar c)
	{
		long long ans = 0;
		Calendar a(year, month, day);
		ans -= a.day;
		ans += c.day;
		a.day = 0;
		c.day = 0;
		for (; a.month >= 1; a.month--)
		{
			ans -= dat[a.uruu()][a.month-1];
		}
		for (; c.month >= 1; c.month--)
		{
			ans += dat[c.uruu()][c.month-1];
		}
		for (; a.year != c.year; a.year++)
		{
			ans += 365;
			if (a.uruu())ans++;
		}
		return ans;
	}


};




int main()
{
	vector<ll> dp(150000, 1000000000);
	inin(n);
	rei(n)
	{
		ll a;
		cin >> a;
		*lower_bound(al(dp), a) = a;
	}
	rei(n+3)
	{
		if (dp[i] == 1000000000)
		{
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 2332
import sys
sys.setrecursionlimit(500000)

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
vs = n * (n - 1) // 2

vmap = {}
c = 0
for i in range(n):
    for j in range(i):
        vmap[(i, j)] = c
        vmap[(j, i)] = c
        c += 1

edges = [[] for _ in range(vs)]
numin = [0] * vs
for i in range(n):
    for j in range(n - 2):
        j1 = a[i][j] - 1
        j2 = a[i][j + 1] - 1
        edges[vmap[(i, j1)]].append(vmap[(i, j2)])
        numin[vmap[(i, j2)]] += 1

order = []
day = [1] * vs
q = [i for i in range(vs) if numin[i] == 0]
while len(q) > 0:
    index = q.pop(0)
    order.append(index)
    d = day[index]
    for i in edges[index]:
        numin[i] -= 1
        if numin[i] == 0:
            q.append(i)
            day[i] = max(day[i], d + 1)

print(max(day) if len(order) == vs else -1)


Measured memory_bytes: 209144
def resolve():
    a=int(input())
    b=int(input())
    c=int(input())
    x=int(input())
    cnt=0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if 500*i+100*j+50*k==x:
                    cnt+=1
    print(cnt)
resolve()

Measured memory_bytes: 3060
#define NDEBUG
NDEBUG


#include <algorithm>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <random>


typedef int64_t int64;


using namespace std;

// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    /// caide keep
    template<int N>
    struct bytetype {
        
    };

    /// caide keep
    template<>
    struct bytetype<4> {
        
    };

    /// caide keep
    template<>
    struct bytetype<3> {
        
    };

    /// caide keep
    template<>
    struct bytetype<2> {
        
    };

    /// caide keep
    template<>
    struct bytetype<1> {
        
    };

    /// caide keep
    template<>
    struct bytetype<0> {
        
    };

    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
    int64 a = next<int64>(in);
    int64 b = next<int64>(in);
    if (abs(a - b) <= 1) {
        out << "Brown\n";
    } else {
        out << "Alice\n";
    }
//    memset(gr, -1, sizeof gr);
////    dbg(rec(5, 0));
//    for (int sum = 0; sum <= 100; ++sum) {
//        for (int a = 0; a <= sum; ++a) {
//            dbg(a, sum - a, rec(a, sum - a));
//        }
//    }
}


int main() {
    solve(cin, cout);
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#define YOSHI 1000000

int A[YOSHI],n;
int partition(int,int);

int main(){
    int i,q;
    
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%d",&A[i]);
    }
    
    q = partition(0,n - 1);
    
    for(i = 0;i < n;i++){
        if(i) printf(" ");
        if(i == q) printf("[");
        
        printf("%d",A[i]);
        
        if(i == q) printf("]");
    }
    printf("\n");
    
    return 0;
}

int partition(int p,int r){
    int x,i,j,t;
    
    x = A[r];
    i = p - 1;
    
    for(j = p;j < r;j++){
        if(A[j] <= x){
            i++;
            
            t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    
    t = A[i + 1];
    A[i + 1] = A[r];
    A[r] = t;
    
    return i + 1;
}




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

int main(void) {
    int Y, X, K;
    cin >> Y >> X >> K;
    vector<string> s(Y);
    rep(y,Y) cin >> s[y];
    int res = 0;
    rep(maskY, 1<<Y)rep(maskX, 1<<X){
        int cnt = 0;
        rep(y,Y)rep(x,X){
            if (maskY & bit(y)) continue;
            if (maskX & bit(x)) continue;
            if (s[y][x] == '#') cnt++;
        }
        if (cnt == K) res ++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main(){
    int D;
    cin >> D;
    if(D==22) {
        cout << "Christmas Eve Eve Eve" << endl;
    }

    if(D==23) {
            cout << "Christmas Eve Eve" << endl;
        }

    if(D==24) {
                cout << "Christmas Eve" << endl;
            }

    if(D==25){
                    cout << "Christmas" << endl;}
            }
            

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

int main() {
    
    long long a,b;
    cin>>a>>b;
    
    long long rem = a%b;
    
    if(rem == 0){
        cout<<rem<<endl;
    }else{
        if(rem>abs(rem-b)){
            cout<<abs(rem-b)<<endl;
        }else{
            cout<<rem<<endl;
        }
    }
    
    
	return 0;
}


Measured memory_bytes: 256