akhauriyash/Code-Regression huggingface dataset:
void main() {
	auto ip = readAs!(int[]), A = ip[0], B = ip[1], C = ip[2];
	auto K = ri;
	auto r = max(A,B,C)*2^^K;
	auto s = A+B+C-max(A,B,C);
	(r + s).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

Measured memory_bytes: 256
n = int(input())
x = 10**6
li = [True for i in range(x+10)]
li[0] = False
li[1] = False

for i in range(int(x**0.5)+1):
    if li[i]:
        m = 2
        while(i*m<=x):
            li[i*m] = False
            m += 1
#print(li)
for i in range(x):
    if i>=n and li[i]:
        print(i)
        break

Measured memory_bytes: 10904
(defun solve(a b c k)
  (let ((m (max a b c)))
    (+ (- (* m (expt 2 k)) m) a b c)))

(defun main()
  (let* ((a (read))
         (b (read))
         (c (read))
         (k (read)))
    (princ (solve a b c k))))


(main)


Measured memory_bytes: 24252
package main

import (
	"fmt"
	"unicode"
)

func count(s string, r rune) int {
	return count_range(s, r, 0, len(s))
}

func count_range(s string, r rune, from, to int) int {
	var cnt int
	for _, v := range s[from:to] {
		if v == r {
			cnt++
		}
	}
	return cnt
}

func count_lowers(s string) int {
	var cnt int
	for _, v := range s {
		if unicode.IsLower(v) {
			cnt++
		}
	}
	return cnt
}

func main() {
	var s string
	fmt.Scan(&s)
	if s[0] == 'A' && count(s, 'C') == 1 && count_range(s, 'C', 2, len(s)-1) == 1 &&
		count(s, 'A') == 1 && count_lowers(s) == len(s)-2 {
		fmt.Println("AC")
	} else {
		fmt.Println("WA")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
long long dp[110][110000];
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<n;i++)

int checker(int n){
  int pre=0;
  for(int j=1;j<=n;j++){
    if((n%j)==0){
      pre++;
    }
  }
  return pre;
}

int main(){
  int n;
  cin >> n;
  int ans=0;
  for(int i=1;i<=n;i+=2){
    int tmp = checker(i);
    if(tmp==8){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-26 14:57:13
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

template<class T> std::vector<T> divisor(T n) {
  std::vector<T> res;
  for (T i = 1; i * i <= n; ++i) {
    if (n % i == 0){
      res.push_back(i);
      if (i * i != n){
        res.push_back(n / i);
      }
    }
  }
  std::sort(res.begin(), res.end());

  return res;
}

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

  int n, m; cin >> n >> m;

  vector<int> v = divisor(m);

  int lim = m / n;

  debug(v, lim);

  cout << *(upper_bound(all(v), lim) - 1) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int a,b,c,d;
	d=n%10;
	c=(n%100)/10;
	b=(n%1000)/100;
	a=(n%10000)/1000;
	if(a+b+c+d==7)
		printf("%d+%d+%d+%d=7\n",a,b,c,d);
	else if(a-b+c+d==7)
		printf("%d-%d+%d+%d=7\n",a,b,c,d);
	else if(a+b-c+d==7)
		printf("%d+%d-%d+%d=7\n",a,b,c,d);
	else if(a-b-c+d==7)
		printf("%d-%d-%d+%d=7\n",a,b,c,d);
	else if(a+b+c-d==7)
		printf("%d+%d+%d-%d=7\n",a,b,c,d);
	else if(a-b+c-d==7)
		printf("%d-%d+%d-%d=7\n",a,b,c,d);
	else if(a+b-c-d==7)
		printf("%d+%d-%d-%d=7\n",a,b,c,d);
	else if(a-b-c-d==7)
		printf("%d-%d-%d-%d=7\n",a,b,c,d);
	return 0;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e18
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

int main(){
	int n,m;
	cin >> n>>m;
	int a, b;

	int p[200020] = { };
	//int s[200020] = { };

	rep(i, m) {
		cin >> a >> b;
		if (a == 1) p[b]++;
		if (b == n) p[a]++;
	}

	REP(i,0,n) {
		if (p[i] == 2) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}

	cout << "IMPOSSIBLE" << endl;
}






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

// #define multitest 1
// #define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b);
}

int main()
{
#ifndef Debug
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

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

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

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

int main()
{
  int N, M, C, A[21][21], B[21];
  cin >> N >> M >> C;
  for(int i = 0; i < M; ++i) cin >> B[i];
  for(int i = 0; i < N; ++i)
  {
    for(int j = 0; j < M; ++j)
    {
      cin >> A[i][j];
    }
  }

  int solved = 0;
  for(int i = 0; i < N; ++i)
  {
    int score = 0;
    for(int j = 0; j < M; ++j)
    {
      score += A[i][j] * B[j];
    }
    score += C;
    if(score > 0) solved++;
  }
  
  cout << solved << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, ans = -1; string s; cin >> n >> s;
    Rep(i, 1, s.size())
    {
        int cnt = 0;
        for (char c = 'a'; c <= 'z'; c++)
        {
            bool le = false, ri = false;
            rep(j, i)
            {
                if (s[j] == c) le = true;
            }
            Rep(j, i, n)
            {
                if (s[j] == c) ri = true;
            }
            if (le && ri) cnt++;
        }
        if (ans < cnt) ans = cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
N, K = gets.split.map(&:to_i)
x_list = gets.split.take(N).map(&:to_i)
distance_list = (0..(N - K)).map do |i|
  s = x_list[i]
  e = x_list[i + K - 1]
  distance = (s - e).abs
  start_distance = [s.abs, e.abs].min
  start_distance + distance
end
puts distance_list.min


Measured memory_bytes: 11780
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] a = new int[3];
        int[] b = new int[3];
        int[] count = new int[4];

        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt()-1;
            b[i] = sc.nextInt()-1;
            count[a[i]]++;
            count[b[i]]++;
        }

        List<Integer> countlist = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            countlist.add(count[i]);
        }


        if (countlist.contains(3) || countlist.contains(0)) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }
}







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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

using ar4 = array<int, 4>;

int main()
{
	while (true) {
		// input
		int n;
		cin >> n;
		if (!n)break;
		vector<pair<int, int>> pt(n);
		REP(i, n) {
			int p, t;
			cin >> p >> t;
			pt[i] = { p,t };
		}

		// init
		vector<vector<int>> dp(n, vector<int>(4, INF));;
		if (pt[0].second < pt[0].first) {
			cout << "NG 1" << endl;
			goto end;
		}
		dp[0][1] = pt[0].first;
		FOR(i, 1, n) {
			int back = pt[i - 1].first;
			int to = pt[i].first;
			int time = pt[i].second - pt[i - 1].second;
			// 1
			if (2 * back + to <= time)
				dp[i][1] = min(dp[i][1], dp[i - 1][1] + back + to);
			if (3 * back + to <= time)
				dp[i][1] = min(dp[i][1], dp[i - 1][2] + back + to);
			if (4 * back + to <= time)
				dp[i][1] = min(dp[i][1], dp[i - 1][3] + back + to);
			// 2
			if (2 * abs(back - to) <= time)
				dp[i][2] = min(dp[i][2], dp[i - 1][1] + abs(back - to));
			// 3
			if (3 * abs(back - to) <= time)
				dp[i][3] = min(dp[i][3], dp[i - 1][2] + abs(back - to));
			if (*min_element(dp[i].begin(), dp[i].end()) == INF) {
				cout << "NG " << i + 1 << endl;
				goto end;
			}
		}
		cout << "OK " << *min_element(dp.back().begin(), dp.back().end()) + pt.back().first << endl;
	end:;
	}
	return 0;
}



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

int main(){
    int n,x,exe=0;
    int i,j,m;

    while(1){

    scanf("%d %d",&n,&x);

    if(n==0&&x==0)
        break;

    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
            for(m=j+1;m<=n;m++){

                if(i<j&&j<m){
                    if(i+j+m==x){
                        exe++;
                    }

                }
            }
        }
    }

    printf("%d\n",exe);
    exe=0;
    }

    return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string str[4] = {"Sunny", "Cloudy", "Rainy", "Sunny"};
    string s; cin >> s;
    REP(i, 3) if(s == str[i]) cout << str[i + 1] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define N 500000
#define INFTY 1000000000

int n, count = 0;
int A[N];

void merge(int *,int, int, int);
void mergeSort(int *, int, int);

int main()
{

  int i, j;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  mergeSort(A, 0, n);

  for(j=0; j<n; j++){
    if(j == n-1) printf("%d\n",A[j]);
    else printf("%d ",A[j]);
  }

  printf("%d\n",count);

  return 0;
}

void merge(int *A, int left, int mid, int right)
{

  int n1, n2, i, j, k;
  int *L, *R;

  n1 = mid - left;
  n2 = right - mid;

  L = (int *)malloc(sizeof(int)*(n1+1));
  R = (int *)malloc(sizeof(int)*(n2+1));

  for(i=0; i<=(n1-1); i++){
    L[i] = A[left+i];
  }

  for(i=0; i<=(n2-1); i++){
    R[i] = A[mid+i];
  }

  L[n1] = INFTY;
  R[n2] = INFTY;

  i = 0;
  j = 0;

  for(k=left; k<=(right-1); k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
    }
    count++;
  }

  free(L);
  free(R);

}

void mergeSort(int *A, int left, int right)
{

  int mid; 

  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

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

using namespace std;

map<int,int>mp;

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int tmp;
        cin>>tmp;
        mp[tmp]++;
    }
    if(mp.size()>3) cout<<"No"<<'\n';
    else
    {
        int a[4],cnt=0;
        for(auto i:mp)
        {
            a[++cnt]=i.first;
        }
        if(mp.size()==3)
        {
            if((a[1]^a[2])==a[3]&&mp[a[1]]==mp[a[2]]&&mp[a[2]]==mp[a[3]]) cout<<"Yes\n";
            else cout<<"No\n";
        }
        else if(mp.size()==2)
        {
            if(a[1]==0&&2*mp[a[1]]==mp[a[2]]) cout<<"Yes\n";
            else cout<<"No\n";
        }
        else if(mp.size()==1) 
        {
            if(a[1]==0) cout<<"Yes\n";
            else cout<<"No\n";
        }
    }
    return 0;
}

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

#define PI 3.14159265359
#define MODULO 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int x, n;
  int index;
  int diff = 100;
  cin >> x >> n; 
  vi v(102);
  for(int i =0; i<n;i++){
    int k;
    cin >> k;
    v[k] = !!k;
  }
  for(int i =0; i<102;i++){
    if(v[i] == 0){
      if( abs(i-x) <diff){
        diff = abs(i-x);
        index = i;
      }
    }
  }
  cout << index;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
struct FlowEdge {
    int v, u;
    long long cap, flow = 0;
    FlowEdge(int v, int u, long long cap) : v(v), u(u), cap(cap) {}
};

struct Dinic {
    const long long flow_inf = 1e18;
    vector<FlowEdge> edges;
    vector<vector<int>> adj;
    int n, m = 0;
    int s, t;
    vector<int> level, ptr;
    queue<int> q;

    Dinic(int n, int s, int t) : n(n), s(s), t(t) {
        adj.resize(n);
        level.resize(n);
        ptr.resize(n);
    }

    void add_edge(int v, int u, long long cap) {
        edges.emplace_back(v, u, cap);
        edges.emplace_back(u, v, 0);
        adj[v].push_back(m);
        adj[u].push_back(m + 1);
        m += 2;
    }

    bool bfs() {
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int id : adj[v]) {
                if (edges[id].cap - edges[id].flow < 1)
                    continue;
                if (level[edges[id].u] != -1)
                    continue;
                level[edges[id].u] = level[v] + 1;
                q.push(edges[id].u);
            }
        }
        return level[t] != -1;
    }

    long long dfs(int v, long long pushed) {
        if (pushed == 0)
            return 0;
        if (v == t)
            return pushed;
        for (int& cid = ptr[v]; cid < (int)adj[v].size(); cid++) {
            int id = adj[v][cid];
            int u = edges[id].u;
            if (level[v] + 1 != level[u] || edges[id].cap - edges[id].flow < 1)
                continue;
            long long tr = dfs(u, min(pushed, edges[id].cap - edges[id].flow));
            if (tr == 0)
                continue;
            edges[id].flow += tr;
            edges[id ^ 1].flow -= tr;
            return tr;
        }
        return 0;
    }

    long long flow() {
        long long f = 0;
        while (true) {
            fill(level.begin(), level.end(), -1);
            level[s] = 0;
            q.push(s);
            if (!bfs())
                break;
            fill(ptr.begin(), ptr.end(), 0);
            while (long long pushed = dfs(s, flow_inf)) {
                f += pushed;
            }
        }
        return f;
    }
};
int main()
{
	int n,m,s,t;
	cin>>n>>m;
	s=0;t=n-1;
	Dinic ob(n,s,t);
	for(int i=0;i<m;i++)
	{
		int u,v,w;cin>>u>>v>>w;
		ob.add_edge(u,v,w);
	}
	cout<<ob.flow()<<endl;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[1010];

inline bool check(){
    rin{
        if(a[i]%2==0){
            if(a[i]%5>0 && a[i]%3>0){
                return false;
            }
        }
    }
    return true;
}

int main() {
    cin>>n;
    rin{
        cin>>a[i];
    }
    cout<<(check()?"APPROVED":"DENIED")<<endl;


    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#define all(c) (c).begin(),(c).end()

using namespace std;

string toStr(int n){
  stringstream ss;
  ss << n;
  return ss.str();
}

int main(void){
	
	vector<int>pnum;
	
	for(int i=0;i<20001;i++){
		string s=toStr(i);
		string r=s;
		reverse(all(r));
		if(s==r)pnum.push_back(i);
	}
	
	int n;
	while(cin >> n){
		vector<int>::iterator l;
		l=lower_bound(all(pnum),n);
	
		if(abs(n-*(l-1))>abs(n-*l))cout << *l << endl;
		else cout << *(l-1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1252
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INF (1LL << 62)
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){
  
  int n,k;
  cin >> n >> k;
  
  vector<ll> x(n),y(n);  // 座標を保持
  vector<P> xy;
  REP(i,n){
    cin >> x[i] >> y[i];
    xy.push_back({x[i],y[i]});
  }
  
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  
 /* REP(i,n){
    cout << xy[i].first << " " << xy[i].second << endl;
  }
  */
  
  ll ans = INF;
    FOR(xi,0,n-1){
      FOR(xj,xi+1,n){
        FOR(yi,0,n-1){
          FOR(yj,yi+1,n){
            int sum = 0;
            REP(i,n){
              if(x[xi] <= xy[i].first && xy[i].first <= x[xj]
              && y[yi] <= xy[i].second && xy[i].second <= y[yj])
                sum++;
            }
            if(sum >= k) ans = min(ans,(x[xj]-x[xi])*(y[yj]-y[yi]));
          }
        }
      }
    }
  
  cout << ans << endl;

 return 0;
}

Measured memory_bytes: 256
eval"N,H,D="+`tr \\  ,`
M=10**9+7
s=n=0
t=1
1.upto(N){|i|s+=t=t*i%M}
H.times{|i|x=n*s
i<D&&x+=t
$*<<x%=M
n+=x-($*[~D]||0)}
p$*[-1]

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


int main(){
    int N; cin>>N;
    vector<int> h(N,0),f(N,0);
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    f[0]=0;
    f[1]=abs(h[0]-h[1]);
    for(int i=2;i<N;i++){
        f[i]=min(f[i-2]+abs(h[i]-h[i-2]),f[i-1]+abs(h[i]-h[i-1]));  //最短距離
    }
    cout<<f[N-1];
    return 0;
}

Measured memory_bytes: 1024
r,c=map(int,input().split())
x=[list(map(int,input().split())) for i in range(r)]
y=[0]*(c+1)

for i in range(r):
    x[i].append(sum(x[i]))

for j in range(c+1):
    for i in range(r):
        y[j]+=x[i][j]

for i in range(r):
    print(*x[i])
print(*y)


Measured memory_bytes: 6200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int r = in.nextInt();
        int result = r;
        if(n<10) {
            result = r + 100 * (10 - n);
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 24148
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

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

    for (auto c : s) {
        cout << (char)((((c-'A') + n) % 26) + 'A');
    }
    cout << endl;
}

Measured memory_bytes: 888
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n = map(int, input())
    ans = sum(n)
    if ans % 9 == 0:
        print("Yes")
    else:
        print("No")
    return 0
if __name__ == "__main__":
    solve()

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

typedef long long ll;
const ll INF = 1e9;

int main() {
    int N, M;
    while (cin >> N >> M, N+M) {
        ll d[2][N][N];
        for (int from = 0; from < N; from++) for (int to = 0; to < N; to++) {
            d[0][from][to] = (from == to ? 0 : INF);
            d[1][from][to] = (from == to ? 0 : INF);
        }
        for (int i = 0; i < M; i++) {
            int x, y, t; char sl;
            cin >> x >> y >> t >> sl;
            x--, y--;
            d[sl == 'S'][x][y] = d[sl == 'S'][y][x] = min(d[sl == 'S'][x][y], (ll)t);
        }
        for (int k = 0; k < N; k++) for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
            d[0][i][j] = min(d[0][i][j], d[0][i][k] + d[0][k][j]);
            d[1][i][j] = min(d[1][i][j], d[1][i][k] + d[1][k][j]);
        }

        int R; cin >> R;
        vector<int> route(R);
        for (int i = 0; i < R; i++) {
            cin >> route[i];
            route[i]--;
        }

        ll dp[R][N]; // (# of done, ship_pos)
        for (int i = 0; i < R; i++)
            for (int j = 0; j < N; j++) dp[i][j] = INF;
        dp[0][route[0]] = 0;
        for (int n_done = 0; n_done < R - 1; n_done++) {
            int from = route[n_done], to = route[n_done + 1];
            for (int ship = 0; ship < N; ship++) {
                dp[n_done + 1][ship] = min(dp[n_done + 1][ship], dp[n_done][ship] + d[0][from][to]);
                for (int pos = 0; pos < N; pos++) {
                    ll move_cost = d[0][from][ship] + d[1][ship][pos] + d[0][pos][to];
                    dp[n_done + 1][pos] = min(dp[n_done + 1][pos], dp[n_done][ship] + move_cost);
                }
            }
        }

        ll ans = INF;
        for (int ship = 0; ship < N; ship++) ans = min(ans, dp[R-1][ship]);
        cout << ans << endl;
    }
}



Measured memory_bytes: 5276
#include <iostream>
#include <vector>
#include <map>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	std::map<int,int> seq;
	int n,m;
	cin >> n >> m;
	for (int i = 1; i < n+1; i++) {
		seq[i] = i;
	}

	int now = 0;
	int num;
	for (int i = 0; i < m; i++) {
		cin >> num;
		seq[now] = num;
		now--;
	}

	std::vector<bool> check(n+1,false);
	for (int i = now+1; i < n+1; i++) {
		num = seq[i];
		if ( !check[num] ) {
			cout << num << endl;
			check[num] = true;
		}
	}

	return 0;
}

Measured memory_bytes: 17180
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

template<int m>
class Prime{
  std::vector<bool> p;
  std::vector<int> ps;
public:
  Prime(){
    p = std::vector<bool>(m,true);
    assert(m>1);
    p[0]=p[1]=false;
    for(int i=4;i<m;i+=2)
      p[i]=false;
    ps.push_back(2);
    for(int i=3;i<m;i+=2){
      if(p[i]){
        ps.push_back(i);
        for(int j=i+i;j<m;j+=i)
          p[j]=false;
      }
    }
  }

  bool isPrime(int n){
    assert(m>n);
    return p[n];
  }

  int operator [] (int n){
    if(n<ps.size()) return ps[n];
    else return 0;
  }

  int size(){
    return ps.size();
  }
};

int main(){
  Prime<(1<<15)+100> p;
  int n;
  while(cin>>n, n){
    int ans = 0;
    for(int i=0; p[i] + p[i] <= n; i++){
      if(p.isPrime(n - p[i]))
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import functools

@functools.lru_cache()
def lucas(n):
    if n == 0:
        return 2
    if n == 1:
        return 1
    else:
        return lucas(n-1) + lucas(n-2)

N = int(input())
print([lucas(i) for i in range(1, N+1)][-1])


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	ll n;cin>>n;
	vector<ll> mov(5);
	int i;
	rep(i,5)cin>>mov[i];
	sort(all(mov));
	ll ans;
	ans=(n+mov[0]-1)/mov[0]+4;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }

    Arrays.sort(a);

    long x = 0;
    long y = 0;
    int k = 0;

    for (int i = n-1; i > 0; i--) {
      if (a[i] == a[i-1]) {
        x = a[i];
        k = i;
        break;
      }
    }

    for (int i = k-2; i > 0; i--) {
      if (a[i] == a[i-1]) {
        y = a[i];
        break;
      }
    }

    System.out.println(x*y);
    
  }

}


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

typedef long long ll;

ll curpow, a[10001];
int N, K;
vector<ll> s[2];

ll get_ans(int m)
{
    if (curpow == -1LL)
    {
        ll ans = s[m][0];
        for (int i = 1; i < K; i++)
        {
            ans &= s[m][i];
        }
        return ans;
    }
    s[1-m].clear();
    for (ll x : s[m])
    {
        if (x & (1LL << curpow)) s[1-m].push_back(x);
    }
    if (s[1-m].size() == K) {
        curpow = -1LL;
        return get_ans(1-m);
    }
    else if (s[1-m].size() > K)
    {
        curpow--;
        return get_ans(1-m);
    }
    else
    {
        curpow--;
        return get_ans(m);
    }
}

int main()
{
    scanf("%d %d", &N, &K);
    for (int i = 1; i <= N; i++)
    {
        scanf("%lld", a + i);
        a[i] += a[i-1];
    }
    for (int i = 0; i <= N; i++)
    {
        for (int j = i + 1; j <= N; j++)
        {
            s[0].push_back(a[j] - a[i]);
        }
    }
    curpow = 60;
    printf("%lld\n", get_ans(0));
    return 0;
}


Measured memory_bytes: 6512
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	ret := 0
	for i := 1; i <= N; i++ {
		if 1 <= i && i <= 9 {
			ret++
		}
		if 100 <= i && i <= 999 {
			ret++
		}
		if 10000 <= i && i <= 99999 {
			ret++
		}
	}
	fmt.Println(ret)
}


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

using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define per(i, n) for (ll i = (ll)(n); i >= 0; i--)
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(ll i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

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

  vector<ll> ans(100000);
  ll current = 0;

  //if(n % 26 != 0) {
    while(n != 0) {
      ll tmp = n % 26;
      ans.at(current) += tmp + 96;
      //cout << ans.at(current) << endl;
      current++;
      n = n / 26;
      if(tmp == 0){
        ans.at(current-1)+=26;
        n--;
      }
    }
//  }
//  else {
    
//  }

//  cout << current << endl;

  per(i,current-1) {
    char ansc = ans.at(i);
    cout << ansc;
  }

  cout << endl;

  
  
}



Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MX = 100005;
ll X[MX];

int main() {
  int n;
  cin >> n;
  REP(i,n){
    int a;
    cin >> a;

    X[a]++;
  }
  int q;
  cin >> q;
  vector<ll> sum(q+1);

  sum[0] = 0;
  REP(i,MX){
    sum[0] += i * X[i];
  }



  for(int i = 1; i <= q; ++i){
    int b, c;
    cin >> b >> c;
    ll tmp_b = X[b];
    X[b] = 0;
    X[c] += tmp_b;

    sum[i] = sum[i-1] - tmp_b*b + tmp_b*c;
  }

  for(int i = 1; i <= q; ++i) cout << sum[i]<< endl;

  return 0;
}

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

#define MAXN (200010)

char s[MAXN], t[MAXN];
std::vector<std::vector<int>> cnt1(26), cnt2(26);

int main() {
    scanf("%s", s);
    scanf("%s", t);
    for (int i = 0; s[i]; ++i) {
        cnt1[s[i] - 'a'].push_back(i);
        cnt2[t[i] - 'a'].push_back(i);
    }
    // aba
    // abb
    // cnt1 = {{0, 2}, {1}, {}, {}, ...}
    // cnt2 = {{0}, {1, 2}, {}, {}, ...}
    std::sort(cnt1.begin(), cnt1.end());
    std::sort(cnt2.begin(), cnt2.end());
    puts(cnt1 == cnt2 ? "Yes" : "No");
    return 0;
}
/*
abb
aba
 */


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

int main(){
    int n; cin >> n;
    ll x; cin >> x;
    ll ans = 0;
    vector<ll> a(n);
    for(int  i = 0; i < n; i++){
        cin >> a[i];
    }
    if(a[0] > x){
        ans += a[0] - x;
        a[0] -= a[0] - x;
    }
    for(int i = 1; i < n; i++){
        if(a[i-1] + a[i] > x){
            ans += a[i-1] + a[i] - x;
            a[i] -= a[i-1] + a[i] - x;
        }
    }
    cout << ans << endl;
}

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

struct student
{
    int num;
    int a;

    student(int n, int aa)
    {
        num = n;
        a = aa;
    }
    bool operator<(const student &another) const
    {
      return a < another.a;
    };

};

int main(){
  int N;
  cin >> N;
  vector<student> A;
  int temp;
  REP(i, 0, N){
    cin >> temp;
    student hoge(i+1, temp);
    A.push_back(hoge);
  }

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

  for(auto itr=A.begin(); itr!=A.end(); ++itr)
    cout << (*itr).num << " ";
  cout << endl;

  return 0;
}


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

int main(void){
	int l, r, d, res = 0;
	cin >> l >> r >> d;
	for(int i = l; i <= r; i++){
		if(i % d == 0) res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
# D-Knapsack

'''
3 8
3 30
4 50
5 60
'''

N, W = map(int, input().split())

w, v = [None] * N, [None] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp = [[None] * (W+1) for _ in range(N+1)]
dp[0] = [0] * (W+1)
# print(dp)

for i in range(N):
    for j in range(W + 1):
        if j >= w[i]:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i])
        else:
            dp[i + 1][j] = dp[i][j]

# print(dp)
print(dp[N][W])


Measured memory_bytes: 257656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
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);

    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    rep(i, h) cin >> grid[i];
    const int dy[] = {0, 1, 0, -1};
    const int dx[] = {1, 0, -1, 0};
    bool ans = true;
    rep(i, h) rep(j, w) if (grid[i][j] == '#') {
        bool flag = false;
        rep(k, 4) {
            int ni = i + dy[k], nj = j + dx[k];
            if (ni < 0 || nj < 0 || h <= ni || w <= nj) continue;
            if (grid[ni][nj] == '#') flag = true;
        }
        if (!flag) ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3604
//sumitrust2019
//Chandigarh University
//author: shivamkr21 (pseduo coders)
#include<bits/stdc++.h>
//#include "boost/multiprecision/cpp_int.hpp"
//#define eint int1024_t
#define lli long long int
#define endl "\n"
#define vint vector<int>
#define vvint vector< vector<int> >
#define pub push_back 
#define mod 1000000007
//using namespace boost::multiprecision;
using namespace std;
lli fun_cal(lli x, lli y, lli l, lli r);
int main()
{
    std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	lli m1,d1,m2,d2,res=0;
	cin>>m1>>d1>>m2>>d2;
	if(m1==1 && d1==31)
		res=1;
	else if(m1==2 && d1==28)
	{
		if(m2==3 && d2==1)
			res=1;
	}
	else if(m1==2 && d1==29)
		res=1;
	else if(m1==3 && d1==31)
		res=1;
	else if(m1==4 && d1==30)
		res=1;
	else if(m1==5 && d1==31)
		res=1;
	else if(m1==6 && d1==30)
		res=1;
	else if(m1==7 && d1==31)
		res=1;
	else if(m1==8 && d1==31)
		res=1;
	else if(m1==9 && d1==30)
		res=1;
	else if(m1==10 && d1==31)
		res=1;
	else if(m1==11 && d1==30)
		res=1;
	else if(m1==12 && d1==31)
		res=1;

	cout<<res;

	return 0;

}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const ll INF = 1e18;

int main(){
	int n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vector<vector<vl>> dp(n+1, vector<vl>(2, vl(3, -INF)));
	dp[0][1][0] = 0;

	rep(i,n)rep(j,2)rep(k,3){
		if(k+j<3) dp[i+1][1][k+j] = max(dp[i][j][k], dp[i+1][1][k+j]);
		if(j){
			dp[i+1][0][k] = max(dp[i][j][k]+a[i], dp[i+1][0][k]);	
		}
	}
	
	if(n%2) cout << max(dp[n][1][1], dp[n][0][2]);
	else cout << max(dp[n][0][1], dp[n][1][0]); 
}

Measured memory_bytes: 34420
import re
import sys

# アルファベットをリストに入れる
alphbt = list("abcdefghijklmnopqrstuvwxyz")

# インプットデータを受け取る
inp = ""
for line in sys.stdin.readlines():
    inp += line

# 処理実行
for alp in alphbt:
    count = len(re.findall(alp, inp, flags=re.IGNORECASE))
    print(f"{alp} : {count}")



Measured memory_bytes: 6524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int x = sc.nextInt();
			int cnt = 0;
			int tmp = 0;
			do {
				tmp += x;
				tmp %= 360;
				cnt++;
			} while(tmp != 0);
			System.out.println(cnt);
		}
	}
}


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

int main() {
 int n,c=1,f=0;
 cin>>n;
 int a[n+1];
 a[0]=-1;
 
 for(int i=1;i<=n;i++)
 {
       cin>>a[i];
 }
 ll x=a[1];
 
 for(int i=1;i<=n;i++)
 {
      if(x==2)
      {f=1;
        break;
      }
      else
      {
        x=a[x];
        c++;
      }
 }
 if(f)
 {
   cout<<c<<endl;
 }
 else
 {
   cout<<-1<<endl;
 }

}

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

import Data.Bits

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b ] <- readInts
	print $ if a == 0 then f b else ( f $ a - 1 ) `xor` ( f b )

f x
	| x `mod` 4 == 0 = x
	| x `mod` 4 == 1 = 1
	| x `mod` 4 == 2 = x + 1
	| x `mod` 4 == 3 = 0

Measured memory_bytes: 508
n,m = map(int,input().split())
dic = {}
for i in range(n):
    dic[i+1]=set()
    
for _ in range(m):
    a,b = map(int,input().split())
    dic[a].add(b)
    dic[b].add(a)

max_num = 0
registerd_set = set()
for i in range(1,n+1):
    if i in registerd_set:
        continue
    else:
        people_list = [i]
        registerd_set.add(i)
    count = 0
    for people in people_list:
        count += 1
        for friend in dic[people]:
            if friend not in registerd_set:
                registerd_set.add(friend)
                people_list.append(friend)
    if max_num < count:
        max_num = count
print(max_num)

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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    string s, t;
    int ans = 0;
    cin >> s >> t;

    int l = s.size();
    rep(i, l)
    {
        if (s[i] != t[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3916
import sys
a='abcdefghijklmnopqrstuvwxyz'
for b in sys.stdin:
 b=b.strip()
 for i in range(26):
  c=''.join(a[ord(e)-97-i]if e in a else e for e in b)
  if any(('the'in c,'this'in c,'that'in c)):print(c)


Measured memory_bytes: 5568
# -*- coding: utf-8 -*-
"""
A - Blackjack
https://atcoder.jp/contests/abc147/tasks/abc147_a

"""
import sys


def solve(A):
    return 'win' if sum(A) <= 21 else 'bust'


def main(args):
    A = map(int, input().split())
    ans = solve(A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
# from math import gcd
def gcd(x, y):
    if y > x:
        x, y = y, x
    if y == 0:
        return x
    return gcd(y, x % y)


N, X = map(int, input().split())
x = [abs(X-int(x)) for x in input().split()]
if N == 1:
    print(x[0])
else:
    GCD = gcd(x[0], x[1])
    for i in range(2, N):
        GCD = gcd(GCD, x[i])
    print(GCD)


Measured memory_bytes: 14200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 100000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}



int main()
{
  int n ;
  cin>>n;
  int arr[n];
  map<int,int>m;
  int f=0;
  for(int i=0;i<n;i++)
  {
       cin>>arr[i];
       m[arr[i]]++;
       if(m[arr[i]]>1) f=1;
  }
  if(f==1) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

















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

int main() {
    int w, h;
    cin >> w >> h;
    vector<pair<long, int>> dat;
    for (int i = 0; i < w; i++) {
        long e;
        cin >> e;
        dat.emplace_back(e, 0);
    }
    for (int i = 0; i < h; i++) {
        long e;
        cin >> e;
        dat.emplace_back(e, 1);
    }
    
    sort(dat.begin(), dat.end());
    
    long ans = 0;
    for (const auto &e : dat) {
        long cost; int type;
        tie(cost, type) = e;
        if (type == 0) {
            ans += (long)(h + 1) * cost;
            w--;
        } else {
            ans += (long)(w + 1) * cost;
            h--;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  vvi dist(n, vi(n, 1e9)), cst(n, vi(n, 1));
  rep(i,0,n) rep(j,0,n) {
    ckmin(dist[i][j], i);
    ckmin(dist[i][j], j);
    ckmin(dist[i][j], n-i-1);
    ckmin(dist[i][j], n-j-1);
  }

#define in(i, j) (i >= 0 and i < n and j >= 0 and j < n)
#define id(i, j) ((i)*n + (j))

  int ans = 0;
  rep(_,0,n*n) {
    int k;
    cin >> k;
    --k;
    cst[k/n][k%n] = 0;
    ans += dist[k/n][k%n];
    deque<pair<int,int>> q;
    q.emplace_front(dist[k/n][k%n], k);
    while (not q.empty()) {
      auto [d,u] = q.front(); q.pop_front();
      int i = u/n, j = u%n;
      if (dist[i][j] < d) continue;
      rep(di, -1, 2) rep(dj, -1, 2) if (abs(di) + abs(dj) == 1) {
        int ni = i+di, nj = j+dj;
        if (not in(ni, nj)) continue;
        int nd = d+cst[i][j];
        if (nd==d and nd < dist[ni][nj]) {
          dist[ni][nj] = nd;
          q.emplace_front(nd, id(ni, nj));
        } else if (nd>d and nd < dist[ni][nj]) {
          dist[ni][nj] = nd;
          q.emplace_back(nd, id(ni, nj));
        }
      }
    }
  }

  cout << ans << '\n';

}

Measured memory_bytes: 6612