akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	int a,b,c,d;
	cin >>a>>b>>c>>d;
	int ans = min(b,d)-max(a,c);
	if(ans < 0) ans = 0;
	cout << ans << endl;
	return 0;
}
	

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;

#[derive(Default)]
struct Input {
    buf: Vec<String>
}

impl Input {
    fn new() -> Input {
        Input { buf: Vec::new() }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_2<T: FromStr, U: FromStr>(&mut self) -> (T, U)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug {
        (self.read(), self.read())
    }

    fn read_bytes(&mut self) -> Vec<u8> {
        self.next().unwrap().into_bytes()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = io::stdin().read_line(&mut s);
            self.buf = s.split_whitespace().map(|s| s.to_owned()).collect::<Vec<_>>();
            self.buf.reverse();
        }
        self.buf.pop()
    }
}

fn run() {
    let mut ip = Input::new();
    let s = ip.read_bytes();
    let y = s.iter().fold(0, |c, b| if *b == b'1' { c + 1 } else { c });
    println!("{}", y);
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(10 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}

Measured memory_bytes: 8572
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for (i = 0; i <= VMAX; i++) {
    C[i] = 0;
  }
  for (i = 1; i <= n; i++) {
    scanf("%hu", &A[i]);
    C[A[i]]++;
  }
  for (i = 1; i <= VMAX; i++) {
    C[i] = C[i] + C[i - 1];
  }
  for (j = n; j >= 1; j--) {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for (i = 1; i <= n; i++) {
    if (i == n) {
      printf("%d\n", B[i]);
    } else {
      printf("%d ", B[i]);
    }
  }

  return 0;
}



Measured memory_bytes: 9596
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
    { 
        if (y == 0) 
            return 1; 
        int p = power(x, y/2, m) % m; 
        p = (p * p) % m; 
  
        return (y%2 == 0)? p : (x * p) % m; 
    } 
    int modInverse(int a, int m) 
    {   
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p) 
    { 
           if (r==0) 
              return 1; 
  
        int fac[n+1]; 
        fac[0] = 1; 
        for (int i=1 ; i<=n; i++) 
            fac[i] = fac[i-1]*i%p; 
  
        return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
    } 
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        // cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            ll n=0;
            cin>>n;
            ll a=0,b=0,c=0;
            int v[n][3];
            for (int i = 0; i < n; ++i)
            {
                cin>>v[i][0]>>v[i][1]>>v[i][2];
            }
            int dp[n+1][3];
            dp[0][0]=dp[0][1]=dp[0][2]=0;
            for (int i = 1; i <=n; ++i)
            {
                dp[i][0]=v[i-1][0]+max(dp[i-1][1],dp[i-1][2]);
                dp[i][1]=v[i-1][1]+max(dp[i-1][0],dp[i-1][2]);
                dp[i][2]=v[i-1][2]+max(dp[i-1][1],dp[i-1][0]);
            }
            cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
        }
        return 0;
    }

Measured memory_bytes: 8276
#!/usr/local/bin/ruby
#while line=gets
n=gets.to_i
rec=Array.new
ans=Array.new
n.times{
   rec=gets.split(" ").map(&:to_i)
   rec.sort!{|a,b| a <=> b}
   x,y,z=rec[0].to_i,rec[1].to_i,rec[2].to_i
   a=x*x+y*y
   b=z*z
   if a==b
   puts"YES"
   else
      puts"NO"
   end
}

Measured memory_bytes: 6112
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

struct BM {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  BM(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int max_match() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};

int main(){
	ll n ; cin >> n ;
	vector<pll> a(n),b(n) ;
	for(int i=0;i<n;i++) cin >> a[i].first >> a[i].second ;
	for(int i=0;i<n;i++) cin >> b[i].first >> b[i].second ;
	static BM bm(n*2) ;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i].first<b[j].first&&a[i].second<b[j].second){
				bm.add_edge(i,j+n) ;
			}
		}
	}
	cout << bm.max_match() << endl ;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){	
	ll n,m;
	cin>>n>>m;
	if(m-2*n<4) cout<<min(m/2,n);
	else cout<<n+(m-2*n)/4;
	return 0;
}

Measured memory_bytes: 3596
from collections import deque
n = int(input())
num_hen = n-1
info = [list(map(int,input().split())) for i in range(num_hen)]

for i in range(num_hen):
  info[i][0] -=1
  info[i][1] -=1

tree=[[] for i in range(n)]
for i in range(num_hen):
  tree[info[i][0]].append(info[i][1])
  tree[info[i][1]].append(info[i][0])
  
#paintedが0のときまだ塗られていない、1のとき黒、-1のとき白
painted=[0]*n
painted[0]=1
painted[n-1]=-1

#0からn-1まで行くための経路を求める（dfsで経路復元する）。
#keiroが経路になる
que = deque()
for i in range(len(tree[0])):
  que.append([tree[0][i],0])
visited=[False]*n 
visited[0]=True
keiro ={}
while que:
  v = que.pop()
  keiro[v[1]]=v[0]
  if v[0] == n-1:
    final = v[1]
    break
  elif not visited[v[0]]:
    for i in range(len(tree[v[0]])):
      que.append([tree[v[0]][i],v[1]+1])
    visited[v[0]]=True

#経路を黒と白で塗る
for i in range(final):
  if i%2==0:
    painted[keiro[i//2]]=1
  else:
    painted[keiro[final-1-i//2]]=-1

#全部の頂点に渡ってペイントするためのdfs
def dfs(i,color):
  que2 = deque()
  for element in tree[i]:
    que2.append(element)
  while que2:
    w = que2.pop()
    if painted[w]==0:
      painted[w]=color
      for element in tree[w]:
        que2.append(element)
  return

for i in range(n):
  if painted[i]==1:
    dfs(i,1)
  elif painted[i]==-1:
    dfs(i,-1)

print("Fennec" if painted.count(1) > painted.count(-1) else "Snuke")


    

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

int main()
{
    string s;
    getline(cin, s);

    for (char &c: s) {
        if ('a' <= c && c <= 'z') {
            cout << (char) (c - 'a' + 'A');
        } else if ('A' <= c && c <= 'Z') {
            cout << (char) (c - 'A' + 'a');
        } else {
            cout << c;
        }
    }

    cout << endl;

    return 0;
}

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

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 5;

int n, to[MAXN], in[MAXN], step1[MAXN], step2[MAXN], vis[MAXN];
LL k, len1, len2;

void toposort() {
    queue<int> q;
    for (int i = 1; i <= n; i++)
        if (!in[i]) q.push(i);
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        if(!(--in[to[cur]])) q.push(to[cur]);
    }
}

void getLen(int cur) {
    if (vis[cur]) return;
    vis[cur] = 1;
    if (in[cur]) step2[++len2] = to[cur], getLen(to[cur]);
    else step1[++len1] = to[cur], getLen(to[cur]);
}

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> to[i], in[to[i]]++;
    toposort(), getLen(1);
    if (k <= len1) cout << step1[k] << endl;
    else {
        k = (k - len1) % len2 ? (k - len1) % len2 : len2;
        cout << step2[k] << endl;
    }
    return 0;
}

Measured memory_bytes: 6732
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}

int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	cout<<(10 -( n/200))<<endl;
	
}

Measured memory_bytes: 3692
#include<bits/stdc++.h> 
 using namespace std;
 long long n,x,ans,c,d,y,i; 
 int main(){
	cin>>n;
	ans=n;
	for(int i=0;i<=n;i++)
	{
		x=i;
		c=0;	
	while(x) 
	{
		c+=x%9;
	    x=x/9;
	}
	y=n-i;
	while(y) 
	{
		c+=y%6;
	    y=y/6;
	}
	if(ans>c)
	ans=c;
	}
	cout<<ans;	
   return 0;
  }

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

int main()
{
  int n;
  cin >> n;
  int temp4 = n/4;
  int i;
  int temp = n;
  for(i = 0;i <= temp4;++i){
    temp -= 4*i;
    if(temp % 7 == 0){
      cout << "Yes" << endl;
      break;
    }else{
      temp = n; continue;
    }
  }
  if(i == temp4+1){
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//#include "pch.h"
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

int square(int a)
{
	return a * a;
}

int isint(int *data, int i, int j, int D)
{
	int nSum = 0;
	for (int k = 0; k < D; k++)
		nSum += square(data[i * D + k] - data[j * D + k]);

	if (square((int)(sqrt(nSum))) == nSum)
		return 1;
	else
		return 0;
}

int main()
{
	int N, D;
	scanf("%d %d", &N, &D);
	int *data = (int *)malloc(sizeof(int) * N * D);

	for (int i = 0; i < N * D; i++)
		scanf("%d", &data[i]);

	int nCount = 0;
	for (int i = 0; i < N - 1; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			if (isint(data, i, j, D))
				nCount++;
		}
	}

	printf("%d", nCount);

	return 0;
}

Measured memory_bytes: 128
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int32_t V[200010];
int32_t len[200010];
int32_t min[200010];
int32_t max[200010];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> V[i]; --V[i];
	}

	for (size_t i = 0; i < N; i++)
	{
		len[V[i]] = len[V[i] - 1] + 1;
	}

	out << N-*std::max_element(all_range(len)) << endl;


	return 0;
}
#endif


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

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

	int l, r;
	cin >> l >> r;
	int res = mod;
	for(int i = l; i <= min(l + 2018, r); i++){
		for(int j = l; j <= min(l + 2018, r); j++){
			if(i == j) continue;
			res = min(res, ((i % 2019) * (j % 2019)) % 2019);
		}
	}
	cout << res;
}

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H,W,D;
  cin >> H >> W >> D;
  pair<int, int> cor[H*W];
  int a;
  rep(i,H){
    rep(j,W){
      cin >> a;
      a--;
      cor[a] = mp(i,j);
    }
  }
  //  const int N=H*W;
  int Q;
  cin >> Q;
  int L,R;
  pair<int,pair<int, int> > Que[Q];
  pair<pair<int,pair<int, int> >,int > ind[Q];
  rep(i,Q){
    cin >> L >> R;
    L--;R--;
    Que[i] =mp(L%D, mp(L,R));
    ind[i] =mp(mp(L%D, mp(L,R)),i);
  }
  sort(Que, Que+Q);
  sort(ind, ind+Q);
  int MAX_N=1e5;
  int sum[MAX_N];
  int ans[Q];
  rep(i,Q){
    int l=(Que[i].second).first;
    int r=(Que[i].second).second;
    if(i!=0 && Que[i].first == Que[i-1].first){
      l=(Que[i-1].second).second;
      l+=D;
      while(l<=r){
        sum[l/D] = sum[l/D-1] + abs(cor[l-D].first-cor[l].first)+abs(cor[l-D].second-cor[l].second);
        l+=D;
      }      
    }
    else{
      sum[l/D]=0;
      l+=D;
      while(l<=r){
	sum[l/D] = sum[l/D-1] + abs(cor[l-D].first-cor[l].first)+abs(cor[l-D].second-cor[l].second);
	l+=D;
      }
    }
    l=(Que[i].second).first;
    ans[ind[i].second]=sum[r/D]-sum[l/D];
  }
  rep(i,Q) cout << ans[i] << endl;

  
  return 0;
    

}


Measured memory_bytes: 5376
#include<stdio.h>
int main()
{
    int i,n,a[101]={0};
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }

    for(i=n-1;i>=0;i--){
        if(i==0){
                printf("%d\n",a[i]); break;}

        printf("%d ",a[i]);
    }



    return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 3000000000000000000;

struct SegmentTree {
    int length;
    vector<int> node;
    SegmentTree(int N) {
        length = 1;
        while (length < N) length *= 2;
        node.resize(2 * length - 1, inf);
    }
    void update(int idx, int val) {
        idx += (length - 1);
        node[idx] = val;
        while (idx > 0) {
            idx = (idx - 1) / 2;
            node[idx] = min(node[2 * idx + 1], node[2 * idx + 2]);
        }
    }
    int getmin(int a, int b, int now = 0, int l = 0, int r = -1) {
        if (r < 0) r = length;
        if (r <= a || b <= l) return inf;
        if (a <= l && r <= b) return node[now];
        int vl = getmin(a, b, 2 * now + 1, l, (l + r) / 2);
        int vr = getmin(a, b, 2 * now + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};


int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    SegmentTree ST(N);
    rep(i, N) ST.update(i, A[i]);
    
    ll ans = 0;
    rep(i, N) {
        ll x = 0, y = 0;
        int left = -1, right = i + 1;
        while (right - left > 1) {
            int mid = (right + left) / 2;
            if (ST.getmin(mid, i + 1) < A[i]) left = mid;
            else right = mid;
        }
        x = i - left;
        left = i;
        right = N + 1;
        while (right - left > 1) {
            int mid = (right + left) / 2;
            if (ST.getmin(i, mid) < A[i]) right = mid;
            else left = mid;
        }
        y = left - i;
        ans += A[i] * x * y;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6136
#include <stdio.h>

int main(void){
	int n, tmp, j, i,l;
	int array[256];
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&array[i]);
	
	for(i=0;i<n;i++){
		printf("%d",array[i]);
		if(i!=n-1)printf(" ");
	}
	printf("\n");
	for (i = 1; i < n; i++) {
    	tmp = array[i];
    	if (array[i - 1] > tmp) {
        	j = i;
        	do {
        	    array[j] = array[j - 1];
        	    j--;
        	} while (j > 0 && array[j - 1] > tmp);
        	array[j] = tmp;
    	}
    	for(l=0;l<n;l++){
    		printf("%d",array[l]);
    		if(l!=n-1)printf(" ");
    	}
    	printf("\n");
    }
	return 0;
}

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;
long long a[100010][3];
long long dp[100010][3];

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (j == k)
                {
                    continue;
                }
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    long long res = 0;
    for (int i = 0; i < 3; i++)
    {
        chmax(res, dp[N][i]);
    }
    cout << res << endl;
}

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

int main() {
  int N, K, x, sum = 0; // Nは列の数、Kは右端のx座標
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> x;
    if (x < K - x)
      sum += x * 2;
    else
      sum += (K - x) * 2;
  }
  cout << sum << endl;
}


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

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

int main(){
    lint K;
    cin >> K;
    deque<pair<lint,lint>> Q;
    bool chk[100000];
    for(lint i=0;i<K;i++) chk[i]=false;

    Q.push_back(make_pair(1ll,1ll));
    while(!Q.empty()){
        lint cur=Q.front().first;
        lint d=Q.front().second;
        if(cur==0){
            cout << d << endl;
            return 0;
        }
        Q.pop_front();
        chk[cur]=true;

        if(!chk[(cur+1)%K]){
            Q.push_back(make_pair((cur+1)%K,d+1));
        }
        if(!chk[10*cur%K]){
            Q.push_front(make_pair(10*cur%K,d));
        }
    }

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int calcDate(int y, int m, int d){
  int i, days=0;

  for(i=1;i<y;i++){
    if(i%3==0){
      days += 200;
    }else{
      days += 195;
    }
  }

  for(i=1;i<m;i++){
    if(i%2==1 || y%3==0){
      days += 20;
    }else{
      days += 19;
    }
  }

  days += d-1;

  return days;
}

int main(){
  int i, n, y, m, d, seed;

  seed = calcDate(1000, 1, 1);

  scanf("%d", &n);
  int days[n];

  for(i=0;i<n;i++){
    scanf("%d", &y);
    scanf("%d", &m);
    scanf("%d", &d);
    days[i] = seed - calcDate(y, m, d);
  }

  for(i=0;i<n;i++){
    printf("%d\n", days[i]);
  }

  return 0;
}

Measured memory_bytes: 596
#b
n,k = map(int, input().split())
p = [0]*n
ans = 0
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        p[a[j]-1] += 1
for r in range(n):
    if p[r] == 0:
        ans += 1
print(ans)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	int c=-1,i=9;
	while(i>0)
	{
		if(a%i==0)
		{
			if(a/i<10)
			{
				c=1;
				break;
			}
		}
		i--;
	}
	if(c==-1)
	cout<<"No";
	else
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

const int N_MAX = 100010;
ll dp_A[N_MAX];
ll dp_AB[N_MAX];
ll dp_ABC[N_MAX];
ll dp_N[N_MAX];

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

    // input
    string s;
    cin >> s;

    ll L = s.size();
    dp_A[0] = 0;
    dp_AB[0] = 0;
    dp_ABC[0] = 0;
    dp_N[0] = 1;

    // i文字目を見たとき (1-indexed)
    FOR(i, 1, L+1){
        char c = s[i-1];
        if(c=='A'){
            dp_A[i] = dp_A[i-1] + dp_N[i-1]; // 文字列数分だけAが増える
            dp_AB[i] = dp_AB[i-1];
            dp_ABC[i] = dp_ABC[i-1];
            dp_N[i] = dp_N[i-1];
        }
        else if(c=='B'){
            dp_A[i] = dp_A[i-1];
            dp_AB[i] = dp_AB[i-1] + dp_A[i-1]; // １つ前のAの数だけABが増える
            dp_ABC[i] = dp_ABC[i-1];
            dp_N[i] = dp_N[i-1];
        }
        else if(c=='C'){
            dp_A[i] = dp_A[i-1];
            dp_AB[i] = dp_AB[i-1];
            dp_ABC[i] = dp_ABC[i-1] + dp_AB[i-1]; // 1つ前のABの数だけABCが増える
            dp_N[i] = dp_N[i-1];
        }
        else if(c=='?'){
            // Aの場合
            ll A_A = dp_A[i-1] + dp_N[i-1];
            ll AB_A = dp_AB[i-1];
            ll ABC_A = dp_ABC[i-1];

            // B
            ll A_B = dp_A[i-1];
            ll AB_B = dp_AB[i-1] + dp_A[i-1];
            ll ABC_B = dp_ABC[i-1];

            // C
            ll A_C = dp_A[i-1];
            ll AB_C = dp_AB[i-1];
            ll ABC_C = dp_ABC[i-1] + dp_AB[i-1];

            dp_A[i] = A_A + A_B + A_C;
            dp_AB[i] = AB_A + AB_B + AB_C;
            dp_ABC[i] = ABC_A + ABC_B + ABC_C;

            dp_N[i] = 3 * dp_N[i-1];
        }

        dp_A[i] %= mod;
        dp_AB[i] %= mod;
        dp_ABC[i] %= mod;
        dp_N[i] %= mod;
    }

    p(dp_ABC[L]);
    
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main(){
	int x,y,d;
	while(scanf("%d %d",&x,&y)>0){
		x+=y;
		d=1;
		while(x/10){
			d++;
			x/=10;
		}
		printf("%d\n",d);
	}
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio
    lli num1 , num2 , num3;
    cin >> num1 >> num2 >> num3 ;
    (num1 + num2 >= num3 ? (num1 <= num3 ? YES : NO ) : NO ) ;



    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (){
  int N,Y;
  cin >> N >> Y;
  int c;
  for(int i=0; i<N+1;i++){
    for(int j=0;j<N+1;j++){
      c=N-i-j;
      if(c>=0 && 10000*i+5000*j+1000*c==Y){
        cout << i << " "<< j << " "<< c << endl;
        return 0;
      }
    }
  }
  cout << -1 << " "<< -1 << " "<< -1 << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        char[] c = line.toCharArray();
        boolean a =true ;
        for(int i = 0; i < line.length() - 1; i++){
            if(c[i] == c[i + 1])
            a = false;
        }
        if(a)
        System.out.println("Good");
        else
        System.out.println("Bad");
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

bool b(char c)
{
	return c == '#';
}

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	for (int r = 0; r < H; ++r) {
		cin >> s[r];
	}

	vector<vector<int>> dp(H, vector<int>(W));

	dp[0][0] = b(s[0][0]);

	for (int r = 1; r < H; ++r) {
		dp[r][0] = dp[r - 1][0];
		if (!b(s[r - 1][0]) && b(s[r][0])) {
			++dp[r][0];
		}
	}
	for (int c = 1; c < W; ++c) {
		dp[0][c] = dp[0][c - 1];
		if (!b(s[0][c - 1]) && b(s[0][c])) {
			++dp[0][c];
		}
	}
	for (int r = 1; r < H; ++r) {
		for (int c = 1; c < W; ++c) {
			int t1 = dp[r - 1][c];
			if (!b(s[r - 1][c]) && b(s[r][c])) {
				++t1;
			}
			int t2 = dp[r][c - 1];
			if (!b(s[r][c - 1]) && b(s[r][c])) {
				++t2;
			}
			dp[r][c] = min(t1, t2);
		}
	}

	int ans = dp[H - 1][W - 1];
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

// Eratosthenes
vector<ll> divTable;

void setupDivTable(ll n) {
    divTable.assign(n + 1, 0);
    divTable[0] = 1;
    divTable[1] = 1;
    for (ll i = 2; i <= n; i++) {
        if (divTable[i] == 0) {
            for (ll j = 1; i * j <= n; j++) {
                divTable[i * j] = i;
            }
        }
    }
}


vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    while (N > 1) {
        ll a = divTable[N];
        ll ex = 0; // 指数
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}


void Main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    ll a = A[0];
    rep(i, n) {
        a = GCD(a, A[i]);
    }
    bool setwise = a == 1;

    ll maxA = *max_element(all(A));

    setupDivTable(maxA + 1);
    vector<ll> cnt(maxA + 1);
    rep(i, n) {
        auto primes = prime_factorize(A[i]);
        for (auto& p : primes) {
            cnt[p.first]++;
        }
    }

    bool pairwise = true;
    rep(i, cnt.size()) {
        if (cnt[i] >= 2) {
            pairwise = false;
            break;
        }
    }

    if (pairwise) { put("pairwise coprime") }
    else if (setwise) { put("setwise coprime") }
    else { put("not coprime") }

}
signed main(){ Main();return 0;}

Measured memory_bytes: 26648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 104;
ll n;

bool so(ll x){
	bool ok=true;
	FOR(i,2,sqrt(x)+1){
		if(x%i==0)ok=false;
	}
	return ok;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	ll i=11;
	cout<<11;n--;
	while(n!=0){
		i+=10;
		if(so(i)){
			cout<<" "<<i;
			n--;
		}
	}
	return 0;
}


Measured memory_bytes: 256
def main(argv)
  s = gets.chomp
  
  f = true
  (s.size - 1).times do |i|
    if s[i] == s[i + 1] then
      f = false
    end
  end
  
  puts (f ? 'Good' : 'Bad')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int r;
  cin>>r;
  int ans;
  ans=r*r*3;
  cout<<ans<<"\n";

return 0;
}


Measured memory_bytes: 256
def check_prime(k):
    '''
    素数の時1、合成数の時0を返す
    '''
    if k == 1:return 0
    num = int(k ** 0.5 // 1)
    for i in range(2, num + 1):
        if k % i == 0:return 0
    return 1

n = int(input())
prime = []

for i in range(2, 55556):
    if check_prime(i):
        prime.append(i)

rec = [2]
ind = 1
for i in range(n - 1):
    while True:
        if prime[ind] % 5 == 1:
            rec.append(prime[ind])
            ind += 1
            break
        ind += 1

print(*rec)

Measured memory_bytes: 3444
#include<stdio.h>
int main(void){
   int h[100], fst, snd, trd, n, i;
   for(i = 0; i < 10; i++){
      scanf("%d", &h[i]);
   }
   fst = 0;
   snd = 0;
   trd = 0;
   for(i = 0; i < 10; i++){
      if(fst <= h[i]){
         trd = snd;
         snd = fst;
         fst = h[i];
      }else if(snd <= h[i]){
         trd = snd;
         snd = h[i];
      }else if(trd <= h[i]){
         trd = h[i];
      }
   }
   printf("%d\n%d\n%d\n", fst, snd, trd);
   return 0;
}

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


vector<ll> make_is_prime(int n) {
  vector<ll> ret(n,1);
  ret[0] = 0;
  for (int i = 1; i*2 <= n-1; i++) {
    // ret[i]++;
    for(int j = i*2; j <= n-1; j += i) {
      ret[j]++;
    }
  }
  return ret;
}

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
// ll divisor(long long n) {
//     ll ret = 0;
//     for (long long i = 1; i * i <= n; i++) {
//         if (n % i == 0) {
//             ret++;
//             if (i * i != n) ret++;
//         }
//     }
//     // sort(ret.begin(), ret.end()); // 昇順に並べる
//     return ret;
// }

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  // prime.resize(N);
  vector<ll> prime = make_is_prime(N);
  for (int i = 1; i < N; i++) {
    ans += prime[i];
  }
  // for (int ab = 1; ab <= N-1; ab++) {
  //   ll cnt = divisor(ab);
  //   ans += cnt;
  // }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11180
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int A,B;
int main(){
	cin>>A>>B;

	if(A==1)A=14;
	if(B==1)B=14;

	if(A==B)cout<<"Draw"<<endl;
	if(A>B)cout<<"Alice"<<endl;
	if(A<B)cout<<"Bob"<<endl;

	return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def check(n, nums):
    kind = set(nums)

    if len(kind) > 3:
        return False

    if len(kind) == 1 and 0 in kind:
        return True
    if n % 3 != 0:
        return False
    if len(kind) == 3:
        a, b, c = kind
        return nums.count(a) == nums.count(b) == nums.count(c) and a ^ b ^ c == 0
    elif len(kind) == 2:
        a, b = kind
        a_c, b_c = nums.count(a), nums.count(b)
        if 0 not in kind:
            return False
        elif n / 3 != nums.count(0):
            return False
        else:
            return True


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print("Yes" if check(n, a_list) else "No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 14688
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int d, t, s;
	cin >> d >> t >> s;
    if(d<=t*s) cout << "Yes" << "\n";
    else       cout << "No" << "\n";
	return 0;
}


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

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

    vector<string> s(n);
    for(int i=0; i<n; i++){
        cin >> s.at(i);
    }

    int m;
    cin >> m;
    
    vector<string> t(m);
    for(int i=0; i<m; i++){
        cin >> t.at(i);
    }

    int _max=0,tmp;

    for(int i=0; i<n; i++){
        tmp = 0;
        for(int j=i; j<n; j++){
            if(s.at(i) == s.at(j)){
                tmp++;
            }
        }
        for(int j=0; j<m; j++){
            if(s.at(i) == t.at(j)){
                tmp--;
            }
        }
        _max = max(_max, tmp);
    }

    cout << _max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,x,y,z,n,m;
	cin >> a >> b;
	x = a+b;
	y = a-b;
	z = a*b;
	n = max(x,y);
	m = max(n,z);
	cout << m;
	return 0;
} 

Measured memory_bytes: 256
N = int(input())

L = 1
R = 26
R0 = 0

while N > R:
    R0 = R
    L += 1
    R += 26**L

N2 = N - R0 - 1
S = []

for _ in range(L):
    N2,d = divmod(N2, 26)
    S.append(chr(d + 97))

print(''.join(reversed(S)))



Measured memory_bytes: 9184
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int a, b, k;
    cin >> k >> a >> b;
    rep(i, a, b + 1) {
        if(i % k == 0) {
            output("OK");
            return 0;
        }
    }
    output("NG");
    
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 100002;
ll fenv[N];
void fenvAdd(int p, ll val) {
	for(; p < N; p |= p + 1)
		fenv[p] += val;
}
ll fenvGet(int r) {
	ll res = 0;
	for(; r >= 0; r = (r & (r + 1)) - 1)
		res += fenv[r];
	return res;
}

struct Line {
	double A, B, C;

	Line() : A(), B(), C() {}
	Line(double _A, double _B, double _C) : A(_A), B(_B), C(_C) {}

	void scan() {
		scanf("%lf%lf%lf", &A, &B, &C);
	}

	bool operator < (const Line &L) const {
		return A / B < L.A / L.B;
	}

	double getY(double x) {
		return (C - A * x) / B;
	}
};

const double INF = 3e8;
const int IT = 70;
int n;
Line _a[N], a[N];
pair<double, int> b[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		a[i].scan();
	ll m = ((ll)n * (n - 1) / 2 + 1) / 2;
	
	sort(a, a + n);

	double l = -INF, r = INF;
	for (int it = 0; it < IT; it++) {
		double x = (l + r) / 2;
		ll cnt = 0;
		for (int i = 0; i < n; i++)
			b[i] = mp(a[i].getY(x), i);
		sort(b, b + n);
		for (int i = 0; i < N; i++)
			fenv[i] = 0;
		for (int i = 0; i < n; i++) {
			cnt += i - fenvGet(b[i].second);
			fenvAdd(b[i].second, 1);
		}
		if (cnt < m)
			l = x;
		else
			r = x;
	}
	printf("%.13lf ", r);

	
	for (int i = 0; i < n; i++) {
		swap(a[i].A, a[i].B);
	}
	sort(a, a + n);

	l = -INF, r = INF;
	for (int it = 0; it < IT; it++) {
		double x = (l + r) / 2;
		ll cnt = 0;
		for (int i = 0; i < n; i++)
			b[i] = mp(a[i].getY(x), i);
		sort(b, b + n);
		for (int i = 0; i < N; i++)
			fenv[i] = 0;
		for (int i = 0; i < n; i++) {
			cnt += i - fenvGet(b[i].second);
			fenvAdd(b[i].second, 1);
		}
		if (cnt < m)
			l = x;
		else
			r = x;
	}
	printf("%.13lf\n", r);

	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int64_t N;
    cin >> N;

    int64_t T, A;
    cin >> T >> A;
    while(--N) {
        int64_t t, a;
        cin >> t >> a;
        int64_t mul = max((T+t-1)/t, (A+a-1)/a);
        T = t*mul;
        A = a*mul;
    }

    cout << T+A << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long n,i,j,k,d[20],a;
  char s[20];
  scanf("%s",s);
  for(i=0;s[i];i++)d[i]=s[i]-'0';//printf("%d\n",i);
  for(j=a=0;j<(1<<(i-1));j++){
    n=d[0];
    for(k=0;k<i-1;k++){
      if(j&(1<<k))n=n*10+d[k+1];
      else{
	a+=n;//printf("%d\n",n);
	n=d[k+1];
      }
    }
    a+=n;
  }
  printf("%lld\n",a);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef map<int, int> MI;
typedef set<int> SI;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COUT(x) cout << (x) << endl

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


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

    int a, p; cin >> a >> p;
    int ans = (p + (a * 3)) / 2;
    COUT(ans);
}

Measured memory_bytes: 256
a,b,c,d=map(int,input().split())
n=int(input())
if n == 1:
  print(min(a*4,b*2,c))
elif n%2 == 0:
  print(min(a*4*n,b*2*n,c*n,d*n//2))
else:
  print(min(a*4*n,b*2*n,c*n,n//2*d+min(a*4,b*2,c)))


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

int main() {
  ll n;
  vector<int> temp(100);
  cin >> n;
  n--;
  if (n < (ll)26) {
    cout << (char)(n + 'a') << endl;
    return 0;
  }
  n -= (ll)26;
  if (n < (ll)26 * 26) {
    for (int i = 0; i < 2; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 1; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  n -= (ll)26 * 26;
  if (n < (ll)26 * 26 * 26) {
    for (int i = 0; i < 3; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 2; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  n -= (ll)26 * 26 * 26;
  if (n < (ll)26 * 26 * 26 * 26) {
    for (int i = 0; i < 4; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 3; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  n -= (ll)26 * 26 * 26 * 26;
  if (n < (ll)26 * 26 * 26 * 26 * 26) {
    for (int i = 0; i < 5; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 4; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  n -= (ll)26 * 26 * 26 * 26 * 26;
  if (n < (ll)26 * 26 * 26 * 26 * 26 * 26) {
    for (int i = 0; i < 6; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 5; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  n -= (ll)26 * 26 * 26 * 26 * 26 * 26;
  if (n < (ll)26 * 26 * 26 * 26 * 26 * 26 * 26) {
    for (int i = 0; i < 7; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 6; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  n -= (ll)26 * 26 * 26 * 26 * 26 * 26 * 26;
  if (n < (ll)26 * 26 * 26 * 26 * 26 * 26 * 26 * 26) {
    for (int i = 0; i < 8; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 7; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  n -= (ll)26 * 26 * 26 * 26 * 26 * 26 * 26 * 26;
  if (n < (ll)26 * 26 * 26 * 26 * 26 * 26 * 26 * 26 * 26) {
    for (int i = 0; i < 9; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 8; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  n -= (ll)26 * 26 * 26 * 26 * 26 * 26 * 26 * 26 * 26;
  if (n < (ll)26 * 26 * 26 * 26 * 26 * 26 * 26 * 26 * 26 * 26) {
    for (int i = 0; i < 10; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 9; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  n -= (ll)26 * 26 * 26 * 26 * 26 * 26 * 26 * 26 * 26 * 26;
  if (n < (ll)26 * 26 * 26 * 26 * 26 * 26 * 26 * 26 * 26 * 26 * 26) {
    for (int i = 0; i < 11; i++) {
      temp[i] = n % 26;
      n /= 26;
    }
    for (int i = 10; i >= 0; i--) {
      cout << (char)(temp[i] + 'a');
    }
    cout << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)(n); i++)
typedef long long int lli;
const lli inf = 1e18;

int main(){
    int n,k;
    cin >> n >> k;
    lli ans = 0;
    for(int a=1; a<=n; a++){
        if(2*a %k != 0) continue;
        lli sub = max(0, (int)floor((double)(n+a)/k) -(int)ceil((double)(1+a)/k) +1);
        sub *= max(0, (int)floor((double)(n-a)/k) -(int)ceil((double)(1-a)/k) +1);
        ans += sub;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256