akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(15) //15桁表示



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

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;

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

	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
pp=[0]*n
res=0

qq=[True]*n
for i in range(m):
    i,j=input().split()
    i=int(i)
    i-=1
    if j=="AC":
        if qq[i]:
            qq[i]=False
            res+=pp[i]
    else:
        pp[i]+=1

print(qq.count(False),res)

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<bool>> swi(M, vector<bool>(N, false));
    vector<int> p(M);
    for (int i = 0; i < M; i++) {
        int K; cin >> K;
        for (int j = 0; j < K; j++) {
            int s; cin >> s; s--;
            swi[i][s] = true;
        }
    }
    for (int i = 0; i < M; i++) cin >> p[i];
    
    int ans = 0;
    for (int bit = 0; bit < (1<<N); bit++) {
        int lamp = 0;
        for (int i = 0; i < M; i++) {
            int cnt = 0;
            for (int k = 0; k < N; k++) {
                if ((bit&(1<<k)) && swi[i][k]) cnt++;
            }
            if (cnt%2 == p[i]) lamp++;
        }
        
        if (lamp == M) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

vector<string> merge(int d,vector<string> &vec){
    if(d<=0)return vec;
    vector<string> nvec(0);
    for(string x:vec){
        set<char> s;
        for(char c:x){
            s.insert(c);
        }
        for(int i=0;i<=s.size();i++){
            nvec.pb(x+(char)('a'+i));
        }
    }
    vec=merge(d-1,nvec);
    return vec;
}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int n;cin>>n;
    vector<string> vec={"a"};
    vec=merge(n-1,vec);
    for(auto x:vec)cout<<x<<endl;
}


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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = S()
    if s == 'ABC':
        print('ARC')
        return
    print('ABC')

main()



Measured memory_bytes: 10912
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout <<(a <= c && c <= b ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import sys

N, A, B = map(int, sys.stdin.readline().split())
if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    print(min(A + (B - A - 1) // 2, N - B + 1 + (B - A - 1) // 2))

Measured memory_bytes: 9148
#include <iostream>
using namespace std;
int main()
{
	int num[20][20], m, sum,n,b[20],cnt=0,c;
	cin>>m>>n>>c;
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>num[i][j];
		}
	}
	for(int i=0;i<m;i++)
	{
		sum=c;
		for(int j=0;j<n;j++)
		{
			sum+=b[j]*num[i][j];
		}
		if(sum>0)
		{
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			if ((ab[0] * ab[1]) % 2 == 0) {
				Console.WriteLine("No");
			} else {
				Console.WriteLine("Yes");
			}
		}
	}
}

Measured memory_bytes: 13268
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int MAX = INT_MAX;

int N,M;
int dp[20001][256];

vector<int> C;
vector<int> x;

int round255(int n)
{
	if(n > 255){ return 255; }
	else if(n < 0){ return 0;}
	else{ return n; }
}

int main()
{
	while(cin >> N >> M && N)
	{
		C.resize(M);
		x.resize(N);
		fill_n((int *)dp, sizeof(dp)/sizeof(int), MAX);

		rep(i,M){ cin >> C[i]; }
		rep(i,N){ cin >> x[i]; }

		dp[0][128] = 0;

		rep(i,N)
		{
			rep(j,256)
			{
				if(dp[i][j] == MAX){ continue; }	
				rep(k,M)
				{
					int yn = j + C[k];
					yn = round255(yn);
					int sum2 = (x[i] - yn)*(x[i] - yn);
					dp[i+1][yn] = min(dp[i+1][yn], dp[i][j]+sum2);
				}
			}
		}

		cout << *min_element(dp[N],dp[N]+256) << endl;
	}
	return 0;
}


Measured memory_bytes: 23160
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VL primes(int n){
    vector<bool> a(n+1, 1);
    VL p;
    FOR(x,2,n){
        if (!a[x]) continue;
        p.push_back(x);
        for (int y = 2 * x; y <= n; y += x) a[y] = 0;
    }
    return p;
}

int main() {
    int n;
    cin >> n;
    VL a(n);
    REP(i,n) a[i] = in();
    VL ps = primes(5e4);
    set<ll> st;
    REP(i,n){
        ll x = a[i];
        for (ll p : ps){
            if (x % p == 0){
                st.insert(p);
                while (x % p == 0) x /= p;
            }
        }
        if (x > 1) st.insert(x);
    }
    ll ans = 0;
    for (ll p : st){
        ll sum = 0;
        REP(i,n) if (a[i] % p == 0) sum += a[i];
        chmax(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    for (int i = 0; i < n; i++)
        if (s[i] != s[k - 1])s[i] = '*';

    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[200011];
int dp[200011][4];

void MAIN() {
    scanf("%s", S+1);
    S[0] = '$';
    N = strlen(S);
    memset(dp, 0xc0, sizeof dp);
    dp[1][1] = 0;
    for (int i=1; i<N; i++) {
	for (int a=1; a<=3; a++) if (a<=i && dp[i][a] >= 0) {
	    for (int b=1; b<=3; b++) if (i+b <= N) {
		bool ok = false;
		if (a == b) {
		    REP (k, a) if (S[i-a+k] != S[i+k]) ok = true;
		} else {
		    ok = true;
		}
		if (ok) {
		    amax(dp[i+b][b], dp[i][a]+1);
		}
	    }
	}
    }

    int ans = *max_element(dp[N], dp[N]+4);
    printf("%d\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//
int main(){
    string s;cin>>s;
    int ans;
    if(s=="RRR")ans=3;
    else if(s=="RRS")ans=2;
    else if(s=="RSR")ans=1;
    else if(s=="RSS")ans=1;
    else if(s=="SRR")ans=2;
    else if(s=="SRS")ans=1;
    else if(s=="SSR")ans=1;
    else if(s=="SSS")ans=0;
    cout<<ans<<endl;
}


Measured memory_bytes: 3620
#[test]
fn test_solve() {
    assert_eq!(solve("5 2 4\n"), "1\n");
    assert_eq!(solve("5 2 3\n"), "2\n");
    assert_eq!(solve("5 3 4\n"), "2\n");
    assert_eq!(solve("2 1 2\n"), "1\n");
    assert_eq!(solve("100 1 100\n"), "50\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: u64 = sc.read();
    let a: u64 = sc.read();
    let b: u64 = sc.read();

    assert!(a < b);

    format!(
        "{}\n",
        if a & 1 == b & 1 {
            (b-a) / 2
        } else {
            *[b-1, n-a, a+(b-a)/2, n-b+1+(b-a-1)/2].iter().min().unwrap()
        }
    )
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.get().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

bool check(string tmp) {
    // cout << tmp << endl;
    if(tmp.length() % 2 == 1) {
        cout << "nope" << endl;
        return false;
    } else {
        int len = tmp.length();
        string before = tmp.substr(0, len / 2);
        string after = tmp.substr(len / 2);
        // cout << before << ":" << after << endl;
        return before == after;
    }
}
int main() {
    string s;
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) { cin >> a[i]; }
    int cnt = 0;
    int res = 1;
    while(res != 2) {
        res = a[res - 1];
        cnt++;
        if(cnt > N + 1) {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::vector<int> b(N);
  std::vector<int> ans;
  range(i, N) std::cin >> b[i];
  int flag;
  while(!b.empty()){
    flag = 1;
    for(int i=b.size()-1;i>=0;i--){
      if(b[i]==i+1) {
        ans.push_back(b[i]);
        b.erase(b.begin() + i );
        flag = 0;
        break;
      }
    }
    if(flag == 1){
      std::cout << -1 << '\n';
      return 0;
    }
  }
  reverse(ans.begin(), ans.end());
  range(i, ans.size()) std::cout << ans[i] << '\n';
  return 0;
}


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

long long n, m, ac = 0, pen = 0;
vector<long long> cnt;
vector<bool> ch;

int main() {
  cin >> n >> m;
  ch.assign(n, 0);
  cnt.assign(n, 0);
  for(int i = 0; i < m; ++i) {
    string s;
    int p;
    cin >> p >> s;
    --p;
    if(s == "AC") {
      if(ch[p]) continue;
      ch[p] = 1;
      ++ac;
      pen += cnt[p];
      cnt[p] = 0;
    }
    else
      ++cnt[p];
  }

  cout << ac << " " << pen << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int x,a,b,n=1;
	cin>>x;
	for(a=-100;a<=1000;a++){
		for(b=-100;b<=1000;b++){	
			while(a*a*a*a*a-b*b*b*b*b==x){
				cout<<a<<" "<<b;
				return 0;
		
		
			}
		}
	}

			

}



Measured memory_bytes: 3612
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int N;
    cin >> N;
    vector<int> A, _A;
    int in;
    rep(_, N) {
        cin >> in;
        A.push_back(in);
        _A.push_back(in);
    }

    sort(all(A), greater<int>());

    rep(i, N) {
        if (_A[i] != A[0]) prints(A[0]);
        else prints(A[1]);
    }

    return 0;
}



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

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

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<pi>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int n;
ll cst[1 << 16];
ll A[16][16];
ll dp[1 << 16];

int main(){
    cin >> n;
    rep(i, n) rep(j, n) cin >> A[i][j];
    rep(msk, 1 << n) rep(i, n) REP(j, i + 1, n) if ((msk >> i & 1) && (msk >> j & 1)){
        cst[msk] += A[i][j];
    }

    rep(msk, 1 << n) {
        for (int msk2 = msk; msk2 > 0; msk2 = (msk2 - 1) & msk) {
            dp[msk] = max(dp[msk], dp[msk - msk2] + cst[msk2]);
        }
    }
    co(dp[(1 << n) - 1]);
}


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

int gcd(int a, int b){
    if(a < b) swap(a,b);
    if(b == 0) return a;
    return gcd(b,a % b);
}

int main() {
    int N,X;
    cin >> N >> X;
    int ans;
    cin >> ans;
    ans = abs(X-ans);
    for(int i=1; i < N; ++i) {
        int x;
        cin >> x;
        ans = gcd(ans, abs(X - x));
    }
    cout << ans << endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;
vector<pll> xyav[101010];
ll c[20],P3[20];
ll i,j,k,ans;
ll bdp[1<<16];



int main(){
    scanf("%lld",&N);
    fornum(i,1,N){
        ll x,y,a;
        scanf("%lld%lld%lld", &x, &y, &a);
        xyav[x].push_back({y, a});
        xyav[y].push_back({x, a});
    }
    fornum(i,0,N){
        ll b=0;
        fornum(j,0,xyav[i].size()){
            b ^= xyav[i][j].second;
        }
        //printf("%lld-%lld\n", i, b);
        c[b]++;
    }
    j = 0;
    k = 99;
    P3[0] = 1;
    ans = 1;
    fornum(i,1,16){
        //printf("%lld,%lld\n", i, c[i]);
        ans += c[i] / 2;
        c[i] %= 2;
        if(c[i]){
            j += 1<<i;
            //k = min(k, i);
        }
        //P3[i] = P3[i - 1] * 3;
    }
    bdp[j] = ans;
    queue<ll> q;
    q.push(j);
    while(q.size()){
        ll qa = q.front();
        q.pop();
        //cout << bitset<6>(qa) << " "<<bdp[qa]<<" "<<q.size()<< endl;
        if(qa==0){
            break;
        }
        fornum(i,1,16){
            if(qa&(1<<i)){
                break;
            }
        }
        ll nxt = qa ^ (1 << i);
        fornum(j,i+1,16){
            if(qa&(1<<j)){
                
                ll b = i ^ j;
                ll nxtt = nxt ^ (1 << j) ^ (1 << b);
                if(nxtt&(1<<b)){
                    ll a = bdp[qa] + 1;
                    if(bdp[nxtt]==0){
                        bdp[nxtt] = a;
                        q.push(nxtt);
                    }else{
                        bdp[nxtt] = min(bdp[nxtt], a);
                    }
                }else{
                    ll a = bdp[qa] + 2;
                    if(bdp[nxtt]==0){
                        bdp[nxtt] = a;
                        q.push(nxtt);
                    }else{
                        bdp[nxtt] = min(bdp[nxtt], a);
                    }
                }
                //printf(" %lld %lld\n", j, bdp[nxtt]);
            }
        }
    }
    printf("%lld", bdp[0] - 1);
    return 0;
}

Measured memory_bytes: 8064
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    ll dp[100001];

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,m,i,j,x;
            cin>>n>>m;

            for(i=1;i<=m;++i)
            {
                cin>>x;
                dp[x]=-1;
            }
            if(dp[0]!=-1)
                dp[0]=1;
            else
                dp[0]=0;

            if(dp[1]!=-1)
                dp[1]=1;
            else
                dp[1]=0;
            for(i=2;i<=n;++i)
            {
                if(dp[i]==-1)
                {
                    dp[i]=0;
                    continue;
                }
                dp[i]=(dp[i-1]+dp[i-2])%mod;
            }
            cout<<dp[n]<<endl;
        }
        return 0;
    }


Measured memory_bytes: 1024
N,Y = map(int,input().split())
ans = "-1 -1 -1"
 
for i in range(N+1):
  for j in range(N+1-i):
    if Y == 10000*i + 5000*j + 1000*(N - i - j):
      print(str(i)+" "+str(j)+" "+str(N-i-j))
      exit()
print(ans)

Measured memory_bytes: 3060
import java.util.*;
import java.awt.*;

class Main {

    private static Scanner sc = new Scanner(System.in);
    //ソート系
    /*
    *ソート(配列) Arrays.sort(配列名);
    *ソート(リスト)Collections.sort(foo);
    *逆順ソート(配列) Arrays.sort(配列名,  Collections.reverseOrder());
    *逆順ソート(リスト) Collections.reverse(リスト名);
    */

    //変換系
    /*
    *String to int : Integer.parseInt();
    *
    */

    public static void main(String[] args) {
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());


        int ans = (n*a < b) ? n*a : b;
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ll long long
#define endl "\n"
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define hell 1000000007
#define ff first
#define ss second
#define pii pair<ll,ll>
#define upd upper_bound
#define lbd lower_bound
#define vi vector<ll>
#define vii vector<pii>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)

using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define N 200005

ll i=0,j=0;

ll powr(ll a,ll b)
{
    ll i=0;
    ll ans=1;
    for(i=1;i<=b;i++)
    {
        ans*=a;
    }
    return ans;
}

int main()
{
    IOS;
    // program to find the longest common subsequence of 2 strings;
    string s,t;
    cin>>s>>t;
    ll m=s.size();
    ll n=t.size();
    ll dp[m+1][n+1];
    memset(dp,0,sizeof(dp));
    for(i=1;i<=m;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else if(dp[i][j-1]>dp[i-1][j])
                dp[i][j]=dp[i][j-1];
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    ll i=m;
    ll j=n;
    string ans="";
    while(i>=1 and j>=1)
    {
        if(s[i-1]==t[j-1])
        {
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i][j-1]>dp[i-1][j])
        {
            j--;
        }
        else
        {
            i--;
        }
    }
    reverse(all(ans));
    cout<<ans<<endl;
}



Measured memory_bytes: 70656
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector <int> pre,in,post;
int pos=0;
void rec(int l,int r){
    if (l>=r)
        return;
    int root=pre[pos++];
    int mid=distance(in.begin(),find(in.begin(),in.end(),root));
    rec(l,mid);
    rec(mid+1,r);
    post.push_back(root);
}
int main(){
    int n;
    cin>>n;
    int temp;
    for(int i=0;i<n;i++){
        cin>>temp;
        pre.push_back(temp);
    }
    for(int i=0;i<n;i++){
        cin>>temp;
        in.push_back(temp);
    }
    rec(0,n);
    for(int i=0;i<n-1;i++)
        cout<<post[i]<<" ";
    cout<<post[n-1]<<endl;
    return 0;
}



Measured memory_bytes: 3148
array = []
i = 0

while true
 array[i] = gets.chomp
 if array[i] == 0.to_s
  break
 end
 i = i+1
end

i = 0

while i+1 < array.length
 puts "Case #{i+1}: #{array[i]}"
 i = i+1
end

Measured memory_bytes: 6728
a,b;double f(x){return fabs(b-sqrt(x*x+(a-x)*(a-x)));}
main(x){for(;scanf("%d%d",&a,&b),a;){
	x=2*b*b < a*a ? a/2 : (a-sqrt(2*b*b - a*a))/2;
	printf("%f\n",a<b ? b-a : fmin(f(x),f(-~x)));
}}
//x*x + a*a - 2*a*x + x*x = b*b <=> x = (2*a + sqrt(8*b*b - 4*a*a)) / 4
//??????????????????<0?????¨???

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    vector<pair<ll, ll>> p(n);
    rep(i, n)
    {
        cin >> p[i].first;
        p[i].second = i;
    }
    sort(ALL(p), greater<PII>());
    VVL dp(n + 1, VL(n + 1, -1));
    dp[0][0] = 0;
    //dp[0][1] = abs(n - p[0].second) * p[0].first;
    //dp[1][0] = abs(p[0].second) * p[0].first;
    //    cerr << dp[0][n] << endl;
    rep(i, n)
    {
        rep(j, n)
        {
            if (i + j > n)
            {
                continue;
            }
            chmax(dp[i + 1][j], dp[i][j] + llabs(p[i + j].second - i) * p[i + j].first);
            chmax(dp[i][j + 1], dp[i][j] + llabs(n - 1 - j - p[i + j].second) * p[i + j].first);
        }
    }
    ll ans = 0;
    rep(i, n + 1)
    {
        chmax(ans, dp[i][n - i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34624
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
int a[2][3];
ll dp[25000010];

ll Solve(int N, int u, int v)
{
    rep(i, 0, N + 1) dp[i] = i;
    rep(i, 0, N + 1)
    {
        rep(j, 0, 3)
        {
            if (a[u][j] < a[v][j] && i >= a[u][j])
            {
                chmax(dp[i], dp[i - a[u][j]] + a[v][j]);
            }
        }
    }
    return dp[N];
}

void _main()
{
    int N;
    cin >> N;
    rep(i, 0, 2) rep(j, 0, 3) cin >> a[i][j];
    cout << Solve(Solve(N, 0, 1), 1, 0) << endl;
}


Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
#define ioS            ios::sync_with_stdio(false);cin.tie(0);
#define li             long int
#define ll            long li
#define ull            unsigned ll
#define pi             pair<int,int>
#define vi             vector<int>
#define vli            vector<li>
#define vll           vector<ll>
#define vvi            vector<vector<int>>
#define pb             push_back
#define mp             make_pair
#define forn(i,s,n)    for(auto i=s;i<n;++i)               
#define forr(i,s,n)    for(auto i=s;i>=n;--i) 

void solve() 
{
    int n,k;
    cin>>n>>k;
    vli a(n),g(n);
    forn(i,0,n) cin>>a[i];
    forn(i,k,n)
    {
        if(a[i] <= a[i-k])
            cout<<"No"<<endl;
        else 
            cout<<"Yes"<<endl;
    }
}
int main() {
    int t;
    // cin>>t;
    // while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 6424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
   
public class Main {
	public static final double PI = 3.1415926;
	
    public static void main( String args[] ) throws IOException {
		BufferedReader bufRed	= new BufferedReader( new InputStreamReader( System.in ) );
        String[] dat			= bufRed.readLine().split( " " );
        int a, b, C;
		a = Integer.parseInt(dat[0]);
        b = Integer.parseInt(dat[1]);
        C = Integer.parseInt(dat[2]);
		
		final double radianC	= C * PI / 180.0;
		final double ab				= a * b;
          
        final double sinC = Math.sin( radianC );
        final double cosC = Math.cos( radianC );
          
          
        // S
        double S = ab * sinC / 2;
          
        // L
        double L = a + b + Math.sqrt( a * a + b * b - 2 * ab * cosC );
          
        // h
        double h = b * sinC;
          
        System.out.print(S + "\n" + L + "\n" + h + "\n");
          
    }
      
}

Measured memory_bytes: 16920
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

C = [0] * N

for i in range(N):
    x = min(A[i], B[i])
    y = min(A[i + 1], max(B[i] - A[i], 0))
    C[i] = x + y
    A[i] = A[i] - x
    A[i + 1] = A[i + 1] - y

print(sum(C))

Measured memory_bytes: 25292
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define F first
#define S second
void solve(){
    string a,b;
    cin>>a>>b;
    int ans=0;
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i]){
            ans++;
        }
    }
    cout<<ans<<"\n";
}
int main() {
	int t=1;
	//cin>>t;
	while(t--){
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3832
from collections import deque
def DFS(graph,start,end):
    #  深さ優先探索ではスタックを用いたが幅優先探索ではキューを用いる
    c,r = len(graph[0]),len(graph)
    que = deque([])
    que.append(start)
    visited = [[0 for _ in range(c)] for _ in range(r)]

    while visited[end[0]][end[1]]==0:
        if len(que)== 0:
            break
        now = que.popleft()
        y,x = now
        up,down,left,right = [y-1,x],[y+1,x],[y,x-1],[y,x+1]

        #up
        if visited[up[0]][up[1]]==0:
            if graph[up[0]][up[1]]==".":
                que.append(up)
                visited[up[0]][up[1]]= visited[y][x]+1
            
        #down
        if visited[down[0]][down[1]]==0:
            if graph[down[0]][down[1]]==".":
                que.append(down)
                visited[down[0]][down[1]]= visited[y][x]+1
        #left
        if visited[left[0]][left[1]]==0:
            if graph[left[0]][left[1]]==".":
                que.append(left)
                visited[left[0]][left[1]]= visited[y][x]+1
        #right
        if visited[right[0]][right[1]]==0:
            if graph[right[0]][right[1]]==".":
                que.append(right)
                visited[right[0]][right[1]]= visited[y][x]+1
    
    return visited[end[0]][end[1]]

def main():
    h,w = map(int,input().split())
    ls = [list(input()) for _ in range(h)]
    cnt = 0
    for i in range(h):
        for j in range(w):
            if ls[i][j]=="#":
                cnt += 1

    dummy = ["#" for _ in range(w+2)]
    for i in range(h):
        ls[i].append("#")
        ls[i].insert(0,"#")
    ls.insert(0,dummy)
    ls.append(dummy)

    step = DFS(ls,[1,1],[h,w])+1

    if step == 1:
        print(-1)
    else:
        print(h*w-step-cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 40432
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

ll dp[3007][6007];

int main(){
    ll N,T;
    pair<ll,ll> A[3007];
    cin >> N >> T;
    rep(i,N){
        cin >> A[i].fr >> A[i].sc;
    }
    sort(A,A+N);
    rep(i,N){
        rep(j,6006){
            if(j<T){
                dp[i+1][j+A[i].fr]=max(dp[i][j]+A[i].sc,dp[i][j+A[i].fr]);
            }
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        }
    }
    ll M=0;
    rep(i,6005){
        M=max(M,dp[N][i]);
    }
    cout << M << endl;
}

Measured memory_bytes: 141056
#include <stdio.h>

int main(void){

  int N ;
  scanf("%d",&N);
  int A[N],i;
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  int j;
  for(j=0;j<N;j++){
    if(A[j]%2==0){
      if(A[j]%3!=0&&A[j]%5!=0){
	break;
      }
    }
  }

  if(j==N){
    printf("APPROVED");
  }else{
    printf("DENIED");
  }
    
  

  return 0;
}


Measured memory_bytes: 128
N = input()
for i in range(10):
    if int(N[0]) == i:
        if int(N[1]) > i:
            ans = str(i+1)
        if int(N[1]) == i:
            if int(N[2]) > i:
                ans = str(i+1)
            else:
                ans = str(i)
        if int(N[1]) < i:
            ans = str(i)
print(int(ans+ans+ans))

Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func abs(x int) int {
	if x < 0 {
		return -1 * x
	} else {
		return x
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(nil, 10000000000)

	_, _, m := nextInt(), nextInt(), nextInt()

	hs := make([]int, m)
	ws := make([]int, m)

	hsum := make(map[int]int)
	wsum := make(map[int]int)

	bomb := make(map[int]map[int]bool)

	for i := 0; i < m; i++ {
		hs[i], ws[i] = nextInt()-1, nextInt()-1

		if _, ok := bomb[hs[i]]; ok {
			bomb[hs[i]][ws[i]] = true
		} else {
			bomb[hs[i]] = make(map[int]bool)
			bomb[hs[i]][ws[i]] = true
		}

		hsum[hs[i]] += 1
		wsum[ws[i]] += 1

	}

	var hmax int
	var wmax int
	for _, v := range hsum {
		if hmax < v {
			hmax = v
		}
	}
	for _, v := range wsum {
		if wmax < v {
			wmax = v
		}
	}

	checkh := []int{}
	checkw := []int{}

	for k, v := range hsum {
		if v == hmax {
			checkh = append(checkh, k)
		}
	}

	for k, v := range wsum {
		if v == wmax {
			checkw = append(checkw, k)
		}
	}

	ans := hmax + wmax - 1
	for _, ch := range checkh {
		if _, ok := bomb[ch]; !ok {
			continue
		}
		for _, cw := range checkw {
			if _, ok := bomb[ch][cw]; !ok {
				ans = hmax + wmax
				fmt.Println(ans)
				return
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 130380
unittest
{
	assert( [ "0 4" ].parse.expand.solve == 0 );		// 追加ケース
	assert( [ "1 4" ].parse.expand.solve == 1 );		// 追加ケース
	assert( [ "2 4" ].parse.expand.solve == 2 );		// 追加ケース
	assert( [ "3 4" ].parse.expand.solve == 1 );		// 追加ケース
	assert( [ "4 4" ].parse.expand.solve == 0 );		// 追加ケース
	assert( [ "5 4" ].parse.expand.solve == 1 );		// 追加ケース
	assert( [ "6 4" ].parse.expand.solve == 2 );		// 追加ケース
	assert( [ "30 4" ].parse.expand.solve == 2 );		// 追加ケース
	
	assert( [ "7 4" ].parse.expand.solve == 1 );
	assert( [ "2 6" ].parse.expand.solve == 2 );
	assert( [ "1000000000000000000 1" ].parse.expand.solve == 0 );
}



import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	if( k <= n ) n = ( n - k ) % k;
	while( true )
	{
		auto d = abs( n - k );
		if( n <= d ) break;
		n = d;
	}
	return n;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
if a%2!=0 or b%2!=0 or c%2!=0:
    print(0)
elif a==b==c:
    print(-1)
else:
    total=0
    while True:
        x=a/2
        y=b/2
        z=c/2
        a=y+z
        b=x+z
        c=x+y
        total+=1
        if a%2!=0 or b%2!=0 or c%2!=0:
            print(total)
            break

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

using namespace std;

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

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

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

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a,b,c,d;

int main(){
    cin >> a >> b >> c >> d;
    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d))cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int A = 0, B = 0, C = 0;
  for (int i = 0; i < n; i ++) {
    int tmp;
    cin >> tmp;
    if (tmp <= a) A ++;
    else if (tmp <= b) B ++;
    else C ++;
  }

  int ans = min(A, min(B, C));

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=5e3+100,M=210;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int st[M][N],w[M][N],top[M];
LL dis[N],tag[N*4],mx[N*4];
#define lc (i<<1)
#define rc (lc|1)
inline void add(int i,LL t) { tag[i]+=t,mx[i]+=t; }
inline void modify(int i,int l,int r,int k,LL t) {
	if (l==r) mx[i]=t;
	else {
		int mid=(l+r)>>1;
		k<=mid?modify(lc,l,mid,k,t):modify(rc,mid+1,r,k,t);
		mx[i]=max(mx[lc],mx[rc]);
	}
}
inline void pushdown(int i) {
	if (tag[i]) {
		add(lc,tag[i]);
		add(rc,tag[i]);
		tag[i]=0;
	}
}
inline void add(int i,int l,int r,int L,int R,int t) {
	if (L<=l&&r<=R) add(i,t);
	else {
		int mid=(l+r)>>1;
		pushdown(i);
		if (L<=mid) add(lc,l,mid,L,R,t);
		if (mid<R) add(rc,mid+1,r,L,R,t);
		mx[i]=max(mx[lc],mx[rc]);
	}
}
int main()
{
	int n=gi(),m=gi(),i,j;LL ans=0,s;
	for (i=2;i<=n;i++) dis[i]=dis[i-1]+gi();
	for (i=1;i<=n;i++) {
		s=0;
		for (j=1;j<=m;j++) {
			s+=w[j][i]=gi();
			while (top[j]&&w[j][i]>w[j][st[j][top[j]]])
				add(1,1,n,st[j][top[j]-1]+1,st[j][top[j]],w[j][i]-w[j][st[j][top[j]]]),top[j]--;
			st[j][++top[j]]=i;
		}
		modify(1,1,n,i,s+dis[i]);
		ans=max(ans,mx[1]-dis[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8448
i = input().split(' ')
W = int(i[0])
H = int(i[1])
x = int(i[2])
y = int(i[3])
r = int(i[4])

if x - r >= 0 and y - r >= 0 and x + r <= W and y + r <= H:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6724
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int sosu[66666];
main(){
  for(int i=2;i<=60000;i++){
    if(sosu[i]==1) continue;
    for(int j=i*2;j<=60000;j+=i){
      sosu[j]=1;
    }
  }
  
  int N;
  while(~scanf("%d",&N))
    {
      int i=N-1;
      while(sosu[i]) i--;
      printf("%d ",i);
      i=N+1;
      while(sosu[i]) i++;
      printf("%d\n",i);
    }
}

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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int out = 1;
    char pre = s[0];

    for (int i = 1; i < n; i++) {
        if (pre == s[i]) continue;
        pre = s[i];
        out++;
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 512
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];
        int[] b = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextInt();
        for (int i = 0; i < n; i++) b[i] = sc.nextInt();
        for (int i = 0; i < n; i++) c[i] = sc.nextInt();
        long ans = 0L;
        Arrays.sort(a);
        Arrays.sort(c);
        for (int i = 0; i < n; i++) {
            int ok1 = -1;
            int ng1 = n;
            while(1 < ng1 - ok1){
                int m = (ok1+ng1)/2;
                if(a[m] < b[i]) ok1 = m;
                else ng1 = m;
            }
            int ok2 = n;
            int ng2 = -1;
            while(1 < ok2-ng2){
                int m = (ok2+ng2)/2;
                if(b[i] < c[m]) ok2 = m;
                else ng2 = m;
            }
            ans += (long)ng1 * (n-ok2);
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 93656
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
tmp = -1
for i in A:
  ans += B[i - 1]
  if i - 1 == tmp:
    ans += C[tmp - 1]
  tmp = i
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
 
typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
 
#define ALL(a) (a).begin(),a.end()
#define MAXE(a) *max_element(ALL(a))
#define MINE(a) *min_element(ALL(a))

int main(){
  int N; 
  cin >> N;
  int p = 0;
  if(N<1000000)p =  9 + 900 + 90000;
  if(N<100000)p =  9 + 900 + N-10000+1;
  if(N<10000)p =  9 + 900;
  if(N<1000)p =  9 + N-100+1;
  if(N<100)p =  9;
  if(N<10)p =  N;
  cout << p << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char a;
	char b;
	scanf("%c %c", &a,&b);
	if(a=='H'&&b=='H'){
		printf("H\n");
	}
	else if(a=='H'&&b=='D'||a=='D'&&b=='H'){
		printf("D\n");
	}
	else if(a=='D'&&b=='D'){
		printf("H\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long[] a = new long[n];
		long[] s = new long[n];
		long min = Long.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		
		s[0] = a[0];
		for (int i = 1; i < n; i++) {
			s[i] = s[i-1] + a[i];
		}
		
		for (int i = 0; i < n-1; i++) {
			long S = s[i];
			long A = s[n-1] - s[i];
			long dif = Math.abs(S-A);
			if (min > dif) {
				min = dif;
			}
		}
		
		System.out.println(min);
	}
}


Measured memory_bytes: 87712