akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=s;i<t;i++)
typedef long long ll;
const ll inf=1e18;
ll dp[2][5555];int num[5555];
int main()
{
    int n,a,b;scanf("%d%d%d",&n,&a,&b);
    rep(i,1,n+1)scanf("%d",&num[i]);
    rep(i,1,n+1)dp[0][i]=inf;
    int type=1;dp[0][0]=0;
    rep(i,1,n+1)
    {
        rep(i,0,n+1)dp[type][i]=1e18;
        rep(j, 0, n+1)if(dp[!type][j]!=inf)
        {
            if(num[i]<j)dp[type][j]=min(dp[type][j],dp[!type][j]+b);
            else dp[type][j]=min(dp[type][j],dp[!type][j]+a),dp[type][num[i]]=min(dp[type][num[i]],dp[!type][j]);
        }
        type=!type;
    }
    ll res=inf;
    rep(i,1,n+1)res=min(res,dp[!type][i]);
    printf("%lld\n",res);
}

Measured memory_bytes: 384
import collections
cc = collections.Counter()
for _ in range(int(raw_input())): 
	cc[raw_input()[0]] +=1	

def dfs(i, total ,cumul, cc, k, s):
	if i == len(s) or k == 0:
		if k == 0: total[0] += cumul
		return 
	if k:
		dfs(i+1, total, cumul * cc[s[i]], cc,k - 1, s)

	dfs(i+1, total, cumul, cc, k, s)

total = [0]
dfs(0, total, 1 , cc, 3, 'MARCH')
print total[0]

Measured memory_bytes: 98876
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();

		long ans = 0;
		long max = 0;
		for(int i=0; i<N; i++) {
			if(max>A[i]) {
				ans += max-A[i];
			} else {
				max = A[i];
			}
		}
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 50244
def solve(K, ABs):
    if not ABs: return 0
    ansK = sum(b for a, b in ABs if (K | a) == K)
    pool = []
    for i in range(30, -1, -1):
        if (K & (1<<i)):
            pool.append(i)
    for p in pool:
        v = 1 << p
        KK = (K >> p) << p
        KKK = (K >> p)
        t = sum(b for a, b in ABs if (not(a & v) and (a | KK) >> p == KKK))
        if t > ansK: ansK = t
    return ansK
   

N, K = map(int, input().split())
ABs = []
for i in range(N):
    a, b = map(int, input().split())
    if a > K: continue
    ABs.append([a, b])

print(solve(K, ABs))

Measured memory_bytes: 80984
#include <iostream>
#include <cstdio>
#include <string>
#include <bits/stdc++.h>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

//using namespace std;


int main(){
  set<int> ans;

  for(int i=0;i<3;i++){
    int a;
    cin>>a;
    ans.insert(a);
  }

  cout<<ans.size()<<endl;
  
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(k: usize);
    for _ in 0..k {
        puts!("ACL");
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2248
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

string ss;

bool f(int index) {
    string ss1,ss2="AIDUNYAN";

    for(int i=index;i<index+8;i++) {
        ss1+=ss[i];
    }
    sort(ss1.begin(),ss1.end());
    sort(ss2.begin(),ss2.end());

    if(ss1!=ss2) return false;

    ss.replace(index,8,"AIZUNYAN");
    return true;
}

int main() {
    cin>>ss;

    rep(i,ss.size()) {
        if(f(i)) i+=7;
    }
    cout<<ss<<endl;

    return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
 
int main(){
    int d,n;
    cin>>d>>n;
    int ans;
  if(n==100) n++;
    ans=pow(100,d)*n;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[110];
int ans[110000];
vector<pair<int,int> >g[110000];
void dfs(int a,int b,int c){
	int now=0;
	if(now==c)now++;
	for(int i=0;i<g[a].size();i++){
		if(g[a][i].first==b)continue;
		ans[g[a][i].second]=now;
		dfs(g[a][i].first,a,now);
		now++;
		if(now==c)now++;
	}
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(make_pair(q,i));
		g[q].push_back(make_pair(p,i));
	}
	int ret=0;
	for(int i=0;i<a;i++){
		ret=max(ret,(int)g[i].size());
	}
	printf("%d\n",ret);
	dfs(0,-1,-1);
	for(int i=0;i<a-1;i++)printf("%d\n",ans[i]+1);
}


Measured memory_bytes: 9472
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Double[] list = Arrays.stream(sc.nextLine().split(" ")).map(Double::parseDouble).toArray(Double[]::new);
            System.out.println(list[0] <= list[6] && list[1] <= list[7] && list[2] >= list[4] && list[3] >= list[5] ? "YES" : "NO");
        }
    }
}



Measured memory_bytes: 31972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	static PrintWriter pw;
	static int n;

	static long gcd(long n, long m) {
		return (m == 0 ? n : gcd(m, n % m));
	}
	static int[] gcd2(int p, int q) {
	      if (q == 0)
	         return new int[] { p, 1, 0 };

	      int[] vals = gcd2(q, p % q);
	      int d = vals[0];
	      int a = vals[2];
	      int b = vals[1] - (p / q) * vals[2];
	      return new int[] { d, a, b };
	   }

	public static void main(String[] args) throws IOException, InterruptedException {
		Scanner sc = new Scanner(System.in);
		pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		PriorityQueue<Integer>pq = new PriorityQueue<Integer>();
		while(n-->0){
			pq.add(sc.nextInt());
		}
		while(pq.size()>1){
			int a =pq.poll();
			int b = pq.poll()%a;
			if(b!=0)pq.add(b);
			pq.add(a);
		}
		pw.println(pq.poll());
		pw.flush();
				}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define PI 3.1415926535

int main(void){

    int s, w;
    cin >> s >> w;
    if(s<=w)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin >> n;
  std::vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  std::sort(d.begin(), d.end());
  cout << d[n / 2] - d[n / 2 - 1] << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  double ans = 0;
  cin >> n >> k;
  FOR(i, 1, n+1) {
    int a = i;
    double tmp = 1.0 / n;
    while(a < k) {
      a *= 2;
      tmp /= 2.0;
    }
    ans += tmp;
  }
  cout << setprecision(20) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 50
#define INF 0x3f3f3f3f
LL f[MAXN+5],g[MAXN+5];
LL Fuc(LL n,LL k){
	if(!k) return 0;
	if(!n||k==g[n]) return f[n];
	if(k==g[n-1]+2)
		return Fuc(n-1,k-2)+1;
	else if(k<g[n-1]+2)
		return Fuc(n-1,k-1);
	return f[n-1]+1+Fuc(n-1,k-g[n-1]-2);//f[n-1]+2<k
}
int main(){//f[i]:等级为i的汉堡有f[i]片肉
	LL n=read(),k=read();
	g[0]=f[0]=1;
	for(int i=1;i<=n;i++)
		f[i]=2*f[i-1]+1,g[i]=2*g[i-1]+3;
	printf("%lld\n",Fuc(n,k));
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int[] a = new int[3];
		a[0] = parseInt(sc.next());
		a[1] = parseInt(sc.next());
		a[2] = parseInt(sc.next());
		sc.close();
		Arrays.parallelSort(a);
		out.println(a[0]+a[1]==a[2]?"Yes":"No");
	}
}


Measured memory_bytes: 23380
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a&1)||(b&1)||(c&1)) return puts("0"),0;
  for(int i=1;i<=10000000;i++){
    int a1=a>>1,b1=b>>1,c1=c>>1;
    a=b1+c1; b=a1+c1; c=a1+b1;
    if((a&1)||(b&1)||(c&1)) return printf("%d\n",i),0;
  }
  return puts("-1"),0;
}


Measured memory_bytes: 256
#coding=UTF-8

mozir=input()
hyo=mozir.split(' ')
N_toshi=int(hyo[0])
M_miti=int(hyo[1])

hindo=[0]*N_toshi

for idx in range(0,M_miti,1):
    mozir=input()
    hyo=mozir.split(' ')
    hashis=(int(mono)-1 for mono in hyo)
    for tenn in hashis:
        hindo[tenn]=hindo[tenn]+1

for tenn in hindo:
    print(tenn)


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

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

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;


int main(){
    //input
    ll n,q;
    cin >> n >> q;
    dsu d(n);
    rep(i,q){
        ll t,u,v;
        cin >> t >> u >> v;
        if(t==0){
            d.merge(u,v);
        }
        else{
            if(d.same(u,v))cout<<1<<endl;
            else cout << 0 << endl;
        }
    }

    
    return 0;
}


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

int main() {
  int x, y, z, result=0;
  
  cin >> x;
  cin >> y;
  cin >> z;
  
  for(int i=0;i<1000;i++) {
    
    x = x - y;
    result = result + z;
    if(x<=0) {
      break;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Buttons | diff Buttons.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Buttons.cpp && ./a.out

/*
 
 4/17/2019
 
 15:34-
 
 */

int A,B;

void solve() {
  if(A<B) swap(A,B);
  int res=A--;
  if(A<B) swap(A,B);
  res+=A--;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int ans = 0;
    while(true){
        bool flag = false;
        rep(i,n){
            if(a[i]%2==1) flag = true;
        }
        if(flag) break;
        rep(i,n) a[i]/=2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  competitive
//
//  Created by shinku on 2018/10/06.
//  Copyright © 2018 shinku. All rights reserved.
//

#include <iostream>
#include <utility>

using namespace std;
int main(int argc, const char * argv[]) {
    int n,t;
    cin >> n >> t;
    int res = 10000;
    for(int i = 0;i < n;i++) {
        int c,tt;
        cin >> c >> tt;
        if(tt <= t) {
            res = min(res,c);
        }
    }
    if(res == 10000) cout << "TLE";
    else cout << res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H, W; 
char A[110][110]; 
int INF = 1919; 
struct edge{
	int to, cap, rev; 
}; 
vector<edge> E[210]; // 0がS, [1,H]が水平, [H+1, H+W]が垂直, H+W+1がT
int level[210]; 
int iter[210]; 
void add_edge(int from, int to, int cap){
	E[from].push_back((edge){to, cap, (int) E[to].size()}); 
	E[to].push_back((edge){from, 0, (int) E[from].size()-1}); 
}
void bfs(int s){
	fill(level, level + H+W+2, -1); 
	queue<int> que; 
	level[s] = 0; 
	que.push(s); 
	while(que.size()){
		int v = que.front(); que.pop(); 
		for(auto i : E[v]){
			edge &e = i; 
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v] + 1; 
				que.push(e.to); 
			}
		}
	}
}
int dfs(int v, int t, int f){
	if(v == t) return f; 
	for(int &i = iter[v]; i < (int) E[v].size(); i++){
		edge &e = E[v].at(i); 
		if(e.cap > 0 && level[v] < level[e.to]){
			int d = dfs(e.to, t, min(f, e.cap)); 
			if(d > 0){
				e.cap -= d; 
				E[e.to].at(e.rev).cap += d; 
				return d; 
			}
		}
	}
	return 0; 
}
int max_flow(int s, int t){
	int flow = 0; 
	while(1){
		bfs(s); 
		if(level[t] < 0) return flow; 
		fill(iter, iter + H+W+2, 0); 
		int f; 
		while((f = dfs(s, t, INF)) > 0){
			flow += f; 
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> H >> W; 
	for(int i = 1; i <= H; i++){
		for(int j = 1; j <= W; j++){
			cin >> A[i][j]; 
			if(A[i][j] == 'S'){
				add_edge(0, i, INF); 
				add_edge(0, H+j, INF); 	
			}else if(A[i][j] == 'T'){
				add_edge(i, H+W+1, INF); 
				add_edge(H+j, H+W+1, INF); 				
			}else if(A[i][j] == 'o'){
				add_edge(i, H+j, 1); 
				add_edge(H+j, i, 1); 			
			}
		}
	}
	int ans = max_flow(0, H+W+1); 
	if(ans >= INF) cout << -1 << "\n"; 
	else cout << ans << "\n"; 
}

Measured memory_bytes: 4016
#include <iostream>

using namespace std;

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

    if (a%2!= 0 && b%2!= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  
    int a, n;
  
    scanf("%d", &n);
  
    if (n == 111){
       a = 999;
    }
  
    else if (n == 119){
       a = 991;
    }
   
    else if (n == 191){
       a = 919;
    }
  
    else if (n == 199){
       a = 911;
    }
  
    else if (n == 999){
       a = 111;
    }
  
    else if (n == 991){
       a = 119;
    }
  
    else if (n == 919){
       a = 191;
    }

    else {
       a = 199;
    }
  
    printf("%d\n", a);
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
#define LM 55555
using namespace::std;


long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

int A,B,C,X,Y,N, M[LM],num,v[55555],ch,ans;
string s[50], t[100];
bool a, b, c;
int main() {
	cin >> N;
	num = 1;
	ans = 1;
	for (int i = 2; i*i < N; i++) {
		num = 1;
		
		while (num <= N) {
			if (ans < num) {
				ans = num;
			}
			num = num*i;
		}
	}

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




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,s; 
int main()
{
	cin>>n>>a>>b;
	if(a>b) swap(a,b);
	for(int i=1;i<=n;i++)
	{
		long long k=i,l=0;
		while(k>0)
		{
			l=l+k%10;
			k=k/10;
		}
		if(l>=a&&l<=b) s+=i;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{

     public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int total  = a + b + c;
        
        if(total >= 22) System.out.println("bust");
        else System.out.println("win");
     }
}

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

class MainClass
{
    static void Main()
    {
        var NL = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NL[0];
        long L = NL[1];
        var a = ReadLine().Split().Select(long.Parse).ToArray();
        var kitcat = new bool[N - 1];
        for (int i = 0; i < N-1; i++)
        {
            if (a[i] + a[i + 1] >= L)
            {
                kitcat[i] = true;
            }
        }

        if (!kitcat.Contains(true))
        {
            WriteLine("Impossible");
        }
        else
        {
            WriteLine("Possible");
            int bindex = 0;
            int findex = N - 2;
            while (true)
            {
                if (!kitcat[bindex])
                {
                    WriteLine(bindex+1);
                    bindex++;
                }
                else
                {
                    break;
                }
            }
            while (bindex<=findex)
            {
                WriteLine(findex+1);
                findex--;
            }
        }
    }
}


Measured memory_bytes: 40816
#include<stdio.h>
#include<stdlib.h>
#define inf 3000

int MST(int **,int);

int main(){
  int i,j,n;
  int **weight;
  int total;

  scanf("%d",&n);
  weight = malloc(n*sizeof(int *));
  for(i=0 ; i<n ; i++) weight[i] = malloc(n*sizeof(int ));

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

  
  total = MST(weight,n);

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

  return 0;
}



int MST(int **T, int n){
 
  int a[n],f[n];
  int i,j,m,k=1;
  int num,sum = 0;
  
  a[0] = 0;
  f[0] = 1;
  for(i=1 ; i<n ; i++) f[i]=0;
  
  while(k != n){
    num = inf;
    for(i=0;i<k;i++){
      for(j=0;j<n;j++){
	if(T[a[i]][j]<num && T[a[i]][j]!=-1 && f[j]!=1){
	  num=T[a[i]][j];
	  m=j;
	}
      }
    }
    a[k] = m;
    f[m] = 1;
    sum += num;
    k++;
  }
      
  return sum;
}
  

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()

print(ceil(N, 2))


Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> a(m);
	rep(i,m){
		cin >> a[i];
		n -= a[i];
	}
	if(n<0){
		cout << -1;
	}
	else
		cout << n;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3664
N=int(input())
A=list(map(int,input().split()))

A=sorted(A,reverse=True)
if(len(A)%2==1):
    A.append(0)
c=0
l=1
t=0
th=0
for i in range(0,len(A),2):
    if(c==2):
        break
    if(A[i]==A[i+1]):
        c+=1
        l*=A[i]
        th=True
    elif(t==A[i] and not(th)):
        c+=1
        l*=A[i]
        th=False
    else:
        th=False
    t=A[i+1]
if(c==2):
    print(l)
else:
    print(0)

Measured memory_bytes: 14244
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

bool flag[32];
int main() {
	int n;
	int nim = 0;
	scanf("%d", &n);
	REP(i, n) {
		int x;
		scanf("%d", &x);
		nim ^= x;
		int t = 0;
		while(x % 2 == 0) {
			x >>= 1;
			t++;
		}
		flag[t] = true;
	}
	int ret = 0;
	while (nim) {
		int x = nim;
		int t = -1;
		while (x) {
			x >>= 1;
			t++;
		}
		if (flag[t] == false) {
			printf("-1\n");
			return 0;
		}
		nim ^= (1 << (t + 1)) - 1;
		ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
A,B=[int(x) for x in input().split()]
N=B-A+1#足し合わせる数

result=""
AS=bin(A)[2:]
BS=bin(B)[2:]
def calc(ST1,ST2):
    rt=""
    lg=max(len(ST1),len(ST2))
    ST1=("0"*lg+ST1)[-lg:]
    ST2=("0"*lg+ST2)[-lg:]
    for i in range(lg):
        if ST1[i]==ST2[i]:
            rt+="0"
        else:
            rt+="1"
    return rt


if AS[-1]=="0":
    if BS[-1]=="1":
        print(int(N/2)%2)
    else:
        print(int(calc(BS,str(int((N-1)/2)%2)),2)) 
else:
    if BS[-1]=="1":
        print(int(calc(AS,str(int((N-1)/2)%2)),2))
    else:
        print(int(calc(calc(AS,str(int((N-1)/2)%2)),BS),2))



Measured memory_bytes: 3064
/* ex3_4
   key_tree */

#include <stdio.h>

// Nを1-9で割った商が1-9かつ余りが0になればよい
int main(void) {
  int N;
  scanf("%d", &N);
  int i = 1;
  // 1-9まで調べる
  while(i < 10){
    int quotient = N / i;
    int remainder = N % i;
    //商が1-9かつ余り0
    if(quotient >= 1 && quotient <= 9 && remainder == 0){
      printf("Yes\n");
      break;/*当てはまったらwhile脱出*/
	}
    i += 1;
  }
  if(i == 10){
    printf("No\n");
  }
  return 0;
}


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

int main(void)
{
    int N;
    cin >> N;
    int A[N];
    int B[N] = {0};
    int i;
    A[0] = 0;
    for(i=1;i<N;i++){
        cin >> A[i];
        B[A[i]-1]++;
    }

    for(i=0;i<N;i++){
        cout << B[i] << endl;
    }

    return 0;

}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	Int K;
	cin >> K;

	Int N = 50;
	vector<Int> ans(N, K / N);
	for (int i = 0; i < N; ++i) {
		if (i < N - K % N) {
			ans[i] += i;
		} else {
			ans[i] += i + 1;
		}
	}

	cout << N << endl;
	for (int i = 0; i < N; ++i) {
		cout << ans[i] << (i < N - 1 ? " " : "\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;


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

    vi p(N);
    for(int i=0; i<N; i++){
        cin >> p.at(i);
    }

    sort(p.begin(), p.end());
    int sum = 0;
    for(int i=0; i<K; i++){
        sum += p.at(i);
    }

    cout << sum << endl;

}

Measured memory_bytes: 3184
/*
    WRITER:kakitamasziru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;
typedef pair<long,long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    //n!はi = 1;i<=nでする
    for (long long i = n-r+1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int dp[514514];

int main() {
    string S;cin >> S;
    if(S.at(0) != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    else{
        S.at(0) = 'a';
    }
    int count_C = 0;
    for(int i = 2;i<=S.size()-2;i++){
        if(S.at(i) == 'C') {
            count_C++;
            S.at(i) = 'c';
        }
    }

    if(count_C != 1){
        cout << "WA" << endl;
        return 0;
    }

    for(int i = 0;i<S.size();i++){
        if(S.at(i) - 32 < 65){
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
    
    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int ans = n;
		for (int i = 0; i <= n; i+=9) {
			int val = 0;
			int x = i;
			int a = (int) Math.pow(9, 5);
			while (x > 0) {
				val += x / a;
				x %= a;
				a /= 9;
			}
			int y = n - i;
			int b = (int) Math.pow(6, 6);
			while (y > 0) {
				val += y / b;
				y %= b;
				b /= 6;
			}
			ans = Math.min(ans, val);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22100
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long LL;

// import here

void solve_three(vector<vector<char>>& ans, LL& a, LL& b, LL y, LL x){
  ans[y+0][x+0] = '<'; ans[y+0][x+1] = '>'; ans[y+0][x+2] = '^';
  ans[y+1][x+0] = '^'; ans[y+1][x+1] = '.'; ans[y+1][x+2] = 'v';
  ans[y+2][x+0] = 'v'; ans[y+2][x+1] = '<'; ans[y+2][x+2] = '>';
  a -= 2;
  b -= 2;
}

int main(){
    LL n, m, a, b;
    cin >> n >> m >> a >> b;
    LL block = (n/2) * (m/2);
    LL h_line = min<LL>(a, (n%2) * (m/2));
    LL v_line = min<LL>(b, (m%2) * (n/2));
    LL a_block = (max<LL>(0, a-h_line) + 1) / 2;
    LL b_block = (max<LL>(0, b-v_line) + 1) / 2;
    vector<vector<char>> ans(2002, vector<char>(2002, '.'));
    for(LL i = 0; i < h_line; ++i){
        ans[n-1][i*2+0] = '<';
        ans[n-1][i*2+1] = '>';
        --a;
    }
    for(LL i = 0; i < v_line; ++i){
        ans[i*2+0][m-1] = '^';
        ans[i*2+1][m-1] = 'v';
        --b;
    }
    for(LL y = 0; y < n/2; ++y){
        for(LL x = 0; x < m/2; ++x){
            if(a >= 2){
                ans[y*2+0][x*2+0] = '<';
                ans[y*2+0][x*2+1] = '>';
                ans[y*2+1][x*2+0] = '<';
                ans[y*2+1][x*2+1] = '>';
                a -= 2;
                continue;
            }
            if(b >= 2){
                ans[y*2+0][x*2+0] = '^';
                ans[y*2+1][x*2+0] = 'v';
                ans[y*2+0][x*2+1] = '^';
                ans[y*2+1][x*2+1] = 'v';
                b -= 2;
                continue;
            }
            if(a > 0){
                ans[y*2+0][x*2+0] = '<';
                ans[y*2+0][x*2+1] = '>';
                --a;
                continue;
            }
            if(b > 0){
                ans[y*2+0][x*2+0] = '^';
                ans[y*2+1][x*2+0] = 'v';
                --b;
                continue;
            }
        }
    }
    if(n >= 3 && m >= 3 && n % 2 == 1 && m % 2 == 1 && b == 1 && ans[n-3][m-3]=='<' && ans[n-2][m-3]=='.'){
        solve_three(ans, a, b, n-3, m-3);
    }
    if(a > 0 || b > 0){
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    for(LL y = 0; y < n; ++y){
        for(LL x = 0; x < m; ++x){
            cout << ans[y][x];
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
  string S;
  cin >>S;
  if(S == "SUN"){
    cout << 7 << endl;
  }else if(S == "MON"){
    cout << 6 << endl;
  }else if(S == "TUE"){
    cout << 5 << endl;
  }else if(S == "WED"){
    cout << 4 << endl;
  }else if(S == "THU"){
    cout << 3 << endl;
  }else if(S == "FRI"){
    cout << 2 << endl;
  }else if(S == "SAT"){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())
    a = tuple(map(int, input().strip().split()))
    b = tuple(map(int, input().strip().split()))
    l = tuple([i+1 for i in range(n)])

    n_a = 0
    n_b = 0
    for (seq, i) in zip((itertools.permutations(l)), [i for i in range(math.factorial(n))]):
        if seq == a:
            n_a = i
        if seq == b:
            n_b = i
    print(abs(n_a - n_b))


if __name__ == '__main__':
    main()


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

int main()
{
    int A,B,C,X,Y,Z;
    cin>>X>>Y>>Z;

    A=X;
    B=Y;
    C=Z;

    swap(A,B);
    swap(A,C);

    cout<<A<<" "<<B<<" "<<C<<endl;
}


Measured memory_bytes: 256
N=int(input())
s=[input() for _ in range(N)]

s1,s2,s3,s4=[],[],[],[]
ans=0
for i in range(N):
  ans += s[i].count('AB')
  if s[i][0]=='B' and s[i][-1]=='A':
    s1.append(s[i])
  elif s[i][-1]=='A':
    s2.append(s[i])
  elif s[i][0]=='B':
    s3.append(s[i])
  else:
    s4.append(s[i])
    
if len(s2) and len(s3):
  ans += len(s1)+1
  ans += min(len(s2)-1,len(s3)-1)
  
elif len(s1) and len(s2):
  ans += len(s1)
  
elif len(s1) and len(s3):
  ans += len(s1)
  
elif len(s1):
  ans += len(s1)-1

print(ans)

Measured memory_bytes: 9876
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;

class Ins{
    public:
    int a,b,c,d;
    Ins(int _a, int _b, int _c, int _d):a(_a),b(_b),c(_c),d(_d){}
    
};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int h,w;
    cin>>h>>w;
    vector<vector<int>> a(h+1, vector<int>(w+1));
    
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin>>a[i][j];
        }
    }
    
    vector<Ins> vi;
    
    for(int i=1; i<=h; i++){
        for(int j=1; j<w; j++){
            if(a[i][j]%2){
                a[i][j]--;
                a[i][j+1]++;
                vi.push_back(Ins(i,j,i,j+1));
            }
        }
    }
    for(int i=1; i<h; i++){
        if(a[i][w]%2){
            a[i][w]--;
            a[i+1][w]++;
            vi.push_back(Ins(i,w,i+1,w));
        }
    }
    cout<<vi.size()<<endl;
    for(auto i:vi){
        cout<<i.a<<" "<<i.b<<" "<<i.c<<" "<<i.d<<endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 5236
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<vector<ll>> C(N, vector<ll>(N, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> C[i][j];
        }
    }
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            sum += min(C[i][j], C[j][i]);
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3188
import java.util.*;
import java.io.*;

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
         int N = in.nextInt();
         int K = in.nextInt();
         int[] h = new int[N];
         int count = 0;
         for(int i = 0; i<N;  i++)
         {
             h[i] = in.nextInt();
             if(h[i]>=K)
             {
                 count++;
             }

         }
        System.out.println(count);







    }







    }
















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

using namespace std;

int main()
{
    ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
    
    int A, B, C, K; cin >> A >> B >> C >> K; array< int, 3 > x = { A, B, C };
    
    sort( x.begin(), x.end() ), cout << (  x[ 0 ] + x[ 1 ] + x[ 2 ] * ( 1 << K ) );
        
}


Measured memory_bytes: 256