akhauriyash/Code-Regression huggingface dataset:
/*  
    Through the fish-eyed lens of tear stained eyes
    I can barely define the shape of this moment in time
    And far from flying high in clear blue skies
    I'm spiralling down to the hole in the ground where I hide
    _________________________
    _________________________
    1032 Hours of Solitude
    Quarantine_Day : 43
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 1000

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

    int n; cin>>n;
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            if((i * 7 + j * 4) == n){
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No\n";

    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int main(){
	string input;
	int ang;
	double x,y;
	x=0;
	y=0;
	ang=90;
	do{
		cin>>input;
		if (input[0]!='0'){
			int h,k;
			int *p;
			h=0;
			k=0;
			p=&h;
			bool mi_flg=false;
			REP(i,input.length()){
				if (input[i]==','){
					p=&k;
				}
				else if (input[i]!='-'){
					*p*=10;
					*p+=input[i]-'0';
				}
				else{
					mi_flg=true;
				}
			}
			if (mi_flg){
				k*=-1;
			}
			x+=h*cos(ang/180.0*M_PI);
			y+=h*sin(ang/180.0*M_PI);
			ang-=k;
		}
	}while(input[0]!='0');
	cout<<(int)x<<endl<<(int)y<<endl;
}

Measured memory_bytes: 1184
use std::io;
use std::cmp::min;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("can't read");
	let mut iter = buf.split_whitespace();
	
	let n:u64 = match iter.next().unwrap().parse() {
		Ok(num) => num,
		_ => panic!("error"),
	};
	let a:u64 = match iter.next().unwrap().parse() {
		Ok(num) => num,
		_ => panic!("error"),
	};
	let b:u64 = match iter.next().unwrap().parse() {
		Ok(num) => num,
		_ => panic!("error"),
	};
	let mut ans = n/(a+b)*a;
	let rem = n%(a+b);
	ans += min(rem, a);
	println!("{}", ans);
}

Measured memory_bytes: 4352
import pprint

def buy():

    num_refrigerator, num_microwave, num_coupon = map(
        lambda x : int(x), input().split(" ")
    )

    price_list_refrigerator = list(map(lambda x : int(x), input().split(" ")))
    price_list_microwave = list(map(lambda x : int(x), input().split(" ")))

    coupon_list = []
    for _ in range(num_coupon):
        coupon_list.append(list(map(lambda x : int(x), input().split(" "))))

    # get price of most low price refrigerator and microwave.
    least_price = min(price_list_refrigerator) + min(price_list_microwave)

    for product in coupon_list:
        use_coupon_price = (price_list_refrigerator[product[0] - 1]
                        + price_list_microwave[product[1] - 1]
                        - product[2])
        if(least_price > use_coupon_price):
            least_price = use_coupon_price

    print(least_price)


if __name__ == "__main__":
    buy()

Measured memory_bytes: 39084
# AOJ 0015 National Budget

class Bigint
  MAX_DIGIT = 80

  attr_reader :digit_num

  def initialize(s = "0")
    raise ArgumentError, "Non-numeric character exists" if /[^0-9]/ =~ s

    @digit = Array.new(MAX_DIGIT, 0)

    s = s.sub(/^0+/, "").reverse

    if s.empty?
      # 0 と等しい場合
      @digit_num = 1
    else
      # 0 より大きい場合
      @digit_num = s.length
      raise OverflowError, "Given integer is too big" if @digit_num > MAX_DIGIT

      s.each_char.with_index {|c, i| @digit[i] = c.to_i}
    end
  end

  def to_s
    @digit[0..(@digit_num - 1)].reverse.join("")
  end

  def to_i
    result = 0
    d = 1

    @digit[0..(@digit_num - 1)].each_with_index do |x, i|
      result += x * d
      d *= 10
    end

    result
  end

  def +(bi)
    raise TypeError unless bi.is_a?(Bigint)

    new_digit = @digit.dup
    new_digit_num = [@digit_num, bi.digit_num].max

    add = lambda {
      rec = lambda {|i, x|
        return if x.zero?

        raise OverflowError, "Sum is too big" unless i < MAX_DIGIT

        new_digit_num = i + 1 unless i < new_digit_num

        result = new_digit[i] + x
        new_digit[i] = result % 10

        # 桁上り
        rec[i + 1, 1] if result > 9
      }
    }.call

    bi.digit_num.times do |i|
      add[i, bi.digit[i]]
    end

    new2(new_digit_num, new_digit)
  end

  protected
  def digit
    @digit
  end

  def digit=(d)
    @digit = d
  end

  def digit_num=(n)
    @digit_num = n
  end

  private
  def new2(digit_num, digit)
    that = Bigint.new

    that.digit_num = digit_num
    that.digit = digit

    that
  end

  class OverflowError < Exception
  end
end

n = gets.to_i
n.times do
  remained_lines = 2
  begin
    remained_lines -= 1
    x = Bigint.new(gets.chomp)
    remained_lines -= 1
    y = Bigint.new(gets.chomp)
    puts (x + y)
  rescue Bigint::OverflowError
    puts "overflow"
  ensure
    remained_lines.times {gets}
  end
end

Measured memory_bytes: 6264
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int H = scanner.nextInt();
        int W = scanner.nextInt();
        boolean[] is_remove_h = new boolean[W];
        boolean[] is_remove_w = new boolean[H];

        String[] as = new String[H];
        List<String> ans = new ArrayList<>();
        scanner.nextLine();
        for (int i = 0; i < H; i++) {
            as[i] = scanner.nextLine();
        }
        for (int i = 0; i < H; i++) {
            int count = 0;
            for (int j = 0; j < W; j++) {
                if (as[i].charAt(j) == '.') {
                    count++;
                }
            }
            if (count == W) is_remove_w[i] = true;
        }

        for (int i = 0; i < W; i++) {
            int count = 0;
            for (int j = 0; j < H; j++) {
                if (as[j].charAt(i) == '.') {
                    count++;
                }
            }
            if (count == H) is_remove_h[i] = true;
        }

        for (int i = 0; i < H; i++) {
            if (is_remove_w[i]) continue;
            for (int j = 0; j < W; j++) {
                if (is_remove_h[j]) continue;
                System.out.print(as[i].charAt(j));
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 25104
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var s = Console.ReadLine();
        var k = int.Parse(Console.ReadLine());
        for (int i = 'a'; k > 0; i++)
        {
            var list = new List<string>();
            for (int j = 0; j < s.Length; j++)
            {
                if (s[j] == i)
                {
                    for (int m = 0; m < k; m++)
                    {
                        if (j + m + 1 <= s.Length)
                        {
                            list.Add(s.Substring(j, m + 1));
                        }
                    }
                }
            }
            list = list.Distinct().OrderBy(st => st).ToList();
            if (list.Count() >= k)
            {
                Console.WriteLine(list[k - 1]);
                k -= list.Count();
            }
            else
            {
                k -= list.Count();
            }
        }
    }
}

Measured memory_bytes: 13664
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
struct edge {int to, cap, rev;};
const int MAX_V = 120;
vector <edge> G[MAX_V];
bool used[MAX_V];
void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, (int)G[to].size()} );
    G[to].push_back((edge){from, 0, (int)G[from].size()-1});
}

int dfs(int v, int t, int f){
    if(v==t) return f;
    used[v] = true;
    for(int i=0;i<G[v].size();i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f,e.cap));
            if(d>0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        memset(used, 0, sizeof(used));
        int f = dfs(s,t,INF);
        if(f == 0) return flow;
        flow += f;
    }
}
signed main(void){
    int V,E; cin>>V>>E;
    rep(i, E){
        int u,v,c; cin>>u>>v>>c;
        add_edge(u,v,c);
    }
    cout<<max_flow(0, V-1)<<endl;
}



Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX=6000;
int p=998244353;
int main()
{
  long long a,b,c,d,n,x,y,i,j;
  long long s[N_MAX],sb[N_MAX],sc[N_MAX];
  cin >> a >> b >> c >> d;
  n=(c+d)-(a+b);
  fill(sb,sb+N_MAX,0);
  fill(sc,sc+N_MAX,0);
  sb[0]=1;
  s[0]=1;
  for(i=1;i<=n;i++){
    for(j=0;j<=i;j++){
      x=a+i-j;
      y=b+j;
      if(x>c) continue;
      if(y>d) break;
      if(j==0){
        s[0]=sb[0]*y;
      }else if(j==i){
        s[j]=sb[j-1]*x;
      }else{
        s[j]=sb[j]*y+sb[j-1]*x-sc[j-1]*(x-1)*(y-1);
      }
      s[j]%=p;
      if(s[j]<0)
        s[j]+=p;
    }
    copy(sb,sb+N_MAX,sc);
    copy(s,s+N_MAX,sb);
  }
  cout << s[d-b] << endl;
  return 0;
}

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

int N;
int store[55];

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++) scanf("%d", &store[i]);
    sort(store, store+N);

    double ans = store[0];
    for (int i = 1; i < N; i++) {
        ans = (ans + (double)store[i]) / 2.0;

    }

    printf("%f\n", ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	
    Scanner sc =new Scanner(System.in);
    
    int n=sc.nextInt();int a[]=new int[10];
    for(int j=0;j<n;j++){
    	int b=0; int c=0;
    	String ans="YES";
    	for(int i=0;i<10;i++) a[i]=sc.nextInt(); 
    	for(int i=0;i<10;i++){
    
    		if(a[i]>b){
    			b=a[i];
    		}else if(a[i]>c){
    			c=a[i];
    		}else{
    			ans="NO";
    			break;
    		}
    	}
    	System.out.println(ans);
    }

    }
    
}

Measured memory_bytes: 25984
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    int a, b, co = 0;
    cin >> a >> b;
    int ara[a];
    for(int i = 0 ; i < a ; i++) cin >> ara[i];
    
    for(int i = 0 ; i < a ; i++){
        if(ara[i] >= b)
            co++;
    }
    cout << co << endl;

    return 0;
}


Measured memory_bytes: 4020
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    cout << fixed << setprecision(15);

    long double n, k;
    cin >> n >> k;

    long double ans = 0;
    for(int i = 1; i <= n; i++) {
        int score = i;
        int cnt = 0;
        while(score < k) {
            score *= 2.0;
            cnt++;
        }
        ans += pow(0.50, cnt) / n;
    }

    cout << ans << endl;

    return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  ll K;
  scanf("%lld",&K);
  vector<ll> x(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&x[i]);
  }
  ll ans=0;
  for (int i=0; i<N; i++) {
    ans += min(x[i]*2, (K-x[i])*2);
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
//皆さん、第9回シンデレラガール総選挙は、トップでオンリーワンを目指す城ヶ崎美嘉に
//そしてボイスアイドルオーディションは、プログラミングが趣味の才女大石泉に、ぜひ投票をお願いします！
//#城ヶ崎美嘉を009のシンデレラに
//#大石泉の必勝プログラム
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int a,b,c,d;cin>>a>>b>>c>>d;
	int x=(c+b-1)/b,y=(d+a-1)/d;
	if(x>y) cout<<"No"<<endl;else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3632
#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>;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 0;
    ll p = a[0];
    for (int i = 1; i < n; i++) {
        ll f = 0;
        if (p > a[i]) f = p-a[i];
        else f = 0;
        p = a[i]+f;
        ans += f;
    }
    cout << ans << endl;
    return 0;
}


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

# selectionSortの処理
count = 0
for i in range(0, N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    A[i], A[minj] = A[minj], A[i]
    if i != minj:
        count += 1
print(*A)
print(count)



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

struct Line {
	mutable ll k, m, p;
	bool operator<(const Line& o) const { return k < o.k; }
	bool operator<(ll x) const { return p < x; }
};
 
struct LineContainer : multiset<Line, less<>> {
	// (for doubles, use inf = 1/.0, div(a,b) = a/b)
	const ll inf = LLONG_MAX;
	ll div(ll a, ll b) { // floored division
		return a / b - ((a ^ b) < 0 && a % b); }
	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = inf; return false; }
		if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
		else x->p = div(y->m - x->m, x->k - y->k);
		return x->p >= y->p;
	}
	void add(ll k, ll m) {
		auto z = insert({k, m, 0}), y = z++, x = y;
		while (isect(y, z)) z = erase(z);
		if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while ((y = x) != begin() && (--x)->p >= y->p)
			isect(x, erase(y));
	}
	ll query(ll x) {
		assert(!empty());
		auto l = *lower_bound(x);
		return l.k * x + l.m;
	}
};

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  ll c;
  cin >> n >> c;
  vector<int> h(n);
  for(int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  vector<ll> dp(n);
  LineContainer lc;
  lc.add(2ll * h[0], -dp[0] - 1ll * h[0] * h[0]);
  for(int i = 1; i < n; ++i) {
    dp[i] = 1ll * h[i] * h[i] + c - lc.query(h[i]);
    lc.add(2ll * h[i], -dp[i] - 1ll * h[i] * h[i]);
  }
  cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 15104
def main():
    H, W = map(int, input().split())
    a = [input() for _ in range(H)]

    show_r = []
    show_c = []

    for r, row in enumerate(a):
        show_r.append(any(c == '#' for c in row))

    for c, col in enumerate(zip(*a)):
        show_c.append(any(c == '#' for c in col))

    ans = []
    for r in range(H):
        t = ''
        for c in range(W):
            if show_r[r] and show_c[c]:
                t += a[r][c]
        if t:
            ans.append(t)

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>

using namespace std;

char A[101],B[101],C[101];
int main()
{
    int a,b,c;
    int la,lb,lc;
    while(cin>>A>>B>>C){
        int tmp;
        la=strlen(A),lb=strlen(B),lc=strlen(C);
        tmp=1,a=b=c=-1;
        while(1){
            if(a==la){
                cout<<"A"<<endl;
                break;
            }
            else if(b==lb){
                cout<<"B"<<endl;
                break;
            }
            else if(c==lc){
                cout<<"C"<<endl;
                break;
            }
            if(tmp==1){
                a++;
                tmp=A[a]-'a'+1;
            }
            else if(tmp==2){
                b++;
                tmp=B[b]-'a'+1;

            }
            else if(tmp==3){
                c++;
                tmp=C[c]-'a'+1;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
#include <map>
#include <algorithm>

using namespace std;

string str;
int ps;
map<char, int> mpp;

int formula()
{
  int v, u;
  if(isalpha(str[ps])){
    return mpp[str[ps++]];
  } else if(isdigit(str[ps])){
    return (int)(str[ps++]-'0');
  } else if(str[ps] == '-'){
    ++ps;
    return (2-formula());
  } if(str[ps] == '('){
    ++ps;

    v = formula();
    char ch = str[ps++];
    u = formula();
    ++ps;

    if(ch == '*') v = min(v, u);
    else v = max(v, u);
  }

  return v;
}

int solve(int p, int q, int r)
{
  int res;
  ps = 0;
  mpp['P'] = p;
  mpp['Q'] = q;
  mpp['R'] = r;

  res = formula();

  mpp.clear();
  return res;
}

int main()
{
  int cnt;

  while(cin>>str && str != "."){
    cnt = 0;

    for(int i = 0; i < 3; ++i)
      for(int j = 0; j < 3; ++j)
        for(int k = 0; k < 3; ++k)
          if(solve(i, j, k) == 2) ++cnt;

    cout << cnt << endl;
  }

  return 0;
}

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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int n, h, w;

int main() {
	scanf("%d %d %d", &n, &h, &w);
	printf("%d\n", (n-h+1) * (n-w+1));
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	fmt.Println(logic(a, b, c))
}

func logic(a, b, c int) int {
	if a == b {
		return c
	}

	if a == c {
		return b
	}

	return a
}

Measured memory_bytes: 512
S = list(map(str, input()))
ctr = [0 for _ in range(3)]

for s in S:
  if s == "a":
    ctr[0] = 1
  elif s == "b":
    ctr[1] = 1
  else:
    ctr[2] = 1
    
if sum(ctr) == 3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;

int main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    vector<int> L(M),R(M);
    rep(i,M){
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    }
    vector<vector<int>> ans(N,vector<int>(N,0));
    rep(i,M){
        ans[0][R[i]]++;
        if (L[i]<N-1){
            ans[L[i]+1][R[i]]--;
        }
    }
    rep(i,N){
        rep(j,N-1){
            ans[j+1][i]+=ans[j][i];
        }
    }
    rep(i,N){
        rep(j,N-1){
            ans[i][j+1]+=ans[i][j];
        }
    }
    rep(i,Q){
        int p,q;
        cin >> p >> q;
        cout << ans[p-1][q-1] << endl;
    }
}

Measured memory_bytes: 3456
#include<iostream>
#include<functional>
#include<vector>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
using ll =long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(i) i.begin(),i.end()
template<typename T=ll>
using v =vector<T>;
template<typename T=ll>
using vv = vector<v<T>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
const ll INF = (ll)1e9;
const ll MOD = INF+7;
template<typename T> T chmin(T &a,T b){a=min(a,b);}
template<typename T> T chmax(T &a,T b){a=max(a,b);}

int main(){
    ll n;     cin >> n;
    string s; cin >> s;

    ll ans=1;
    ans*=count_if(all(s),[](const char c){return c=='R';});
    ans*=count_if(all(s),[](const char c){return c=='G';});
    ans*=count_if(all(s),[](const char c){return c=='B';});
    
    for(int j=1;j<n-1;j++){
        for(int len=1;;len++){
          	int i=j-len;
          	int k=j+len;
          	if(i<0||k>=n) break;
            if(s[i]!=s[j]&&s[i]!=s[k]&&s[j]!=s[k]){
                ans--;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int a[1010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) cin >> a[i];

  int m = -1;
  REP(i, n) FOR(j, i+1, n) {
    //cout << a[i] << " " << a[j] << " " << a[i]*a[j] << endl;
    if(m < a[i] * a[j]) {
      int tmp = a[i]*a[j];
      string b = to_string(tmp);
      //cout << a << endl;
      bool f = true;
      FOR(i, 1, b.size()) {
        if(b.size() >= 2 && b[i] != b[i-1]+1) f = false;
      }
      if(f) m = a[i]*a[j];
    }
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i;
  cin>>n;
  vector<int> a(n),b(n);
  for(i=0;i<n;i++) cin>>a.at(i)>>b.at(i);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  if(n%2==1) cout<<b.at((n-1)/2)-a.at((n-1)/2)+1<<endl;
  else if(n%2==0) cout<<b.at(n/2-1)+b.at(n/2)-a.at(n/2-1)-a.at(n/2)+1<<endl;
}

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

const long long MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    long long a[m];

    for(int j = 0; j < m; j++) cin >> a[j];

    int j = 0;
    long long ans[n + 1];
    ans[0] = 1;
    if(a[0] == 1) {
        ans[1] = 0;
        j++;
    }
    else ans[1] = 1;

    for(long long i = 2; i <= n; i++) {
        if(j < m && i == a[j]) { 
            ans[i] = 0;
            j++;
        }
        else ans[i] = (ans[i - 2] + ans[i - 1]) % MOD;
        // cout << i << ": " << ans[i] << endl;
    }

    cout << ans[n] << endl;

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using console = System.Console;

namespace AtCoderTemplate
{
    public class App
    {
        public static void Main(string[] args)
        {
            var p = console.ReadLine().Split().Select(i=>int.Parse(i)).ToArray();
            console.WriteLine(Math.Min(p[0]+p[1]+1,p[2])+p[1]);
        }
    }
}

Measured memory_bytes: 13268
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

table = [[0] * (W+1) for i in range(N+1)]

for i in range(1, N+1):
  for j in range(1, W+1):
    if(j - wv[i-1][0] >= 0):
      table[i][j] = max(table[i-1][j], table[i-1][j - wv[i-1][0]] + wv[i-1][1])
    else:
      table[i][j] = table[i-1][j]

print(table[N][W])


Measured memory_bytes: 151612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {

char inp[100];
int i;
int year;
double nm;
int c,j,count;
char str[100]={'\0'};
char *ln;

fgets(str, 100, stdin); // 入力："123456\n"
ln = strchr(str, '\n'); /* 改行文字を検索 */
if (ln != NULL) { /* 改行が読み取られていたかどうか */
   *ln = '\0';    /* 改行文字を終端文字に置き換える */
}
else {            /* 入力ストリーム上に文字が残ってる場合 */
   while (1) {    /* 改行文字が読み取られるまで空読みする */
       c = getchar();
      if (c == '\n' || c == EOF) break;
   }
}

//printf("%s\n",str);



//double sum=0;

//sscanf(str, "%d", &year);
//printf("%d\n",year);

//for(i=1;i<=year;i++){




//fgets(str, 100, stdin); // 入力："123456\n"
//ln = strchr(str, '\n'); /* 改行文字を検索 */
//if (ln != NULL) { /* 改行が読み取られていたかどうか */
//   *ln = '\0';    /* 改行文字を終端文字に置き換える */
//}
//else {            /* 入力ストリーム上に文字が残ってる場合 */
//   while (1) {    /* 改行文字が読み取られるまで空読みする */
//       c = getchar();
//      if (c == '\n' || c == EOF) break;
//   }
//}

//printf("%s\n",str);



int a,b;

 sscanf(str, "%d %d %d", &a, &b, &c);

//printf("%d\n",a);
//printf("%d\n",b);
//printf("%d\n",c);

int d;

d=b/a;

if(d>=c)
	printf("%d\n",c);
else
	printf("%d\n",d);

//if(strcmp(inp,"JPY")==0)
//	sum=sum+nm;
//else
//	sum=sum+nm*380000.0;


//}
//printf("%lf\n",sum);

    return 0;
}


Measured memory_bytes: 128
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var WHxy = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var W = WHxy[0];
        var H = WHxy[1];
        var x = WHxy[2];
        var y = WHxy[3];
        Console.WriteLine($"{W * H / 2.0} {(W == 2 * x && H == 2 * y ? 1 : 0)}");
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        //        String s = sc.next();

        boolean ans = false;

        //        for (int i = 0; i < n; i++) {
        //
        //        }

        if (1200 <= n)
            ans = true;

        sc.close();

        System.out.println(ans ? "ARC" : "ABC");
        //        System.out.println(ans ? "Yes" : "No");

    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long N) {
  vl ans;
  while (N > 0) {
    ll i = 0;
    for (i = ceil(sqrt((double)N * 2)); i >= 0; i--) {
      if (i * (i + 1) < 2 * N) {
        i++;
        break;
      }
    }
    N -= i;
    ans.push_back(i);
  }

  sort(all(ans));
  for (ll a : ans) {
    print(a);
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define fi first
#define se second
int main()
{
	SPEED
	int n, m, u, v;
	cin >> n >> m;

	vector<vector<int>> adj(n+1);

	for (int i = 0; i < m; ++i)
	{
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	vector<int> parent(n+1, -1);
	vector<int> visited(n+1, 0);

	queue<int> q;
	q.push(1);
	visited[1] = 1;

	while(!q.empty())
	{
		int u = q.front();
		q.pop();

		for (int i = 0; i < adj[u].size(); ++i)
		{
			if (visited[adj[u][i]] == 0 )
			{
				visited[adj[u][i]] = 1;
				q.push(adj[u][i]);
				parent[adj[u][i]] = u;
			}
		}
	}


	bool not_possible = false;
	for (int i = 2; i <= n; ++i)
	{
		if (parent[i] == -1)
		{
			not_possible = true;
			break;
		}
	}


	if (not_possible)
	{
		cout << "No";
		return 0;
	}

	cout << "Yes\n";
	for (int i = 2; i <= n; ++i)
	{
		cout << parent[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 10540
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

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

    if(a-b > c)cout << 0 << endl;
    else cout << c-a+b << endl;

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc136.contest.atcoder.jp/tasks/abc136_b


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

int main(){
  int n; 
  cin >> n;
  vi p(n), q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  int a=0, b=0;
  do{
    a++;
  }while(next_permutation(p.begin(),p.end()));
  do{
    b++;
  }while(next_permutation(q.begin(),q.end()));
  cout << abs(a-b) << endl;
}


Measured memory_bytes: 3616
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        String t=sc.next();
        int ans=0;
        for(int i=0;i<3;i++){
            if(s.charAt(i)==t.charAt(i))ans++;
        }
        System.out.println(ans);
    }


}


Measured memory_bytes: 21844
fun main() {
    val (n, k) = nextIntList()
    val prices = nextIntList().sorted()
    println(prices.subList(0, k).sum())
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }


Measured memory_bytes: 40716
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      Map<Integer, Integer> freq = new HashMap<>();
      for(int i = 0; i < n; i++){
        int num = sc.nextInt();
        freq.put(num, freq.getOrDefault(num, 0) + 1);
      }
      int cnt = 0;
      ArrayList<Integer> vals = new ArrayList<>(freq.values()); 
      Collections.sort(vals, Collections.reverseOrder());
      for(int i = k; i < vals.size(); i++)
        cnt += vals.get(i);
      System.out.println(cnt);
  }
}

Measured memory_bytes: 101508
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	string n;
	cin >> n;
	ll sum=0;
	for(ll i=0; i<n.size(); i++){
		sum+=n[i]-'0';
	}
	if(sum%9)
		cout<<"No"<<endl;
	else 
		cout<<"Yes"<<endl;
	return 0;	
}


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

#define int int_fast64_t

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  double n; cin >> n;
  double s = n/3;
  cout << fixed << setprecision(100) << s*s*s << '\n';
}



Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

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

	for(int i = 1; i<= n; i++)
	{
		if(i%3 == 0){
			printf(" %d",i);
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
			}while(x);
		}
	}
	printf("\n");
}



Measured memory_bytes: 2676
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

int main() {
    int w, h; cin >> w >> h;
    vector<pair<int, int>> edge_w{};
    int wgt;
    for(int i=0; i<w; i++){
        cin >> wgt;
        edge_w.push_back(pair<int, int>{wgt, 0});
    }
    for(int i=0; i<h; i++){
        cin >> wgt;
        edge_w.push_back(pair<int, int>{wgt, 1});
    }
    sort(edge_w.begin(), edge_w.end(), 
         [](pair<int,int>& x, pair<int,int>& y){return x.first < y.first;});
    // for(auto& v:edge_w){
    //     cout << v.first << " " << v.second << endl;
    // }
    ll ans = 0;
    w++; h++;
    for(auto& v:edge_w){
        if(v.second == 0){
            ans += 1LL * h * v.first;
            w--;
        }
        else{
            ans += 1LL * w * v.first;
            h--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3444
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[][] a = new int[3][3];
		int i,j,k,b;
		String ans = "No";
		for(i = 0;i < 3;i++){
			for(j = 0;j < 3;j++){
				a[i][j] = sc.nextInt();
			}
		}
		int N = sc.nextInt();
		for(i = 0;i < N;i++){
			b = sc.nextInt();
			for(j = 0;j < 3;j++){
				for(k = 0;k < 3;k++){
					if(a[j][k] == b){
						a[j][k] = 0;
					}
				}
			}
		}
		if((a[0][0] + a[1][1] + a[2][2]) == 0 || (a[0][2] + a[1][1] + a[2][0]) == 0){
			ans = "Yes";
		}else{
			for(i = 0;i < 3;i++){
				if((a[i][0] + a[i][1] + a[i][2]) == 0 || (a[0][i] + a[1][i] + a[2][i]) == 0 ){
					ans = "Yes";
					break;
				}else{
				ans = "No";
				}
			}
		}
		System.out.println(ans);
	}
}

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

int main(){
    
    int H, W;
    
    
    
    while(true){
        
        cin >> H >> W;
        
        if(H == 0 && W == 0) break;
        
        for(int i = 0; i < H; ++i){
            
            for(int k = 0; k < W; ++k){
                
                if(i % 2 == 1 && k % 2 == 1) cout << "#";
                
                if(i % 2 == 0 && k % 2 == 0) cout << "#";
                
                if(i % 2 == 1 && k % 2 == 0) cout << ".";
                
                if(i % 2 == 0 && k % 2 == 1) cout << ".";
            }
            
            cout << endl;
        }
        
        cout << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int a,b,c,x,y;

void input(){
    cin >> a >> b >> c >> x >> y;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int ans = INF;
    for(int i=0;i<=100000;i++) ans = min(ans,2*c*i+max(0,x-i)*a+max(0,y-i)*b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
line = gets.to_i

if line >= 400 && line <= 599
  puts 8
elsif line >= 600 && line <= 799
  puts 7
elsif line >= 800 && line <= 999
  puts 6
elsif line >= 1000 && line <= 1199
  puts 5
elsif line >= 1200 && line <= 1399
  puts 4
elsif line >= 1400 && line <= 1599
  puts 3
elsif line >= 1600 && line <= 1799
  puts 2
elsif line >= 1800 && line <= 1999
  puts 1
end

Measured memory_bytes: 14368
//15
#include<iostream>
#include<vector>

#define MS(X) ((X/2)*7+((X%2)?6:1))

using namespace std;

int main(){
  bool mcmp[300000]={};
  vector<int> mspf;
  for(int i=1;MS(i)<300000;i++){
    if(!mcmp[MS(i)]){
      mspf.push_back(MS(i));
      for(int j=1;MS(i)*MS(j)<300000;j++){
	mcmp[MS(i)*MS(j)]=true;
      }
    }
  }
  for(int n;cin>>n,n!=1;){
    cout<<n<<':';
    for(int i=0;i<mspf.size();i++){
      if(n%mspf[i]==0){
	cout<<' '<<mspf[i];
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1644
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

n,m = mii()

arr=[[] for i in range(n)]
deg=[0 for i in range(n)]
dp = [0]*(n+1)


for i in range(m):
    x,y = mii()
    arr[x-1].append(y-1)
    deg[y-1]+=1

# V: 頂点数
# G[v] = [w, ...]:
#    有向グラフ上の頂点vから到達できる頂点w
# deg[v]:
#    頂点vに到達できる頂点の数

ans = list(i for i in range(n) if deg[i]==0)
deq = deque(ans)
used = [0]*m

while deq:
    v = deq.popleft()
    for t in arr[v]:
        deg[t] -= 1
        if deg[t]==0:
            deq.append(t)
            ans.append(t)
#print(ans)
# ans: トポロジカル順序に並べた頂点

#ans：遷移前
for i in ans:
    ari = arr[i]
    #j：遷移後の座標を出す
    for j in range(len(ari)):
        dp[ari[j]] = max(dp[i]+1,dp[ari[j]])
    
print(max(dp))






Measured memory_bytes: 88108
n,k,q=map(int,input().split())
need=q-k+1
anstimes=[0 for i in range(n)]
if k>q:
  for i in range(n):
    print("Yes")
else:
  L = [int(input()) for i in range(q)]
  anstimes=[0 for i in range(n)]
  for i in range(q):
    anstimes[L[i]-1]+=1
  for i in range(n):
    if anstimes[i]>=need:
      print("Yes")
    else:
      print("No")
  

Measured memory_bytes: 8644
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2'005;
const int MOD = 1000000007;
void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}
int ans[MAXN];
int main(){
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j){
            int t=min(j-i,1+abs(i-x)+abs(j-y));
            ++ans[t];
        }
    }
    for(int i=1;i<=n-1;++i){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    ll S;
    cin >> S;
    ll x1, x2, x3, y1, y2, y3;
    x1 = 0; y1 = 0;
    ll j = (ll)sqrt(S);
    if (j*j < S) j++;
    x3 = j; y2 = j;
    while (true) {
        ll k = x3*y2 - S;
        y3 = 1;
        x2 = k;
        for (ll i=(ll)sqrt(k)+1;i>1;i--) {
            if (k%i==0) {
                y3 = i;
                x2 = k/i;
                break;
            }
        }
        if (x2 <= 1000000000 && y3 <= 1000000000) break;
        else {
            x3++; y2++;
        }
    }
    printf("%lld %lld %lld %lld %lld %lld\n", x1, y1, x2, y2, x3, y3);

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
string s[101];
string t[101];
int main(void)
{
    int n,m;
    cin >> n ;

    for(int i=0;i<n;i++){
        cin >> s[i];
    }

    cin >> m;
    for(int j=0;j<m;j++){
       cin >> t[j];
    }

    int mval = 0,val = 0;
    string a;
    for(int i=0;i<n;i++){
        val = 0;
        a = s[i];
        for(int j=0;j<n;j++){if(a == s[j]) val++;}
        for(int j=0;j<m;j++){if(a == t[j]) val--;}
        mval = max(val,mval);
    }

    cout << mval;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	int64 hh, ww, cx, cy, dx, dy, tmpx, tmpy;
	int64 xfil[] = {-1, 1, 0, 0}, yfil[] = {0, 0, -1, 1};
	cin >> hh >> ww >> cx >> cy >> dx >> dy;
	cx--;
	cy--;
	dx--;
	dy--;
	int64 table[hh][ww];
	bool memo[hh][ww];
	string ss;
	for(int64 ii = 0;ii < hh;ii++)
	{
		cin >> ss;
		for(int64 jj = 0;jj < ww;jj++)
		{
			memo[ii][jj] = false;
			table[ii][jj] = 100000000;
			if(ss[jj] == '.')
			{
				memo[ii][jj] = true;
			}
		}
	}
	
	deque<pair<int64, int64>> deq;
	deq.push_back(make_pair(cx, cy));
	table[cx][cy] = 0;
	while(!deq.empty())
	{
		tmpx = deq.front().first;
		tmpy = deq.front().second;
		deq.pop_front();
		for(int64 ii = 0;ii < 4;ii++)
		{
			if(tmpx + xfil[ii] >= 0 && tmpx + xfil[ii] < hh && tmpy + yfil[ii] >= 0 && tmpy + yfil[ii] < ww)
			{
				if(table[tmpx][tmpy] < table[tmpx + xfil[ii]][tmpy + yfil[ii]] && memo[tmpx + xfil[ii]][tmpy + yfil[ii]])
				{
					deq.push_front(make_pair(tmpx + xfil[ii], tmpy + yfil[ii]));
					table[tmpx + xfil[ii]][tmpy + yfil[ii]] = table[tmpx][tmpy];
				}
			}
		}
		for(int64 ii = -2;ii <= 2;ii++)
		{
			for(int64 jj = -2;jj <= 2;jj++)
			{
				if(ii == 0 && jj == 0)
				{
					continue;
				}
				if(tmpx + ii >= 0 && tmpx + ii < hh && tmpy + jj >= 0 && tmpy + jj < ww)
				{
					if(table[tmpx][tmpy] + 1 < table[tmpx + ii][tmpy + jj] && memo[tmpx + ii][tmpy + jj])
					{
						deq.push_back(make_pair(tmpx + ii, tmpy + jj));
						table[tmpx + ii][tmpy + jj] = table[tmpx][tmpy] + 1;
					}
				}
			}
		}
	}
	if(table[dx][dy] == 100000000)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << table[dx][dy] << endl;
	}
	return 0;
}

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

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a =new int[n];
		for(int i = 0;i < n;i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);

		int max = 0;
		int min = 0;
		long ans = 0;
		int center = (a[n-1]+1)/2;

		int mm = 0;				//i/2に近い値
		if(Math.abs(center-a[lowerbond(center,a)]) < Math.abs(center-a[Math.max(lowerbond(center,a)-1,0)])){
			mm = a[lowerbond(center,a)];
		}else{
			mm =a[Math.max(lowerbond(center,a)-1,0)];
		}
		//System.out.println(a[lowerbond(center,a)]);
		max = a[n-1];
		min = mm;

		System.out.println(max + " "+min);




	}
	static int lowerbond(int k, int[] data){		//kより小さい最小の値をdataの中から探し、返す二分探索
		int min = -1;
		int max = data.length;

		while(max-min > 1){
			int mid = (max+min)/2;
			if(data[mid] >= k){
				max = mid;
			}else{
				min = mid;
			}
		}
		return max;
	}





}

class UnionFind{
	int[] parent;
	public UnionFind(int N){
		this.parent = new int[N];
		for(int i = 0; i < N;i++){
			parent[i] = i;
		}
	}
	public int root(int x){			//根要素を取得
		if(parent[x] == x){			//初期状態
			return x;
		}else{
			return parent[x] = root(parent[x]);    	//再帰によって根を取得
		}
	}
	public void unite(int x,int y){ 	//統合メソッド
		if(same(x,y)){					//同じ根なら終了
			return;
		}
		int xroot = root(x);
		int yroot = root(y);
		parent[xroot] = yroot;			//統合
		return;

	}

	public boolean same(int x,int y){			//根が同じか（同じグループに属しているか）を判定
		return(root(x) == root(y));
	}
}



class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 50528
/*Rooted Trees*/

#include <iostream>
#include <cstdio>
#define MAX 100005
#define NIL -1
using namespace std;

struct Node {
    int parent;
    int left;
    int right;
};

Node Tree[MAX];
int D[MAX];

void print(int u) {
    printf("node %d: ",u);
    printf("parent = %d, ",Tree[u].parent);
    printf("depth = %d, ",D[u]);
    if (Tree[u].parent==NIL) {
        printf("root, ");
    } else if (Tree[u].left==NIL) {
        printf("leaf, ");
    } else {
        printf("internal node, ");
    }
    printf("[");
    int c;
    for (int i=0,c=Tree[u].left; c!=NIL; i++,c=Tree[c].right) {
        if (i) {
            printf(", ");
        }
        printf("%d",c);
    }
    printf("]\n");
}
int rec(int u,int p) {
    D[u]=p;
    if (Tree[u].right!=NIL) {
        rec(Tree[u].right,p);
    }
    if (Tree[u].left!=NIL) {
        rec(Tree[u].left,p+1);
    }
}
int main() {
    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        Tree[i].parent=Tree[i].left=Tree[i].right=NIL;
    }
    for (int i=0; i<n; i++) {
        int v, d;
        cin >> v >> d;
        int l;
        for (int j=0; j<d; j++) {
            int c;
            cin >> c;
            if (j==0) {
                Tree[v].left=c;
            } else {
                Tree[l].right=c;
            }
            l=c;
            Tree[c].parent=v;
        }
    }
    int r;
    for (int i=0; i<n; i++) {
        if (Tree[i].parent==NIL) {
            r=i;
        }
    }
    rec(r,0);
    for (int i=0; i<n; i++) {
        print(i);
    }
    return 0;
}

Measured memory_bytes: 7712
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a > x || a + b < x)cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 256
def main() :
    a, b, c = map(int, input().split())
    if a == b and a != c or a == c and a != b or b == c and a != b :
        print("Yes")
        
    else :
        print("No")
        
    

if __name__ == '__main__':
    import sys;
    try:
        main(sys.argv)
    except TypeError:
        main()

Measured memory_bytes: 2940