akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

template <class T>
inline void read(T &x)
{
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int p[10], q[10], a[10];
int n, ap, aq, k;
bool flag1, flag2;

int main()
{
    read(n);
    for (int i = 1; i <= n; ++i)
        read(p[i]);
    for (int i = 1; i <= n; ++i)
        read(q[i]);
    for (int i = 1; i <= n; ++i)
        a[i] = i;
    do
    {
        ++k;
        flag1 = true, flag2 = true;
        for (int i = 1; i <= n; ++i)
        {
            if (a[i] != p[i])   flag1 = false;
            if (a[i] != q[i])   flag2 = false;
        }
        if (flag1) ap = k;
        if (flag2) aq = k; 
    } while (std::next_permutation(a + 1, a + n + 1));
    std::cout << abs(ap - aq) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define        fast        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define        ll          long long int
#define        End         return 0
#define        st          string
#define        sz(x)       (int)x.size()
#define        nl          '\n'
int main()
{
    fast;
    int n,i,a[102],b[102];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i]>>b[i];
    for(i=0;i<n-2;i++)
    {
        if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2])
         {
                cout<<"Yes";
                End;
         }
    }
    cout<<"No";
    End;
}



Measured memory_bytes: 3636
use std::io::Write;

macro_rules! eprintln {
    ($($args:tt)*) => { let _ = writeln!(&mut std::io::stderr(), $($args)*); }
}

fn read_line() -> Vec<String> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).expect("Failed to read line");
    line.trim().split_whitespace().map(|s| s.to_string()).collect()
}

struct Reader { v: Vec<String>, n: usize }

impl Reader {
    fn new() -> Self { Reader { v: read_line(), n: 0 } }
    fn next<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
        if self.n == self.v.len() { self.v = read_line(); self.n = 0; }
        self.n += 1;
        self.v[self.n-1].parse().expect(&self.v[self.n-1])
    }
    #[allow(dead_code)]
    fn nexts<T>(&mut self, n: usize) -> Vec<T>
    where T: std::str::FromStr, T::Err: std::fmt::Debug {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n { v.push(self.next()); }
        v
    }
}

fn dfs(cnt: usize, low: usize, high: usize, ans: &mut Vec<Vec<usize>>) {
    let med = (low + high) / 2;
    for i in low..med {
        for j in med..high {
            ans[i][j] = cnt;
            ans[j][i] = cnt;
        }
    }

    if med - low > 1 {
        dfs(cnt+1, low, med, ans);
    }
    if high - med > 1 {
        dfs(cnt+1, med, high, ans);
    }
}

fn main() {
    let mut r = Reader::new();
    let n: usize = r.next();

    let mut ans: Vec<Vec<usize>> = (0..n).map(|_| vec![0; n]).collect();

    dfs(1, 0, n, &mut ans);

    for i in 0..(n-1) {
        for j in (i+1)..n {
            if j == n-1 {
                println!("{}", ans[i][j]);
            } else {
                print!("{} ", ans[i][j]);
            }
        }
    }
}


Measured memory_bytes: 6652
//In the name of ALLAH the most merciful the most beneficial

#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e9;
static const int INF = 0x3f3f3f3f;
static const int MOD = 998244353;

int main(){

    string s;
    cin >> s;
    string s1;
    cin >> s1;
    set<char> se(s1.begin(),s1.end());
    set<char> se1(s.begin(),s.end());
    if(sz(se1) != sz(se)){
        cout << "No";
        return 0;
    }
    map<char,char> mp;

    FOR(i,0,s1.size()){

        if(mp.find(s1[i]) == mp.end())
            mp[s1[i]] = s[i];
        else{

            if(mp[s1[i]] != s[i]){
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}



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

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

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  l=[inf]*100001
  l[0]=0

  l2=[1]
  for i in range(1,10):
    a=pow(6,i)
    b=pow(9,i)
    if a<=100000:
      l2.append(a)
    if b<=100000:
      l2.append(b)
  l2.sort()

  n=I()

  for i in range(1,n+1):
    for x in l2:
      if i-x>=0:
        l[i]=min(l[i],l[i-x]+1)

  return l[n]

print(main())


Measured memory_bytes: 7072
n = int(input())
*x, = map(int, input().split())
y = sorted(x)
p, q = y[n//2-1:n//2+1]
ans = []
for i in range(n):
    if x[i] < q:
        ans.append(q)
    else:
        ans.append(p)
print(*ans, sep='\n')



Measured memory_bytes: 26772
#include<stdio.h>

int main()
{
	int n;
	scanf("%d", &n);

	for (int i = 0; i * 4 <= n; i++)
	{
		if (!((n - i * 4) % 7))
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int count = 0;
    for (int i = 1; i <= N; i++)
    {
        string S = to_string(i);
        if(S.length() % 2 == 1) count++;
    }
    
    cout << count << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;
#define INF 1<<21
#define DIV 1000000007

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

int main() {
  int n,a;
  int cnt=0;
  cin >> n;
  for (int i = 0; i < n; i++) {
	cin >> a;
	if (a % 2 == 1)cnt++;
  }

  if (cnt % 2 == 1) {
	cout << "NO" << endl;
  } else {
	cout << "YES" << endl;
  }

}

Measured memory_bytes: 256
//
// main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

 
struct Mod {
	static uint64_t PRIME;
	struct LocalPrime {
		uint64_t backup;
		LocalPrime(uint64_t prime) { backup = exchange(Mod::PRIME, prime); }
		~LocalPrime() { Mod::PRIME = backup; }
	};
	uint64_t value = 0;
	Mod()
	: value(0) {}
	Mod(ll v) {
		if (v >= 0) {
			value = v % PRIME;
		} else {
			value = PRIME - (-v) % PRIME;
		}
	}
	Mod operator+(const Mod& rhs) const { return Mod(*this) += rhs; }
	Mod& operator+=(const Mod& rhs) {
		value += rhs.value;
		if (value >= PRIME) {
			value -= PRIME;
		}
		return *this;
	}
	Mod operator-(const Mod& rhs) const { return Mod(*this) -= rhs; }
	Mod& operator-=(const Mod& rhs) {
		if (value < rhs.value) {
			value += PRIME;
		}
		value -= rhs.value;
		return *this;
	}
	Mod operator*(const Mod& rhs) const { return Mod(*this) *= rhs; }
	Mod& operator*=(const Mod& rhs) {
		value = (value * rhs.value) % PRIME;
		return *this;
	}
	Mod inv() const { return power(*this, PRIME - 2); }
	Mod operator/(const Mod& rhs) const { return Mod(*this) /= rhs; }
	Mod& operator/=(const Mod& rhs) {
		*this *= rhs.inv();
		return *this;
	}
	static Mod power(Mod rhs, ll exp) {
		Mod ans = 1;
		while (exp > 0) {
			if (exp % 2) {
				ans *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return ans;
	}
};
uint64_t Mod::PRIME = 998244353;

int main() {
	ll N, S;
	cin >> N >> S;
	vector<ll> As(N);
	rep(i,0,N) {
		cin >> As[i];
	}
	auto dp = make_vec_nd((Mod)0, N+1, S+1);
	rep(i,0,N+1) {
		dp[i][0] = i+1;
	}
	rep(i,1,N+1) {
		rep(s,1,S+1) {
			dp[i][s] += dp[i-1][s];
			if (s >= As[i-1]) {
				dp[i][s] += dp[i-1][s-As[i-1]];
			}
		}
	}
	Mod ans = 0;
	rep(r,0,N) {
		ans += dp[r+1][S];
	}
	cout << ans.value << endl;
}



Measured memory_bytes: 70784
import numpy as np

N, M, X = map(int, input().split())

ca = []
for _ in range(N):
  ca.append( list(map(int, input().split())))
ca.sort(key=lambda x:-x[0])
ca = np.array(ca)
#
ans = 10000000
skill = [0]*(M+1)


def DFS(n,skill):
  global ans
  if skill[0] >= ans:
    return
  if min(skill[1:]) >= X:
    ans = min(ans, skill[0])
  if n >= N:
    return
  s = skill.copy()
  DFS(n+1,s)
  s = s + ca[n]
  DFS(n+1,s)
  return
#

DFS(0,skill)
if ans == 10000000:
  print(-1)
else:
  print(ans)
#

Measured memory_bytes: 27244
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n,maxw;
	cin>>n>>maxw;
	ll dp[n+1][(int)1e5+1];
	for(int i=0;i<=n;i++)
		for(int j=0;j<=1e5;j++)
			if(j==0)
				dp[i][j]=0;
			else
				dp[i][j]=1e12;
	for(int i=1;i<=n;i++){
		int ww,vv;
		cin>>ww>>vv;
		if(i==1){
			dp[i][vv]=ww;
			continue;
		}
		for(int j=0;j<=1e5;j++){
			if(j>=vv)
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-vv]+ww);
			else
			dp[i][j]=dp[i-1][j];	
		}
	}
	for(int i=1e5;i>=0;i--)
	if(dp[n][i]<=maxw){
		cout<<i;
		return 0;
	}	
}


Measured memory_bytes: 82484
#include <stdio.h>
#include <stdlib.h>
int asort(const void *A,const void *B){return *(int*)A>*(int*)B?1:0;}
int main(void){
    int n[4];
    scanf("%d%d%d%d",&n[0],&n[1],&n[2],&n[3]);
    qsort (n,4,sizeof(int),asort);
    if (n[0]==1 && n[1]==4 && n[2]==7 && n[3]==9){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> d(n);
  REP(i, n) cin >> d[i];

  ll ans = 0;
  REP(i, n) REP(j, n) if (i < j) { ans += d[i] * d[j]; }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a,b,n;
int main()
{
    cin>>a>>b>>n;
	ll x;
	ll ans;
	if(n<b)
	{
		ans=(a*n)/b-a*(n/b);
		cout<<ans;
		return 0;
	}
	else if(n==b)
	{
		x=n-1;
		ans=(a*n)/b-a*(n/b);
		ll ans1=(a*x)/b-a*(x/b);
		ans=max(ans,ans1);
		cout<<ans;
	}
	else
	{
		ll maxn=(a*n)/b-a*(n/b);
		ll tmp;
		ll num=n/b;
		ll mod=1e7;
		if(num>mod)
		{
			for(ll i=1;i<=mod;i++)
			{
				ll mul=i*b-1;
				tmp=(a*mul)/b-a*(mul/b);
			     maxn=max(maxn,tmp);
			}
		}
		else
		{
		  for(ll i=num;i>=1;i--)
		  {
			ll mul=i*b-1;
			tmp=(a*mul)/b-a*(mul/b);
			maxn=max(maxn,tmp);
		 }
	    }  
		ans=maxn;
		cout<<ans;
	}
	return 0;
 } 

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

        signed main() {
            int n;
            cin>>n;
            int a[n];
            for(int i=0;i<n;i++)cin>>a[i];
            sort(a,a+n);
            int ans=a[0];
            for(int i=1;i<n-1;i++){
                if(abs(a[n-1]-2*ans)>abs(a[n-1]-2*a[i]))ans=a[i];
            }
            cout<<a[n-1]<<' '<<ans;

         return 0;

        }


Measured memory_bytes: 1024
const MAX: i64 = 1e9 as i64;
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let k: usize = sc.read();
    let s: i64 = sc.read();

    let mut ans = vec![];
    for i in 0..n {
        if i < k {
            ans.push(s);
        } else if s == MAX {
            ans.push(s - 1);
        } else {
            ans.push(s + 1);
        }
    }

    for i in 0..n {
        if i > 0 {
            sc.write(" ");
        }
        sc.write(format!("{}", ans[i]));
    }
    sc.write("\n");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 5372
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007
int acs(const void* a, const void* b) { return *(int*)a - *(int*)b; } // 1,2,3,4
int des(const void* a, const void* b) { return *(int*)b - *(int*)a; } // 8,7,6,5
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
//snippet
#define N 1009

int main() {
	int n;
	scanf("%d", &n);
	if (n % 1000)printf("%d", 1000 - (n % 1000));
	else printf("0");
	
	return 0;
}

Measured memory_bytes: 1732
n=int(input())
s=input()
r=g=b=0
for ss in s:
  if ss=="R":r+=1
  elif ss=="G":g+=1
  elif ss=="B":b+=1
ans=r*g*b
for i in range(n-2):
  for j in range(i+1,n-1):
    k=j+(j-i)
    if k>=n:break
    if not(s[i]==s[j] or s[j]==s[k] or s[i]==s[k]):ans-=1
print(ans)


Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#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<long long> A(N);
  long long S = 0;
  rep(i, N) {
    cin >> A[i];
    S += A[i];
  }

  long long minx = S, sum = 0;
  for(int i = 0; i < N; i++) {
    sum += A[i];
    minx = min(minx, abs(sum - (S-sum)));
  }
  cout << minx << endl;

  return 0;
}


Measured memory_bytes: 1792
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int iInput = int.Parse(Console.ReadLine());

            int i100 = iInput / 100;
            int i10 = iInput % 100;

            if((i100*10+ i100) >= i10)
            {
                Console.WriteLine(i100*100 + i100 * 10 + i100);
            }
            else
            {
                i100++;
                Console.WriteLine(i100 * 100 + i100 * 10 + i100);
            }

        }
    }
}

Measured memory_bytes: 13140
N, M = map(int, input().split())
all_dish = []

for n in range(N):
    K_n_list = list(map(int, input().split()))
    del K_n_list[0]
#    all_dish = [K_n_list_num for K_n_list_num in K_n_list]

    for K_n_list_num in K_n_list:
        all_dish.append(K_n_list_num)

prefer_dish = []
dish_kind = list(set(all_dish))
#prefer_dish = [dish_kind_num for dish_kind_num in dish_kind if all_dish.count(dish_kind_num) == N]
for dish_kind_num in dish_kind:
    if all_dish.count(dish_kind_num) == N:
        prefer_dish.append(dish_kind_num)

print(len(prefer_dish))

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

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

            List<int> Nums = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>();

            List<int> aft = new List<int>();

            for (int i = 0; i < Nums.Count(); i++)
            {
                aft.Add(Nums[i]);
            }

            aft.Sort();

            int cnt = 0;

            for (int i = 0; i < Nums.Count(); i++)
            {
                if (Nums[i] != aft[i])
                {
                    cnt++;
                }

                if (3 <= cnt)
                {
                    Console.WriteLine("NO");

                    return;
                }
            }

            Console.WriteLine("YES");

        }
    }
}


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

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

    if(D == 25) cout << "Christmas" << endl;
    else if(D == 24) cout << "Christmas Eve" << endl;
    else if(D == 23) cout << "Christmas Eve Eve" << endl;
    else if(D == 22) cout << "Christmas Eve Eve Eve" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>
#include <unistd.h>

using namespace std;

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

long long int INF = 1e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q;
//ll x[300005],y[300005],z[100005];
ll table[500005];
ll res1,res2;
ll x1,x2,x3,y11,y2,y3;
char s[500005];

int main(){
	cin >> n;
    ll check = (ll)sqrt(n);
    for(ll i=max(check-5,0ll);i<=check + 5;i++){
        if(i * i >= n){
            x1 = i;
            y2 = i;
            x2 = 1;
            y11 = i * i - n;
            x3 = 0;
            y3 = 0;
            bool flag = false;
            while(y11 > 1000000000){
                if(!flag){
                    x1--;
                    y11 -= y2;
                    flag = true;
                }else{
                    y2--;
                    y11 -= x1;
                    flag = false;
                }
            }
            break;
        }
    }
    pe(x1);pe(y11);pe(x2);pe(y2);pe(x3);p(y3);


	return 0;
}



Measured memory_bytes: 12288
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    X, Y, Z = map(int, input().split())
    ans = 0
    ans += X // (Y + Z)
    if X % (Y + Z) < Z:
        ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3960
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <iomanip>
  
using namespace std;

#define pi 3.141592653589793

int main()
{
	int result[32769][5] = {};
	for(int i = 0; i * i < 32769; i++){
		result[i * i][1]++;
		for(int j = i * i + 1; j < min(i * i * 4 + 1, 32769); j++){
			for(int k = 2; k < 5; k++){
				result[j][k] += result[j - i * i][k - 1];
			}
		}
	}
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int ans = 0;
		for(int i = 1; i < 5; i++){
			ans += result[n][i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1808
n = gets.to_i

f = 0
n.times do
	a, b = gets.split(' ').map{|i| i.to_i}
	if a == b
      f += 1
    else
      f = 0
    end
	if f == 3
      puts 'Yes'
      exit()
    end
end
puts 'No'

Measured memory_bytes: 14324
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v.at(i);
  }
  vector<int> w(n);
  for(int i=0;i<n;i++){
    cin >> w.at(i);
  }
  vector<int> vw(n);
  for(int i=0;i<n;i++){
    vw.at(i) = v.at(i) - w.at(i);
  }
  sort(vw.begin(),vw.end());
  reverse(vw.begin(),vw.end());
  int count = 0;
  int j = 0;
  while((j<n)&&(vw.at(j) > 0)){
    count += vw.at(j);
    j++;
  }
  cout << count << endl;
}




Measured memory_bytes: 256
A[1000][1000],I[1000],u[999];i,j;d;F=2;main(N){for(scanf("%d",&N);i<N;++i)for(j=0;j<N-1;)scanf("%d",A[j++]+i);for(;F&2;)for(F=1,i=!++d;i<N;++i)u[i]<d&&(j=A[I[i]][i]-1)>=0&&u[F&=2,j]<d&&A[I[j]][j]==i+1&&++I[u[i]=u[j]=d,++I[i],F=2,j];printf("%d",F*d-1);}

Measured memory_bytes: 4096
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque, defaultdict
from fractions import gcd
from functools import reduce
from itertools import groupby, combinations
from heapq import heapify, heappush, heappop

#sys.setrecursionlimit(30000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return list(map(lambda x: x + d, A))
def ldec(A, d=1): return list(map(lambda x: x - d, A))

N, M = nn()
T = nm(M)

for i in range(M):
    T[i][0] -= 1
    T[i][1] -= 1

dic = defaultdict(list)

m = {}
for i in range(M):
    if (T[i][0], T[i][1]) in m:
        continue
    m[(T[i][0], T[i][1])] = True
    dic[T[i][0]].append(T[i][1])
    dic[T[i][1]].append(T[i][0])

def search(n):
    ret = 1
    deq = deque()

    memo[n] = 1
    for t in dic[n]:
        if memo[t] == 0:
            memo[t] = 1
            deq.append(t)

    while len(deq) != 0:
        d = deq.pop()
        ret += 1
        for t in dic[d]:
            if memo[t] == 0:
                memo[t] = 1
                deq.append(t)

    return ret

memo = array1(N)

ans = 0
for i in range(N):
    if memo[i] == 1:
        continue

    ans = max(search(i), ans)

print(ans)

Measured memory_bytes: 186280
N=int(input())
S=input()
r=g=b=0

for s in S:
    if s=="R":
        r+=1
    elif s=="G":
        g+=1
    else:
        b+=1

ans = r*g*b

for i in range(N-2):
    for j in range(i+1,N-1):
        if 2*j-i>N-1:
            continue
        else:
            first=S[i]
            second=S[j]
            third=S[2*j-i]
            if first!=second and second!=third and first!=third:
                ans-=1
print(ans)

Measured memory_bytes: 73836
/*

Parallelism(https://onlinejudge.u-aizu.ac.jp/problems/0021)
前

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
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;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

//外積を計算する関数
double gaiseki(comp a, comp b)
{
	return (conj(a)*b).imag();
}

void solve(void){

	int N;
	cin >> N;
	while(N--)
	{

		double xs[4], ys[4];
		rep(4, i)
		{
			cin >> xs[i] >> ys[i];
		}

		vector <comp> ps(4);
		rep(4, i)
		{
			ps[i] = comp(xs[i], ys[i]);
		}

		//直線AB,CDに対応するベクトルl,m　回転用のr
		comp l = ps[1]-ps[0], m = ps[3]-ps[2], r = polar(1., PI/180);

		l *= r, m *= r;

		cout << (abs(gaiseki(l, m)) < EPS ? "YES" : "NO") << endl;

	}

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std; \
int main() {
    string str;
    cin >> str;
    int cnt = 0;
    int mx = 0;
    for (auto& x : str) {
        if (x == 'R')cnt++;
        else {
            mx = max(mx, cnt);
            cnt = 0;
        }
    }
    mx = max(mx, cnt);
    cout << mx << endl;
}

Measured memory_bytes: 3596
import Control.Monad
import Data.Char

main = do
    s <- getLine
    putStrLn $ show $ solve s

solve :: String -> Int
solve s = min (doit 0 s) (doit 1 s)
  where
    doit p []    = 0
    doit p (h:t) = (abs (digitToInt h - p)) + doit (1 - p) t

Measured memory_bytes: 8572
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

string to_string(int n)
{
	ostringstream oss;
	oss<<n;
	string res=oss.str();
	res=string(8-res.size(),'0')+res;
	return res;
}

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		int s;
		cin>>s;
		printf("Case %d:\n",i+1);
		rep(j,10){
			string t=to_string(s*s);
			s=atoi(t.substr(2,4).c_str());
			cout<<s<<endl;
		}
	}
	
	return 0;
}

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

int main(){
	string S;
	cin >> S;
	int cnt = 0;
	
	for(int i = 0; i < 4; i++){
		if(S.at(i) == '+') cnt++;
		else cnt--;
	}
	
	cout << cnt << endl;
}

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

int func_a(int A,int B) {
	int max = A > B ? A : B;

	for (int i = 0; i <= max; i++) {
		if (abs(A - i) == abs(B - i)) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

int main()
{
	int A, B;
	cin >> A >> B;
	func_a(A, B);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n, m;
  cin >> n >> m;
  vector<pii> jobs(n);
  // jobs[].ff = # days needed, jobs[].ss = reward gotten
  forx(i,n) cin >> jobs[i].ff >> jobs[i].ss;
  sort(jobs.begin(), jobs.end());
  ll ans = 0;
  int job_idx = 0;
  multiset<int, greater<int>> pick;
  for (int day = 1; day <= m; day++) {
    while(job_idx < n && (jobs[job_idx].ff == day)) {
      pick.insert(jobs[job_idx].ss);
      job_idx++;
    }
    if (pick.size()) {
      auto it = pick.begin();
      ans += *it;
      pick.erase(it);
    }
  }
  cout << ans << nl;

  return 0;
}



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

int main(){
    ios::sync_with_stdio(false);
	int table[510][510];
	memset(table,0,sizeof(table));
	int N,M,Q;
	cin>>N>>M>>Q;
	int p[Q],q[Q];
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		table[a][b]++;
	}
	for(int i=0;i<N+1;i++){
		for(int j=1;j<N+1;j++){
			table[i][j]+=table[i][j-1];
		}
	}
	for(int i=1;i<N+1;i++){
		for(int j=0;j<N+1;j++){
			table[i][j]+=table[i-1][j];
		}
	}
	for(int i=0;i<Q;i++) cin>>p[i]>>q[i];
	for(int i=0;i<Q;i++) cout<<table[q[i]][q[i]]+table[p[i]-1][p[i]-1]-table[p[i]-1][q[i]]-table[q[i]][p[i]-1]<<endl;
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#include <cxxabi.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    ((ll)1ll<60)
#define INF     ((int)1<<30)
#define EPS     (1e-9)
#define MOD     (1000000007)
template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool b=1;for(auto s:t)os<<(exchange(b,0)||strlen(abi::__cxa_demangle(typeid(S).name(),0,0,0))>20?"":" ")<<s;return os<<endl;}

using Node=tuple<int,int,int,double>; //L,R,W,X

vector<Node> node;
vvi edge;

bool isStable(int p){
	int L,R,W;
	double X;
	tie(L,R,W,X)=node[p];
	X*=W;
	bool ok=true;
	for(auto child:edge[p]){
		int l,r,w;
		double x;
		ok&=isStable(child);
		tie(l,r,w,x)=node[child];
		W+=w;
		X+=w*x;
	}
	X/=W;
	node[p]=Node(L,R,W,X);
	return ok and L<X and X<R;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int w,h;
	while(cin>>w>>h,w){
		node.clear();
		edge.clear();
		vector<string> input(h);
		vvi field(h,vi(w,-1));
		
		rep(i,h)cin>>input[i];
		rep(i,h)rep(j,w)if(input[i][j]!='.'){
		    int L=100,R=0,W=0;
		    double X=0;
		    char tgt=input[i][j];
		    queue<pii> q; q.emplace(i,j);
		    while(!q.empty()){
		        int y,x; tie(y,x)=q.front(); q.pop();
		        if(input[y][x]=='.') continue;
		        W++;
		        X+=(x+0.5);
		        input[y][x]='.';
		        field[y][x]=node.size();
		        int v[]={1,0,-1,0};
		        rep(k,4){
		            int ny=y+v[k], nx=x+v[k^1];
		            if(ny<0 or nx<0 or ny>=h or nx>=w or input[ny][nx]!=tgt) continue;
		            q.emplace(ny,nx);
		        }
		    }
		    node.emplace_back(L,R,W,X/W);
		}
		int n=node.size(),p=-1;
		edge.resize(n);
		range(i,1,h)rep(j,w){
		    if(field[i][j]!=-1 and field[i-1][j]!=-1 and field[i-1][j]!=field[i][j]){
		        edge[field[i][j]].push_back(field[i-1][j]);
				auto &d=node[field[i-1][j]];
				get<0>(d)=min(get<0>(d),j);
				get<1>(d)=max(get<1>(d),j+1);
		    }
			if(i==h-1 and field[i][j]!=-1){
				p=field[i][j];
				get<0>(node[p])=min(get<0>(node[p]),j);
				get<1>(node[p])=max(get<1>(node[p]),j+1);
			}
		}
		for(auto &e:edge){
		    sort(all(e));
			e.erase(unique(all(e)),e.end());
		}
		cout<<(isStable(p)?"STABLE":"UNSTABLE")<<endl;
	}
	return 0;
}
 



Measured memory_bytes: 3148
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val hList = readLongList().reversed()
    var pre = hList[0]
    for (i in 1 until n) {
        if (pre >= hList[i]) {
            pre = hList[i]
        } else {
            if (pre == hList[i] - 1) {
                pre = hList[i] - 1
            } else {
                println("No")
                return
            }
        }
    }
    println("Yes")
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 57392
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=14;

int n,m,x;
int c[M];
int a[M][M];
int s[M];
int solve(int msk)
{
    bitset<14>b=msk;
    clr(s);
    int cost=0;
    for(int j=0;j<n;j++)
    {
        if(b[j]==1)
        {
            cost+=c[j];
            for(int i=0;i<m;i++)
            {
                s[i]+=a[j][i];
            }
        }
    }
    int flag=0;
    f(i,0,m-1)
    {
        if(s[i]<x)flag=1;
    }
    if(flag)return inf;
    return cost;
}
 main()

{
    fast
    cin>>n>>m>>x;
    f(i,0,n-1)
    {
        cin>>c[i];
        f(j,0,m-1)
        {
            cin>>a[i][j];
        }
    }
    int ses=inf;
    int yo=(1LL<<n)-1;
    for(int msk=0;msk<=yo;msk++)
    {
       ses=min(ses,solve(msk));
    }
    if(ses>=inf)ses=-1;
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 3616
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;

void ansYes(bool flag) {
    if (flag) cout << "Yes" << endl; else cout << "No" << endl;
}

void ansYES(bool flag) {
    if (flag) cout << "YES" << endl; else cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

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

struct datas {
    Int max;
    Int size;
};

class ContainChecker {
protected:
    Int minx, miny, maxx, maxy;
public:
    ContainChecker(Int minx, Int miny, Int maxx, Int maxy) : minx(minx), miny(miny), maxx(maxx), maxy(maxy) {};

    bool in(Int x, Int y) {
        return (minx <= x && miny <= y && x <= maxx && y <= maxy);
    }
};





int main(void) {
    Int a,b;
    cin >> a >> b;
    if (a < 6 ) {
        cout << 0 << endl;
    }else if ( a < 13) {
        cout << b / 2 << endl;
    }else{
        cout << b << endl;
    }

}




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

public class Main {

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

		int h[] = new int[300];
		int w[] = new int[300];
		int endIndex = 0;
		
		for (int i = 0; i < 300; i++) {
			h[i] = scan.nextInt();
			w[i] = scan.nextInt();

			if (h[i] == 0 && w[i] == 0) {
				endIndex = i;
				break;
			}
		}
		
		for (int i = 0; i < endIndex; i++) {
			for (int height = 0; height < h[i]; height++) {
				for (int width = 0; width < w[i]; width++) {
					if (height == 0 || height == h[i] - 1 || 
							width == 0 || width == w[i] - 1) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		
		scan.close();
	}
}

Measured memory_bytes: 24840
from itertools import product as prod

def main():
    s = input()
    n = len(s)
    sum = 0
    for sym in prod(["","+"],repeat=n-1):
        exp = ""
        for i,c in enumerate(s[:-1]):
            exp += ( c + sym[i] )
        exp += s[-1:]
        sum += eval(exp)
    print(sum)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var jy=input.trim().split(" ").map(Number);
var j=jy[0];
var y=jy[1];
var sum=j+y;
var all=[];
var loop=function(ary,j,y,J,Y){
   if(ary.length==sum){
      all.push(ary.join(""));  
   }else{
      if(J==5 && Y==5)return;
      if(J==6 || Y==6)return;      
      if(J<=3 && Y==5)return;      
      if(J==5 && Y<=3)return;  
      if(j>=1)loop(ary.concat("A"),j-1,y,J+1,Y);
      if(y>=1)loop(ary.concat("B"),j,y-1,J,Y+1);
   }
};
loop([],j,y,0,0);
all.sort();
console.log(all.join("\n"));

Measured memory_bytes: 15888
using System;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var names = Console.ReadLine().Trim().Split(' ').ToList();
        var count = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
        Console.WriteLine(names.IndexOf(Console.ReadLine().Trim()) == 0 ? string.Join(" ", count[0] - 1, count[1]) : string.Join(" ", count[0], count[1] - 1));
    }
}

Measured memory_bytes: 13280
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1, s2;
    cin >> s1 >> s2;
    lli f = 0;
    if (s1.length() == s2.length() - 1)
    {
        for1(i, 0, s1.length())
        {
            if (s1[i] != s2[i])
            {
                f = 1;
                break;
            }
        }
    }
    if (f)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3636
N,M,C = map(int, input().split(" "))
B = [int(i) for i in input().split(" ")]
count = 0
for i in range(N):
    A = [int(k) for k in input().split(" ")]
    Sum = 0
    for j in range(M):
        Sum += A[j]*B[j]
    if Sum+C>0:
        count+=1
print(count)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
using ll = long long;

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

    ll ans = 0;
    if (N == 1 && M == 1) {
        ans = 1;
    } else if (N == 1) {
        ans = M - 2;
    } else if (M == 1) {
        ans = N - 2;
    } else {
        ans = (ll)(N - 2) * (M - 2);
    }

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

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

int n,m;


int main(){
    cin >> n >> m;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    Graph G(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    /*
    for(int i=0;i<n;i++){
        cout << "座標" << i+1 << "=";
        for(auto x:G[i]){
            cout << x << " ";
        }
        cout << endl;
    }
    */
    int ans = 0;
    for(int i=0;i<n;i++){
        bool ok = true;
        //cout << "size=" << G[i].size() << endl;
        for(auto x:G[i]){
            if(h[i] <= h[x]) ok = false;
        }
        if(ok) {ans++;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 8804
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int par[maxn];
int par2[maxn];
int n;
int m1,m2;
void init()
{
	repd(i,0,n)
	{
		par[i]=i;
		par2[i]=i;
	}
}
int findpar(int x)
{
	return x==par[x]?x:par[x]=findpar(par[x]);
}
int findpar2(int x)
{
	return x==par2[x]?x:par2[x]=findpar2(par2[x]);
}
void merg(int x,int y)
{
	x=findpar(x);
	y=findpar(y);
	if(x!=y)
	{
		par[x]=y;
	}
}
void merg2(int x,int y)
{
	x=findpar2(x);
	y=findpar2(y);
	if(x!=y)
	{
		par2[x]=y;
	}
}
std::vector<int> v[maxn];
// std::vector<int> v2[];

int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	gg(n);
	gg(m1);
	gg(m2);
	init();
	int a,b;
	repd(i,1,m1)
	{
		gg(a);
		gg(b);
//		v[a].pb(b);
//		v[b].push_back(a);
		merg(a,b);
	}
	repd(i,1,m2)
	{
		gg(a);
		gg(b);
//		v[a].pb(b);
//		v[b].push_back(a);
		merg2(a,b);
	}
	map<pii,int> ans;
	repd(i,1,n)
	{
//	    sort(ALL(v[i]));
//	    v[i].erase(unique(ALL(v[i])),v[i].end());
        ans[mp(findpar(i),findpar2(i))]++;
//		int cnt=0;
//		repd(x,1,n)
//		{
//			if((findpar(i)==findpar(x))&&(findpar2(i)==findpar2(x)))
//			{
//				cnt++;
//			}
//		}
////		cnt++;
//		printf("%d ",cnt);
	}
    repd(i,1,n)
    {
        cout<<ans[mp(findpar(i),findpar2(i))]<<" ";
    }

    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 39168