akhauriyash/Code-Regression huggingface dataset:
#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<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

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; }

int main() {
    string s;
    cin >> s;
    int n = s.length(), x = 0;
    REP(i,n) x += (s[i] == 'o');
    x += (15 - n);
    cout << (x >= 8 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005;
int n,q,ans;
struct seg
{
	int tr[N<<2];
	void build(int k,int l,int r)
	{
		tr[k]=(k==1?n:1e9);
		if(l==r)
			return;
		int mid=l+r>>1;
		build(k<<1,l,mid);
		build(k<<1|1,mid+1,r);
	}
	void update(int k,int l,int r,int a,int b,int v)
	{
		if(l==a&&r==b)
		{
			tr[k]=min(tr[k],v);
			return;
		}
		int mid=l+r>>1;
		if(b<=mid) update(k<<1,l,mid,a,b,v);
		else if(a>mid) update(k<<1|1,mid+1,r,a,b,v);
		else update(k<<1,l,mid,a,mid,v),update(k<<1|1,mid+1,r,mid+1,b,v);
	}
	int query(int k,int l,int r,int x)
	{
		if(l==r)
			return tr[k];
		int mid=l+r>>1;
		if(x<=mid) return min(tr[k],query(k<<1,l,mid,x));
		else return min(tr[k],query(k<<1|1,mid+1,r,x));
	}
}t1,t2;
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>q;
	ans=(n-2)*(n-2);
	t1.build(1,1,n);
	t2.build(1,1,n);
	while(q--)
	{
		int t,x;
		cin>>t>>x;
		if(t==1)
		{
			int v=t2.query(1,1,n,x);
			ans-=v-2;
			t1.update(1,1,n,1,v,x);
		}
		else
		{
			int v=t1.query(1,1,n,x);
			ans-=v-2;
			t2.update(1,1,n,1,v,x);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11796
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        s: chars,
    }
    let c = s[s.len() / 2];
    let h = s.len() / 2;
    let n = s.len();
    for i in 0..s.len()/2 {
        if s[n-h +i] != c || s[h-1-i] != c {
            if n & 1 > 0 {
            println!("{}", h + i + 1);
            } else {
            println!("{}", h + i);
            }
            return;
        }
    }
    println!("{}", n);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>

int main() 
{
    int n, x, y;
    std::cin >> n >> x >> y;

    std::vector<size_t> counts(n, 0);
    for (int i = 1; i <= n - 1; i++) {
        for (int j = i + 1; j <= n; j++) {
            int d_ij = j - i;
            int d_ixyj = std::abs(i - x) + 1 + std::abs(j - y);
            int d_iyxj = std::abs(i - y) + 1 + std::abs(j - x);
            int d_min = std::min(d_ij, std::min(d_ixyj, d_iyxj));
            counts.at(d_min) += 1;
        }
    }


    for (int i = 1; i < n; i++) {
        std::cout << counts[i] << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    int N;
    string S;
    cin >> N >> S;
    lint r=0,g=0,b=0;
    rep(i,N){
        if(S[i]=='R')r++;
        if(S[i]=='G')g++;
        if(S[i]=='B')b++;
    }
    lint ans=r*g*b;
    rep(j,N)rep(i,j){
            int k = j + (j-i);
        if(k<N)if(S[i]!=S[j]&&S[k]!=S[j]&&S[k]!=S[i])ans--;
    }

    cout << ans;
    return 0;
}


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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 2e5;
const ll inf = 1e18;
const ll mod = 1e9 + 7;



int main(){
	fastio;
	ll tc,n,m,t,tt,f,q;
	deque<char> dq;
	char c;
	string s;
	cin >> s;
	f(i,0,s.size()) dq.push_back(s[i]);
	ll rev = 0;
	cin >> q;
	while(q--){
		cin >> t;
		if(t == 1) rev = 1-rev;
		else{
			cin >> f >> c;
			f--;
		//	cout << f << " " << c << endl;
			if(f == rev) dq.push_front(c);
			else dq.push_back(c);
		} 
	}
	if(rev){
		for (auto it = dq.rbegin(); it != dq.rend(); ++it) 
        cout << *it ; 
	}
	else{
		for (auto it = dq.begin(); it != dq.end(); ++it) 
        cout << *it ; 
	}
}

Measured memory_bytes: 4008
#include<cstdio>
#define LL long long 
LL n,s;
LL f(LL x,LL b)
{
	LL res=0;
	while(x)
	{
		res+=x%b;
		x/=b;
	}
	return res;
}
int main()
{
	scanf("%lld%lld",&n,&s);
	if(s>n)
	{
		printf("-1\n");
		return 0;
	}
	if(s==n)
	{
		printf("%lld\n",n+1);
		return 0;
	}
	for(LL i=2ll;i*i<=n;i++)
		if(f(n,i)==s)
		{
			printf("%lld\n",i);
			return 0;
		}
	LL ans=-1;
	for(LL i=1ll;i*i<=n-s;i++)
		if((n-s)%i==0)
		{
			LL b=(n-s)/i+1;
			if(n%b+n/b==s) ans=b;
		}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,ans;

main(){
	cin>>n;
	n*=2;
	int l[n];
	rep(i,n)cin>>l[i];
	sort(l,l+n);
	for(int i=1;i<n;i+=2){
		ans+=min(l[i-1],l[i]);
		//dans;
	}
	dans;
}



Measured memory_bytes: 256
#define N 101
 
int G[N][N],way[N],chi[N],n;
 
void Fsearch(int x, int y){
  int i;
  way[x] = y;
  for(i=1;i<=chi[x];i++)
    if(y+1<way[G[x][i]]) Fsearch(G[x][i], y + 1);
}
 
int main(){
  int i,j,m;
 
  scanf("%d",&n);
 
  for(i=1;i<=n;i++){
    way[i]=N;
    scanf("%d",&m);
    scanf("%d",&chi[m]);
 
    for(j=1;j<=chi[m];j++){
	 scanf("%d",&G[m][j]);
    }
  }
 
  Fsearch(1,0);
 
  for(i=1;i<=n;i++)
    if(way[i]==N)way[i]=-1;
 
  for(i=1;i<=n;i++) printf("%d %d\n",i,way[i]);
 
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <limits>
#include <string>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 998244353;

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

int main()
{
  int N,T,A;
  float num;
  int bestindex = 0;
  float bestvalue;
  cin >> N >> T >> A;
  cin >> num;
  bestvalue = abs(A - (T - num*0.006));
  for(int i=1;i<N;i++){
    cin >> num;
    if(bestvalue > abs(A - (T - num*0.006))){
      bestvalue = abs(A - (T - num*0.006));
      bestindex = i;
    }
  }
  cout << bestindex+1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int arr[123456];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;cin>>n;
	for(int i=0;i<n;i++) cin>>arr[i],arr[i]--;
	for(int i=1;i<n;i++)
		if(arr[i-1]>arr[i]) arr[i]++;
	for(int i=1;i<n;i++){
		if(arr[i-1]>arr[i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    for(int i = 1; i <= x / 100; i++){
        int tmp = x - i * 100;
        if(tmp <= 5 * i){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();

    System.out.print(a/b + " ");
    System.out.print(a%b + " ");
    double d = (double)a/(double)b;
    System.out.printf("%f",d);

    scan.close();
  }
}


Measured memory_bytes: 26436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static final int MAX_A = 10000 + 10;
    static int n;

    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        n = Integer.parseInt(sc.next());

        int[] A = new int[n + 10];
        for (int i = 0; i < n; i++) {
            A[i] = Integer.parseInt(sc.next());
        }

        int[] B = new int[n + 10];
        CountingSort(A, B);

        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n; i++){
            sb.append(i == 0 ? "" : " ");
            sb.append(B[i]);
        }
        System.out.println(sb.toString());
    }

    static void CountingSort(int[] A, int[] B) {
        int[] C = new int[MAX_A];

        for (int i = 0; i < n; i++) {
            C[A[i]]++;
        }

        for (int i = 1; i < MAX_A; i++) {
            C[i] += C[i - 1];
        }

        for (int i = n - 1; i >= 0; i--) {
            C[A[i]]--;
            B[C[A[i]]] = A[i];
        }
    }

    public static class Scanner {
        private BufferedReader br;
        private StringTokenizer tok;

        public Scanner(InputStream is) throws IOException {
            br = new BufferedReader(new InputStreamReader(is));
        }

        private void getLine() throws IOException {
            while (!hasNext()) { tok = new StringTokenizer(br.readLine()); }
        }

        private boolean hasNext() {
            return tok != null && tok.hasMoreTokens();
        }

        public String next() throws IOException {
            getLine(); return tok.nextToken();
        }

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

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

        public void close() throws IOException {
            br.close();
        }
    }
}

Measured memory_bytes: 159640
#include <bits/stdc++.h>
// https://boostjp.github.io/tips/multiprec-int.html
// https://boostjp.github.io/tips/multiprec-float.html
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

using namespace std;

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

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; }

string s,t;
int main() {
    INIT();

    int m = 19999;
    cin >> s >> t;
    for(int i = 0; i <= (int)(s.length()) - (int)(t.length()); i++) {
        int cnt = 0;
        REP(j, (int)(t.length())) {
            if(t[j] != s[i + j]) cnt++;
        }
        chmin(m, cnt);
    }
    cout << m;
}

Measured memory_bytes: 3608
#include <stdio.h>
int main()
{
	int a,b;
	while(1)	
	{
		scanf("%d%d",&a,&b);
		if(a==0&&b==0)
		break;
		for(int i=1;i<=a;i++)
		{
			for(int j=1;j<=b;j++)
			{
				if(i==1||i==a||j==1||j==b)
				printf("#");
				else 
				printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
 } 


Measured memory_bytes: 2040
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
p = na()
s = 0
for i in range(k):
    s += 1/p[i] * (1/2) * (1 + p[i]) * p[i]
ans = s
l = 0
r = k
for i in range(n-k):
    #print(l, r)
    s -= 1/p[l] * (1/2) * (1 + p[l]) * p[l]
    s += 1/p[r] * (1/2) * (1 + p[r]) * p[r]
    ans = max(ans, s)
    l += 1
    r += 1
print(ans)


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;
using namespace std;
long long h[10000010],x[10000010];

signed main(){
      
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,c;
  cin>>a>>b>>c;

  if(c>=a){
    if(c<=b) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
  }else cout<<"No"<<'\n';
}

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

using namespace std;
const int N = 2e5 + 5, inf = 1e9 + 7;
int a[N], dp[N], ans[N], n;
vector <int> g[N];

void dfs(int v, int p = 0) {
    int x = lower_bound(dp, dp + n + 1, a[v]) - dp, val = dp[x];
    dp[x] = a[v], ans[v] = lower_bound(dp, dp + n + 1, inf) - dp;
    for (int u : g[v]) if (u != p) dfs(u, v);
    dp[x] = val;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v;
        g[u].push_back(v), g[v].push_back(u);
    }
    fill(dp, dp + n + 1, inf), dfs(1);
    for (int i = 1; i <= n; i++) cout << ans[i] << "\n";

    return 0;
}


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

using namespace std;

typedef pair<double, int> p;
 
int main()
{
    vector<p> v, th;
    int n = 3, num;
    double data;
    
    while (n--) {
        v.clear();
        for (int i = 0; i < 8; i++) {
            cin >> num >> data;
            v.push_back(p(data, num));
        }
        sort(v.begin(), v.end());
        printf("%d %.2f\n", v[0].second, v[0].first);
        printf("%d %.2f\n", v[1].second, v[1].first);
        th.push_back(v[2]);
    }
    sort(th.begin(), th.end());
    printf("%d %.2f\n", th[0].second, th[0].first);
    printf("%d %.2f\n", th[1].second, th[1].first);
    return 0;
}

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

#define nax 3009
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)

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

ll dp[nax][nax][2], n;
bool vis[nax][nax][2];
vi v;

ll f(int l = 0, int t = n-1,int k =0){

	if(l==t) return (k==0)?v[l]:-v[l];
	
	if(vis[l][t][k]) return dp[l][t][k];
	vis[l][t][k] = 1;
	
	if(k==0){
		return dp[l][t][k] = max(f(l+1,t,1-k)+v[l],
								f(l,t-1,1-k)+v[t]);
	}else{
		return dp[l][t][k] = min(f(l+1,t,1-k)-v[l],
								f(l,t-1,1-k)-v[t]);
	}
}

int main(){
	cin>>n;
	v.resize(n);
	REP(i,n) cin>> v[i];

	memset(vis,0,sizeof vis);
	memset(dp,0LL,sizeof dp);
	cout<<f()<<endl;

	return 0;
}

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

namespace ConsoleApp11
{
    class Class18
    {
        static void Main()
        {
            var N = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int left = A.Where(x => x < N[2]).Count();
            int right = N[1]-left;
            int R = Math.Min(left, right);
            Console.WriteLine(R);
            
        }
    }
}


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

 
int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    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
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    ll n,t;
    cin>>n>>t;
    ll arr[n];
    loop(n,i,0)
        cin>>arr[i];
    ll tot=n*t;
    loop(n-1,i,0){
        if(arr[i]+t>arr[i+1])
            tot-=(arr[i]+t-arr[i+1]);
    }
    cout<<tot<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


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

int main(){
    int h, w, m = 0;
    int d[1002][1002];
    char a[1002][1002];
    queue<pair<int,int>> q; //x,y

    fill(d[0],d[1002],0);
    fill(a[0],a[1002],'#');

    cin >> h >> w;
    for(int y = 1; y <= h; y++){
        for(int x = 1; x <= w; x++){
            cin >> a[x][y];
            if(a[x][y] == '#'){
                q.push(make_pair(x,y));
            }
        }
    }


    while (!q.empty()){
        pair<int,int> p = q.front();
        q.pop();

        if(d[p.first][p.second] > m){
            m = d[p.first][p.second];
        }

        if(a[p.first][p.second+1] == '.' &&
            d[p.first][p.second+1] == 0){
                d[p.first][p.second+1] = d[p.first][p.second] + 1;
                q.push(make_pair(p.first,p.second+1));
            }
        if(a[p.first][p.second-1] == '.' &&
            d[p.first][p.second-1] == 0){
                d[p.first][p.second-1] = d[p.first][p.second] + 1;
                q.push(make_pair(p.first,p.second-1));
            }
        if(a[p.first+1][p.second] == '.' &&
            d[p.first+1][p.second] == 0){
                d[p.first+1][p.second] = d[p.first][p.second] + 1;
                q.push(make_pair(p.first+1,p.second));
            }
        if(a[p.first-1][p.second] == '.' &&
            d[p.first-1][p.second] == 0){
                d[p.first-1][p.second] = d[p.first][p.second] + 1;
                q.push(make_pair(p.first-1,p.second));
            }
    }
    cout << m << endl;
}

Measured memory_bytes: 13328
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#define INF 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main()
{
	
	int a,b,c;
	scanf("%d%d",&a,&b);
	c=2*b;
	if(a>c)
	printf("%d\n",a-c);
	else
	printf("0\n");
 } 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a = int(input())
b = list(map(int,input().split()))
ret = "Yes"
cur_bar = b[-1]
for n_1 in b[-2::-1]:
    if cur_bar >= n_1:
        cur_bar=n_1
    elif cur_bar - n_1==-1:
        pass
    else:
        ret = "No"
        break
print(ret)


Measured memory_bytes: 63856
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

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

    priority_queue<double, vector<double>, greater<double>> que;
    for (int i = 0; i < n; i++) {
        double v;
        cin >> v;
        que.push(v);
    }

    while (que.size() > 1) {
        double v1 = que.top(); que.pop();
        double v2 = que.top(); que.pop();
        que.push((v1 + v2) / 2);
    }

    cout << setprecision(12) << fixed << que.top() << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[55];
int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
    }
    ll k = 0;
    while(1) {
        ll MAX = -1,id;
        for(int i = 1; i <= n; i ++) {
            if(MAX < a[i]){
                MAX = a[i];
                id = i;
            }
        }
        if(MAX < n)break;
        for(int i = 1; i <= n; i ++) {
            if(i == id) a[i] %= n;
            else a[i] += MAX/n;
        }
        k += MAX / n;
    }
    printf("%lld\n",k);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int cnt = 0;
    rep(i, n) if (p[i] != i + 1) cnt++;
    if (cnt == 0 || cnt == 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

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

int main(){
  while(1){
  int n,m;
  int ans=0;
  int a;
  priority_queue<int> q;
  cin>>n>>m;
  if(n+m==0) break;
  for(int i=1;i<=n;i++){cin>>a;q.push(a);}
  for(int i=1;i<=m;i++){cin>>a;q.push(a);}
  int af;
  af=q.top();q.pop();
    while(!q.empty()){
    int be=q.top();
    q.pop();
    ans=max(ans,af-be);
    af=be;
  }
  ans=max(af,ans);
  cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1348
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int N;
    cin>>N;
    double A;
    string S;
    double ans=0;
    for(int i=0;i<N;i++){
        cin>>A>>S;
        if(S=="BTC"){

            ans=ans+380000*A;
        }
        else{
            ans=ans+A;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N,K; cin >> N >> K;
    VI h(N);
    REP(i, N) cin >> h[i];
    VI dp(N, INF);
    dp[0] = 0;
    REP(i, N-1) {
        REP(j,K) {
            if (i + j + 1 < N) {
                dp[i + j + 1] = min(dp[i + j + 1], dp[i] + abs(h[i] - h[i + j + 1]));
            }
            else {
                break;
            }
        }
    }
    cout << dp[N - 1] << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;

signed main() {
	puts("square1001");
}


Measured memory_bytes: 2928
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int s=0,g=a;
	while(g<1e8){
		if(s%60<=c&&c<=g%60)break;
		if(g%60<s%60&&(s%60<=c||c<=g%60))break;
		s+=a+b;
		g+=a+b;
	}
	if(g>=1e8)cout<<-1<<endl;
	else if(s%60<c)cout<<s+c-s%60<<endl;
	else cout<<g+c-g%60<<endl;
}

Measured memory_bytes: 1164
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let mut f = String::new();
    f.push(s[0]);
    f.push(s[1]);
    let mut b = String::new();
    b.push(s[2]);
    b.push(s[3]);

    let mut ff = false;
    let mut bb = false;

    if f == "01" ||
        f == "02" ||
        f == "03" ||
        f == "04" ||
        f == "05" ||
        f == "06" ||
        f == "07" ||
        f == "08" ||
        f == "09" ||
        f == "10" ||
        f == "11" ||
        f == "12" {
            ff = true;
        }
    if b == "01" ||
        b == "02" ||
        b == "03" ||
        b == "04" ||
        b == "05" ||
        b == "06" ||
        b == "07" ||
        b == "08" ||
        b == "09" ||
        b == "10" ||
        b == "11" ||
        b == "12" {
            bb = true;
        }
    if ff && bb {
        println!("AMBIGUOUS");
    } else if ff {
        println!("MMYY");
    } else if bb {
        println!("YYMM");
    } else {
        println!("NA");
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
using namespace std;
main(){
  char str[256];
  while(~scanf("%s",str)){
    int N=strlen(str);
    for(int i=0;i<N;i++){
      if(str[i]=='@'){
	i++;
	for(int j=0;j<str[i]-'0';j++){
	  printf("%c",str[i+1]);
	}
	i++;
      }
      else
	printf("%c",str[i]);
    }
    puts("");
  }
}

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

typedef long long lli;
typedef vector<vector<int> > Graph;

const int MAXN = 50;

int N;
map<string,int> id;
Graph g;
int B[MAXN];

lli adj[MAXN];
int sum[MAXN];
int ans;

inline int getId(const string &s) {
  if(!id.count(s)) id[s] = id.size()-1;
  return id[s];
}

inline void addEdge(int src, int dst, Graph &g) {
  g[src].push_back(dst);
}

void rec(int k, lli bit, int now) {
  if(now + sum[k] <= ans) return;
  if(k == N) {
    ans = max(ans, now);
    return;
  }
  if(!(bit & (1LL<<k))) rec(k+1, bit|adj[k], now+B[k]);
  rec(k+1, bit, now);
}

int main() {
  while(cin >> N && N) {
    id.clear();
    g = Graph(N);
    for(int i = 0; i < N; ++i) {
      string src;
      int C;
      cin >> src;
      cin >> B[getId(src)] >> C;
      while(C--) {
        string dst;
        cin >> dst;
        addEdge(getId(src), getId(dst), g);
      }
    }

    for(int v = 0; v < N; ++v) {
      adj[v] = 0;//1LL<<v;
      for(int i = 0; i < g[v].size(); ++i) {
        int nv = g[v][i];
        adj[v] |= 1LL<<nv;
      }
    }

    sum[N] = 0;
    for(int v = N-1; v >= 0; --v) sum[v] = sum[v+1] + B[v];

    ans = 0;
    rec(1, adj[0], B[0]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <cstring>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 2e5 + 4;
const double EPS = 1e-7;
const int mod = 1e9 + 7;
const int hashpow = 2;
const int inf = 2e9;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int n, k;
int a[SZ][61];

inline void read() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i][0];
        --a[i][0];
    }
}

int get(int k) {
    int ans = 0;
    int t = 0;
    while (k) {
        if (k & 1) {
            ans = a[ans][t];
        }
        k >>= 1;
        ++t;
    }

    return ans;
}

inline void solve() {
    for (int j = 1; j < 61; ++j) {
        for (int i = 0; i < n; ++i) {
            a[i][j] = a[a[i][j - 1]][j - 1];
        }
    }

    cout << get(k) + 1 << "\n";
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

Measured memory_bytes: 98972
# E

# 入力
# input
N = int(input())
a_list = [0]*(N+1)
for i in range(N+1):
    a_list[N-i] = int(input())


# 10^5までの素数を計算
# list primes <= 10^5 
primes = list(range(10**5))
primes[0] = 0
primes[1] = 0
for p in range(2, 10**5):
    if primes[p]:
        for i in range(2*p, 10**5, p):
            primes[i] = 0
primes = [p for p in primes if p>0]
# primes <= N
p_list_small = [p for p in primes if p <= N]


# A_Nを素因数分解、Nより大きい素因数をp_list_largeに追加
# A_N, ..., A_0の最大公約数の素因数でやっても同じ
# list prime factors of A_N, if greater then N, add to p_list_large
# you can use prime factors of gcd(A_N, ..., A_0) instead 

p_list_large = []
A = abs(a_list[-1])
for p in primes:
    if A % p == 0:
        if p > N:
            p_list_large.append(p)
        while A % p == 0:
            A = A // p
if A != 1:
    p_list_large.append(A)

# 個別に条件確認
# check all p in p_list_small
# x^p ~ x (mod p)
res_list = []
for p in p_list_small:
    r = 0
    check_list = [0]*(N+1)
    for i in range(p):
        check_list[i] = a_list[i]
    for i in range(p, N+1):
        check_list[(i-1) % (p-1) + 1] += a_list[i]
    for i in range(p):
        if check_list[i] % p != 0:
            r = 1
    if r == 0:
        res_list.append(p)
        
# 個別に条件確認
# check all p in p_list_large
# a_i % p == 0
for p in p_list_large:
    r = 0
    for i in range(N+1):
        if a_list[i] % p != 0:
            r = 1
    if r == 0:
        res_list.append(p)
        
for p in res_list:
    print(p)

Measured memory_bytes: 51800
n, x = map(int, input().split())
ls = list(map(int, input().split()))

z = [0]
for i in range(1, n+1):
    z += [z[i-1] + ls[i-1]]

#print(z)

count = 0
for c in z:
    if c <= x:
        count += 1

print(count)

Measured memory_bytes: 3064
#include <stdio.h>

int n;
int memo[1000][11][21]={0};

int main(void){
  int i,j,k,t,co=0,max;
  for(i=1;i<=999;i++){
    for(j=1;j<=10;j++){
      if(i%3==0||j%2!=0)max=20;
      else max =19;
	for(k=1;k<=max;k++){
	  memo[i][j][k]=co;
	  co++;
	}
    }
  }
  scanf("%d",&n);
  for(t=0;t<n;t++){
    scanf("%d%d%d",&i,&j,&k);
    printf("%d\n",196470-memo[i][j][k]);
  }
  
	
  return 0;
}


Measured memory_bytes: 2636
/// Swift5 -> Swift2.2

extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
    // lastIndex(where:)
    func lastIndex(where predicate: (Element) -> Bool) -> Int? {
      	for i in stride(from: count - 1, through: 0, by: -1) {
          	if predicate(self[i]) {
              	return i
            }
        }
      	return nil
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
    // max()
    func max() -> Element? {
        guard self.count > 0 else { return nil }
        return self.reduce(self.first!) { return Swift.max($0, $1) }
    }
}
extension String {
    // Sequence#enumerated()
  	// public func enumerate<Seq : SequenceType>(base: Seq) -> EnumerateSequence<Seq>
    func enumerated() -> EnumerateSequence<[Character]> {
        return Array(self.characters).enumerate()
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
// stride(from:to:by)
func stride(from start: Int, to end: Int, by stride: Int) -> StrideTo<Int> {
    return start.stride(to: end, by: stride)
}

/// end


let N = Int(readLine()!)!

var dp = Array(repeating: Int.max, count: N + 1)
dp[0] = 0

for withdrawal in stride(from: 1, through: N, by: 1) {
    var w6 = 1
    while w6 <= withdrawal {
        dp[withdrawal] = min(dp[withdrawal], dp[withdrawal - w6] + 1)
        w6 *= 6
    }

    var w9 = 1
    while w9 <= withdrawal {
        dp[withdrawal] = min(dp[withdrawal], dp[withdrawal - w9] + 1)
        w9 *= 9
    }
}

print(dp.last!)


Measured memory_bytes: 4464
//Just try and the idea will come
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,i,a[19];
ll go(ll l,ll r,ll x,ll y){
    if(r-l<2)return 0ll;
    ll res=1e18;
    for(ll i=l+1;i<r;i++)res=min(res,a[i]*(x+y)+go(l,i,x,y+x)+go(i,r,x+y,y));
    return res;
}
int main(){
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i];
    cout<<a[1]+a[n]+go(1,n,1,1);
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		Dice dice = new Dice(input());
		int q = Integer.parseInt(input());

		for (int i = 0; i < q; i++) {

			dice.setRight(input());
			System.out.println(dice.getRight());

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

class Dice {

	private int top;
	private int front;
	private int right;
	private int left;
	private int back;
	private int bottom;

	public Dice(String num) {

		String[] partsNum = num.split(" ");

		top = Integer.parseInt(partsNum[0]);
		front = Integer.parseInt(partsNum[1]);
		right = Integer.parseInt(partsNum[2]);
		left = Integer.parseInt(partsNum[3]);
		back = Integer.parseInt(partsNum[4]);
		bottom = Integer.parseInt(partsNum[5]);

	}

	public void setRight(String num) {

		String[] numList = num.split(" ");

		for (int i = 0; i < 6; i++) {

			if (i == 3) {

				this.roll("E");

			}

			if (Integer.parseInt(numList[1]) == this.front) {

				break;

			} else {

				this.roll("N");

			}
		}

		while (true) {

			if (Integer.parseInt(numList[0]) == this.top) {

				break;

			} else {

				this.roll("W");

			}
		}
	}

	public int getRight() {

		return this.right;

	}

	public void roll(String direction) {

		int temp;

		for (int i = 0; i < direction.length(); i++) {

			switch (direction.charAt(i)) {

			case 'E':

				temp = top;
				top = left;
				left = bottom;
				bottom = right;
				right = temp;
				break;

			case 'N':

				temp = top;
				top = front;
				front = bottom;
				bottom = back;
				back = temp;
				break;

			case 'S':

				temp = top;
				top = back;
				back = bottom;
				bottom = front;
				front = temp;
				break;

			case 'W':

				temp = top;
				top = right;
				right = bottom;
				bottom = left;
				left = temp;
				break;

			}
		}
	}

	public int getTop() {

		return top;

	}
}

Measured memory_bytes: 26040
#include <set>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	int x,n,m,k,i;
	for(;scanf("%d",&n),n;){
		vector<set<int> >v;
		for(i=0;i<n;i++){
			set<int>s;
			for(scanf("%d",&m),k=0;k<m;k++)
				scanf("%d",&x),s.insert(x);
			v.push_back(s);
		}
		set<int>t;
		for(scanf("%d",&k),m=0;m<k;m++)
			scanf("%d",&x),t.insert(x);
		vector<int>w;
		for(k=0;k<n;k++){
			set<int>s;
			set_intersection(v[k].begin(),v[k].end(),t.begin(),t.end(),inserter(s,s.end()));
			if(s.size()==t.size())w.push_back(k);
		}
		printf("%d\n",w.size()==1?w[0]+1:-1);
	}
}

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

int main() {
	//input
	string N;
	cin >> N;

	char seven = '7';

	//calculation
	int output = 0;

	for (int i = 0; i < 3; i++) {
		if (N[i] == seven) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    long a=sc.nextLong();
    long b=sc.nextLong();
    long c=sc.nextLong();
    long d=sc.nextLong();
    long ans1=Math.max(a,b)*Math.max(c,d);
    long ans2=Math.min(a,b)*Math.max(c,d);
    long ans3=Math.max(a,b)*Math.min(c,d);
    long ans4=Math.min(a,b)*Math.min(c,d);
    long ans=Math.max(ans1,Math.max(ans2,
    Math.max(ans3,ans4)));
    System.out.println(ans);
  }
}


Measured memory_bytes: 35676
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))
cnt = 0
light = 1
for i in range(N):
	cnt += 1
	light = A[light - 1]
	if light == 2:
		break

if cnt == N:
	print(-1)
else:
	print(cnt)

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k, a, b;
  cin >> k >> a >> b;
  
  int tmp = (a / k) + 1;
  if (a % k == 0 || b % k == 0) {
    cout << "OK" << endl;
    return 0;
  } else if (k * tmp <= b) {
    cout << "OK" << endl;
    return 0;
  } else {
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<iomanip>
#define FAST ios::sync_with_stdio(false)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 9;
const int maxn = (int)1e5 + 5;
using namespace std;

int a[105];

int main()
{
	FAST;
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans;
	if(x == 0){
		ans = min(b, 2 * c) * y;
		return cout << ans << endl, 0;
	}
	if(y == 0){
		ans = min(a, 2 * c) * y;
		return cout << ans << endl, 0;
	}
	ans = min(a + b, 2 * c) * min(x, y);
	if(x > y){
		if(a <= 2 * c)
			ans += ((x - y) * a);
		else ans += (2 * c * (x - y));
	}
	if(x < y){
		if(b <= 2 * c)
			ans += ((y - x) * b);
		else ans += ((y - x) * 2 * c);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t;
char ch;
int main()
{
	cin>>s>>t;
	if(s==t) {
		cout<<"Yes";
		return 0;
	}
	for(int i=0;i<s.size();i++) {
		ch = s[s.size()-1];
		s.erase(s.size()-1,s.size());
		s = ch + s;
		if(s==t) {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256