akhauriyash/Code-Regression huggingface dataset:
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		if(a > 0) System.out.println("Positive");
		else if(b < 0){
			if((b - a + 1) % 2 == 0) System.out.println("Positive");
			else System.out.println("Negative");
		}else System.out.println("Zero");
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22484
//shara's here
//私は大きな男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
#include <bits/stdc++.h>
using namespace std;
//fold
typedef double w;
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
	s ss,dd;
	cin>>ss>>dd;
	int a,b;
	cin>>a>>b;
	s t;
	cin>>t;
	if(t==ss)a--;
	else if(t==dd)b--;
	cout<<a<<' '<<b<<endl;
  return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cins(int, 9, a);
    Cin(int, n);
    Rep(n){
        Cin(int, x);
        For(i, 9) if(a[i] == x) a[i] = -1;
    }
    CoutYn(
        (a[0] == -1 && a[1] == -1 && a[2] == -1) ||
        (a[3] == -1 && a[4] == -1 && a[5] == -1) ||
        (a[6] == -1 && a[7] == -1 && a[8] == -1) ||
        (a[0] == -1 && a[3] == -1 && a[6] == -1) ||
        (a[1] == -1 && a[4] == -1 && a[7] == -1) ||
        (a[2] == -1 && a[5] == -1 && a[8] == -1) ||
        (a[0] == -1 && a[4] == -1 && a[8] == -1) ||
        (a[2] == -1 && a[4] == -1 && a[6] == -1)
    );
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
#define endl '\n'
const ld PI=3.14159265358979;
#define w(x) int x;cin>>x;while(x--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vll vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define F first
#define S second 
#define LB lower_bound
#define UB upper_bound
#define mset multiset
#define uset unordered_set
#define umap unordered_map
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll x, ll y, ll p){  ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;}return res;}  
ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a % b); } 
bool parity(ll x,ll y){ bool f = ((x ^ y) < 0);return !f;}

int main()
{
    IOS
    set<ll> set1;
    set<ll> set2;
    set<ll> set3;
    set1.insert(2);
    set1.insert(4);
    set1.insert(5);
    set1.insert(7);
    set1.insert(9);
    set2.insert(0);
    set2.insert(1);
    set2.insert(6);
    set2.insert(8);
    set3.insert(3);
    ll n;
    cin>>n;
    ll ans=n%10;
    if(set1.find(ans)!=set1.end())
    {
        cout<<"hon"<<endl;
    }
    else if(set2.find(ans)!=set2.end())
    {
        cout<<"pon"<<endl;
    }
    else
    {
        cout<<"bon"<<endl;
    }
    
    return 0;  
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>

int max(int a, int b)
{
  if (a>b) return a;
  else return b;
}
int min(int a, int b)
{
  if (a<b) return a;
  else return b;
}
 
int main()
{
  int n, x, y;
  scanf("%d %d %d", &n, &x, &y);

  int d1[n+1][n+1], d2[n+1][n+1], d[n+1][n+1];
  int c[n+1];
  for(int i=0;i<n+1;i++){
    for(int j=0;j<n+1;j++){
      d1[i][j]=0; d2[i][j]=0; d[i][j]=0;
    }
  }
  for(int i=0; i<n+1; i++) c[i]=0;
  
  //d1
  for(int i=1; i<n; i++) d1[i][i+1]=1;
  for(int i=1; i<n+1; i++){
    for(int j=i+2; j<n+1; j++){
      d1[i][j]=d1[i][j-1]+1;
    }
  }

  //d2
  d2[x][y]=1;
  for(int i=1; i<n+1; i++){
    for(int j=i+1; j<n+1; j++){
      d2[i][j]=abs(x-i)+abs(y-j)+1;
    }
  }
  
  for(int i=1; i<n+1; i++){
    for(int j=i+1; j<n+1; j++){
      d[i][j]=min(d1[i][j],d2[i][j]);
    }
  }
  
  for(int i=1; i<n+1; i++){
    for(int j=1; j<n+1; j++){
      c[d[i][j]]++;
    }
  }
  
  for(int i=1; i<n; i++) printf("%d\n", c[i]);
  
  return 0;
}

Measured memory_bytes: 47104
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)
b_arr = gets.chomp.split(" ").map(&:to_i)
c_arr = gets.chomp.split(" ").map(&:to_i)

score = 0
prev = nil
a_arr.each do |a|
  score += b_arr[a-1]
  if !prev.nil? && prev + 1 == a then
    score += c_arr[prev-1]
  end
  prev = a
end

puts score


Measured memory_bytes: 1788
#include<stdio.h>
#include<iostream>
using namespace std;
const int maxn=2e5+10;
long long a[maxn];
int main()
{
    int n,en=0,st=0;
    long long sum=0,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    while(1)
    {
        while(en<n)
        {
            if((sum&a[en])==0)sum+=a[en++],ans+=en-st;
            else break;
        }
        if(en==n)break;
        sum-=a[st++];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
solveImpl :: Int -> [String] -> [String]
solveImpl _ [] = []
solveImpl _ ("0":_) = []
solveImpl a (x:xs) = ("Case " ++ show a ++ ": " ++ x) : solveImpl (a + 1) xs

solve :: [String] -> [String]
solve xs = solveImpl 1 xs

main :: IO ()
main  = getContents
    >>= return . lines
    >>= return . solve
    >>= mapM_ putStrLn

Measured memory_bytes: 5028
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 1e6 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll mul(ll a, ll b){
	return (a * b) % Mod;
}

ll dp[Maxn];
ll f[Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	ll n, h, d;
	cin >> n >> h >> d;
	
	
	f[0] = 1;
	for(int i = 1; i <= n; i++) f[i] = mul(f[i - 1], i);
	ll sm = 0;
	for(int i = 1; i <= n; i++) sm += f[i];
	sm %= Mod;
	
	dp[0] = f[n];
	ll s = dp[0];
	for(int i = 1; i <= h; i++){
		dp[i] = mul(s, (i == h ? 1 : sm));
		//cerr << dp[i] << ' ';
		s += dp[i];
		if(i >= d) s -= dp[i - d];
		s%=Mod;
	}
	cout << (dp[h] + Mod) % Mod;
	return 0;
}
/*
1
5 1
20 21 22 23 24

1
4 2 
1 2 3 4

2 4 1 3

*/


Measured memory_bytes: 15872
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	string S;
	cin >> S;
	int cnt1 = 0, cnt2 = 0;
	int color = 0;
	for (int i = 0; i < S.size(); i++) {
		if ((S[i] - '0') != color) cnt1++;
		color ^= 1;
	}
	color = 1;
	for (int i = 0; i < S.size(); i++) {
		if ((S[i] - '0') != color) cnt2++;
		color ^= 1;
	}
	cout << min(cnt1, cnt2) << endl;
}

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

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

    string n;
    cin >> n;

    for (auto &d: n) {
        if (d == '1') {
            cout << '9';
        } else {
            cout << '1';
        }
    }
    cout << '\n';
    
    return 0;
}


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

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

i = x
while is_prime(i) == False:
    i += 1
print(i)

Measured memory_bytes: 38640
//SILENT KILLER
              //HARD WORK BEATS TALENT WHEN TALENT DOESNOT WORK HARD
#include<bits/stdc++.h>
//typedef long long ll;
using namespace std;
int main()
  {
    int n,s,t;
  cin>>n>>s>>t;
  if(s*t>=n) cout<<"Yes\n";
    else cout<<"No\n";


  }















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

namespace B___Sum_of_Three_Integers
{
    class Program
    {
        static void Main(string[] args)
        {
            var K_S = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int K = K_S[0], S = K_S[1];
            int count = 0;

            for (int x = 0; x <= K; x++)
                for (int y = 0; y <= K; y++)
                    if (S - (x + y) <= K && S - (x + y) >= 0) count++;

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S;cin >> S;
    int A,B,C,D;
    A = S[0]- '0';
    B = S[1]- '0';
    C = S[2]- '0';
    D = S[3]- '0';
    vector<int> abcd(4);
    abcd[0] = A;
    abcd[1] = B;
    abcd[2] = C;
    abcd[3] = D;

    for(int bit = 0;bit <= 7;bit++){
        int tmp = abcd[0];
        string ans;

        for(int i = 1;i <= 3;i++){
            if(bit & 1 << (i-1)){
                tmp += abcd[i];
                ans += "+";
            }
            else{
                tmp -= abcd[i];
                ans += "-";
            } 
        }
        if(tmp == 7){
            cout << A;
            rep(i,3){
                cout << ans[i];
                cout << abcd[i+1];
            }
            cout << "=7" << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		int cnt = 0;
		for(int j = 1; j <= i; j++) {
			if(i % j == 0 && i % 2 == 1) cnt++;
		}
		if(cnt == 8) {
//			cout << i << endl;
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

double f(double r, double x, double y){
    if(abs(x) >= r) return INF;
    return r + y - sqrt(max(0.0, r*r - x*x));
}

int main(){
    int r; int n;
    while(scanf("%d%d", &r, &n) && (r != 0 || n != 0)){
        map<int, int> hl, hr;
        rep(i, n){
            int xl, xr, hi;
            scanf("%d%d%d", &xl, &xr, &hi);
            For(x, xl, xr) chmax(hl[x], hi);
            For(x, xl+1, xr+1) chmax(hr[x], hi);
        }
        double ans = INF;
        For(x, -21, 22){
            if(x > -r) chmin(ans, f(r, x, hl[x]));
            if(x < r) chmin(ans, f(r, x, hr[x]));
        }
        printf("%.10lf\n", ans);
    }
}


Measured memory_bytes: 3192
import numpy as np
l = 10
f = 2 ** l - 1
ans = -float("inf")
n = int(input())
def ch(n):
    if int(n) == 1:
        return 1
    else:
        return 2
j = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for j in range(n)])
for i in range(n):
    j[i] = (np.array(list(map(ch, input().split()))))
costs = np.array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for j in range(n)])
for i in range(n):
    costs[i] = (np.array(list(map(int, input().split()))))
for i in range(2**l - 1):
    ff = np.array(list(map(int, list(format(f, "b").zfill(l)))))
    tmp = 0
    for h in range(n):
        tmp += costs[h][np.sum(ff == j[h])]
    ans = max(ans, tmp)
    f -= 1
print(ans)


Measured memory_bytes: 14436
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  let n = lines[0] - 0;
  let ns = lines[1].split(" ").map(Number);
  console.log(lines[1]);
  for (let i = 1; i < n; i++) {
    for (let j = i; j > 0; j--) {
      if (ns[j] < ns[j - 1]) {
        const t = ns[j];
        ns[j] = ns[j - 1];
        ns[j - 1] = t;
      } else {
        break;
      }
    }
    console.log(ns.join(" "));
  }
});



Measured memory_bytes: 16980
#include <stdio.h>

#define WIDTH 6
#define HEIGHT 12

enum { YET, ALREADY };

int deleteBlock( void );
int findGroup( int, int );
int findGroup_body( int, int, char );
void fallBlock( void );

typedef struct {
	char color;
	int state;
} FIELD;

FIELD field[ WIDTH ][ HEIGHT ];
const int dx[ 4 ] = { -1, 0, 1, 0 }, dy[ 4 ] = { 0, -1, 0, 1 };

int stack[ WIDTH * HEIGHT ];
int sp;

int main( void ) {
	int x, y, n, chain;

	scanf( "%d ", &n );
	while ( n-- ) {
		for ( y = 0; y < HEIGHT; y++ )
			for ( x = 0; x < WIDTH; x++ ) {
				scanf( "%c ", &field[ x ][ y ].color );
				field[ x ][ y ].state = YET;
			}

		for ( chain = 0; deleteBlock(); chain++ )
			fallBlock();

		printf( "%d\n", chain );
	}

	return 0;
}

int deleteBlock( void ) {
	int x, y, del = 0;

	for ( x = 0; x < WIDTH; x++ )
		for ( y = 0; y < HEIGHT; y++ )
			if ( field[ x ][ y ].color != '.' && field[ x ][ y ].color != 'O' && field[ x ][ y ].state == YET ) {
				sp = 0;
				if ( findGroup( x, y ) >= 4 ) {
					while ( sp-- )
						field[ stack[ sp ] / HEIGHT ][ stack[ sp ] % HEIGHT ].color = '.';

					del = 1;
				}
			}

	return del;
}

int findGroup( int x, int y ) {
	return findGroup_body( x, y, field[ x ][ y ].color );
}

int findGroup_body( int x, int y, char color ) {
	int i, sum;

	stack[ sp++ ] = x * HEIGHT + y;
	field[ x ][ y ].state = ALREADY;

	sum = 0;
	for ( i = 0; i < 4; i++ ) {
		int nx = x + dx[ i ], ny = y + dy[ i ];

		if ( nx >= 0 && nx < WIDTH && ny >= 0 && ny < HEIGHT && field[ nx ][ ny ].state == YET && ( field[ nx ][ ny ].color == color || field[ nx ][ ny ].color == 'O' ) )
			if ( field[ nx ][ ny ].color == 'O' )
				stack[ sp++ ] = nx * HEIGHT + ny;
			else
				sum += findGroup_body( nx, ny, color );
	}

	return sum + 1;
}

void fallBlock( void ) {
	int x, y, cnt;

	for ( x = 0; x < WIDTH; x++ ) {
		cnt = 0;
		for ( y = HEIGHT - 1; y >= 0; y-- )
			if ( field[ x ][ y ].color == '.' )
				cnt++;
			else {
				field[ x ][ y + cnt ].color = field[ x ][ y ].color;
				field[ x ][ y + cnt ].state = YET;
			}

		for ( y = cnt - 1; y >= 0; y-- )
			field[ x ][ y ].color = '.';
	}
}

Measured memory_bytes: 596
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String []args) throws Exception {
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        // int n = Integer.parseInt(br.readLine());
        // long [][] dp = new long[n+1][n+1];
        // ArrayList<String> list = new ArrayList<>();
        int n = sc.nextInt();
        String s = sc.next();
        int r = 0 ; 
        int w = 0;
        for(int i = 0 ; i < s.length() ; i++){
            if(s.charAt(i) == 'R'){
                r++;
            }else{
                w++;
            }
        }
        int tc1 = 0;
        for(int i = 0 ; i < r ; i++){
            if(s.charAt(i) == 'W'){
                tc1++;
            }
        }
        int tc2 = 0;
        for(int i = r ; i < s.length() ; i++){
            if(s.charAt(i) =='R'){
                tc2++;
            }
        }
        int ans = Math.min(Math.min(r ,w) , Math.max(tc1 , tc2));
        System.out.println(ans);
        
    }
}

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

//Kakezan
public class Main{

	void run(){
		int[] f = new int[1000001];
		for(int x=0;x<=1000000;x++){
			int max = 0;
			for(int d=10;d<=1000000;d*=10){
				max = Math.max(max, (x/d)*(x%d));
			}
			f[x] = max;
		}
		Scanner sc = new Scanner(System.in);
		boolean[] u = new boolean[1000001];
		int Q = sc.nextInt();
		while(Q--!=0){
			Arrays.fill(u, false);
			int x = sc.nextInt(), res = 0;
			u[x] = true;
			while(10<=x){
				x = f[x];
				if(u[x]){
					res = -1; break;
				}
				res++;
				u[x] = true;
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second

// 1次元vectorの出力
template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

mint perm(int n, int r){
	mint res(n);
	for(int i=n-1; i>n-r; i--){
		res *= i;
	}
	return res;
}

mint ans;
int n,k;

void dfs(int node, vector<vector<int>> &tree, int par){
	int c = k-2;
	for(int child: tree[node]){
		if(child != par){
			ans *= c--;
			dfs(child, tree, node);
		}
	}
}

int main(void){
	cin >> n >> k;
	if(n == 1){
		cout << k << endl;
		return 0;
	}
	vector<vector<int>> tree(n,vector<int>());
	Rep(n-1){
		int a,b; cin >> a >> b;
		a--; b--;
		tree[a].push_back(b);
		tree[b].push_back(a);
	}
	ans += k;
	ans *= perm(k-1, tree[0].size());
	for(int node: tree[0]){
		dfs(node, tree, 0);
	}
	cout << ans << endl;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<pair<char, char>> T;
	fx(Q) {
		char t, d;
		cin >> t >> d;
		pb(T, make_pair(t, d));
	}

	int left = 0, right = N;
	int mid = (left + right) / 2;
	fx(50) {
		mid = (left + right) / 2;
		int res = 0;
		fy(Q) {
			if (S[mid]==T[y].first) {
				if (T[y].second=='L') {
					mid--;
					if (mid<0) {
						res = -1;
						break;
					}
				}
				else {
					mid++;
					if (mid>=N) {
						res = 1;
						break;
					}
				}
			}
		}
		if (res==0||res==1) {
			right = (left + right) / 2;
		}
		else if (res==-1) {
			left = (left + right) / 2;
		}
	}
	int ansL = (left + right) / 2;
	if (left==right) {
		ansL--;
	}

	 left = -1, right = N-1;
	 mid = (left + right+ 1) / 2;
	fx(50) {
		mid = (left + right+1) / 2;
		int res = 0;
		fy(Q) {
			if (S[mid] == T[y].first) {
				if (T[y].second == 'L') {
					mid--;
					if (mid < 0) {
						res = -1;
						break;
					}
				}
				else {
					mid++;
					if (mid >= N) {
						res = 1;
						break;
					}
				}
			}
		}
		if (res == 0||res==-1) {
			left = (left + right + 1) / 2;
		}
		else if (res == 1) {
			right = (left + right + 1) / 2;
		}
	}
	int ansR = (left + right + 1) / 2;
	if (left == right) {
		ansR++;
	}
	//doublece(ansL,ansR)
	if (ansL>=ansR) {
		ce(N - ansL - 1-N + ansR + abs(ansL-ansR)+1)
	}
	else {
		ce(N-ansL - 1 -N+ansR)
	}

    return 0;
}



Measured memory_bytes: 1024
# include<iostream>
# include<vector>
# include<algorithm>

using namespace std;
typedef long long ll;

int main(){
  int n;
  ll ans = 0;
  cin >> n;
  vector<ll> b(n+1);

  for(int i=1; i<=n-1; ++i)
    cin >> b[i];

  for(int i=0; i<n; ++i){
    if(i == 0){
      ans += b[1];
    }else if(i == n-1){
      ans += b[n-1];
    }else{
      ans += min(b[i], b[i+1]);
    }
  }

  cout << ans << '\n';
  return 0;
}

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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/

    vector<int> v(3);
    int n,ans=0;
    for(int i=0;i<3;i++){
        cin>>v[i];
    }
    cin>>n;
    for(int i=0;i<3001;i++){
        for(int j=0;j<3001;j++){
            if((n-i*v[0]-j*v[1])%v[2]==0&&(n-i*v[0]-j*v[1])>=0){
                ans++;
            }
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		//long a = long.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] NMK = Console.ReadLine().Split(' ');
		int K = int.Parse(NMK[0]);
		int N = int.Parse(NMK[1]);

		string[] house = Console.ReadLine().Split(' ');
		// 次の家までの距離のMAXを探す
		int max = 0;
		for(int i=0; i<N; i++)
		{
			int dis = 0;
			if(i==N-1)
			{
				dis = K - int.Parse(house[i]) + int.Parse(house[0]);
			}
			else
			{
				dis = int.Parse(house[i+1]) - int.Parse(house[i]);
			}

			max = Math.Max(dis, max);
		}
		//string s = Console.ReadLine();


		Console.WriteLine((K - max) + "");

		// 文字列の入力
		//string s = Console.ReadLine();
		//出力
		//Console.WriteLine((a+b+c) + " " + s);
	}
}


Measured memory_bytes: 30940
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
		Stack<Integer> numbers = new Stack<>();
		Scanner in = new Scanner(System.in);
		String line = in.nextLine();
		in.close();
		String[] list = line.split(" ");
		for (String l : list) {
			if (l.equals("+") || l.equals("-") || l.equals("*")) {
				int b = numbers.pop();
				int a = numbers.pop();
				if (l.equals("+")) {
					numbers.push(a + b);
				}
				else if (l.equals("-")) {
					numbers.push(a - b);
				}
				else if (l.equals("*")) {
					numbers.push(a * b);
				}
			}
			else {
				int x = Integer.parseInt(l);
				numbers.push(x);
			}
		}
		System.out.println(numbers.pop());
	}
}



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

int	main(void)
{
  int num, sum_of_digit, copy_num= 0;
  cin >> num;
  copy_num = num;
  
  while (num >= 10)
  {
    sum_of_digit += num % 10;
    num /= 10;
  }
  
  //cout << "while文を抜けた直後のnumの値確認:" << num << endl;
  //cout << "while文を抜けた直後のsum_of_digitの値確認:" << sum_of_digit << endl;
  
  sum_of_digit += num;
  
  if (copy_num % sum_of_digit == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>void add(T &a, const T &b){a += b; a %= mod;}

signed main(){
  int n; cin >> n;
  vi w(n); rep(i,n) cin >> w[i];
  int ans = inf;
  int r = accumulate(all(w),0);
  int l = 0;
  rep(i,n-1){
    l += w[i];
    r -= w[i];
    ans = min(ans, abs(l-r));
  }
  cout << ans << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    ll N, A, B;
    cin >> N >> A >> B;

    if (A > B) {
        cout << 0 << endl;
        return;
    }else if (N == 1 && A != B) {
        cout << 0 << endl;
        return;
    }

    ll num = N-2;
    ll maxnum = B + A + num*B;
    ll minnum = B + A + num*A;

    // cout << maxnum << endl;
    // cout << minnum << endl;
    cout << maxnum - minnum + 1 << endl;
    

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public 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();
        }

        sc.close();

        int cnt = 0;

        boolean flg = true;

        while (flg) {
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 == 0) {
                    a[i] /= 2;
                } else {
                    flg = false;
                    break;
                }
            }
            cnt++;
        }
        cnt--;
        System.out.println(cnt);
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

typedef pair<ll ,ll > pii;
typedef pair<ll,ll> pll;

#define INF 2e18
vector<vector<ll> > dp(401, vector<ll> (401, -1LL));
vector<ll> prefixSums(401, 0LL);

ll MinCost(ll  st, ll  end, vector<ll > &arr){
    if(st == end)
        return 0LL;
    if(dp[st][end ] != -1LL)
        return dp[st][end];
    ll ans = INF;
    ll mergeCost = (st == 0LL)?(prefixSums[end]):(prefixSums[end] - prefixSums[st - 1]); 
    F(ll , mark, st, end - 1LL){
        ans = min(ans, mergeCost + MinCost(st, mark, arr) + MinCost(mark + 1, end, arr));
    }
    dp[st][end] = ans;
    return ans;
}

void solve()
{
    ll  n;
    cin>>n;
    vector<ll > arr(n);
    F(ll , i, 0LL, n - 1LL)
        cin>>arr[i];
    prefixSums[0] = arr[0];
    F(int, i, 1LL, n - 1LL)
        prefixSums[i] = arr[i] + prefixSums[i - 1];
    cout<<MinCost(0LL, n - 1LL, arr);
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        freopen("Debug.txt", "w", stderr);
    #else
    #endif
    solve();
}


Measured memory_bytes: 4948
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN=4e5+10;
const int Inf=2147483647;
int n,Ls,Maxs,Mins,A[MAXN],B[MAXN],Lsh[MAXN<<1];
ll Ans=1e18;
inline int Read()
{   rg int a=0,c=1;   rg char b=getchar();
	while(b!='-'&&(b<'0'||b>'9'))b=getchar();
	if(b=='-')c=-1,b=getchar();
	while(b>='0'&&b<='9')a=a*10+b-48,b=getchar();
	return a*c;
}
inline int Abs(rg int A){   return A>0?A:-A;   }
inline ll Max(rg ll A,rg ll B){   return A>B?A:B;   }
inline ll Min(rg ll A,rg ll B){   return A<B?A:B;   }
namespace Part1
{   int Mint[MAXN<<2],Lan[MAXN<<2];
	inline void Push_Lan(rg int S,rg int Num){   Mint[S]=Min(Mint[S],Num),Lan[S]=Min(Lan[S],Num);   }
	inline void Push_down(rg int S){   Push_Lan(S<<1,Lan[S]),Push_Lan(S<<1|1,Lan[S]),Lan[S]=Inf;   }
	inline int Modify(rg int S,rg int Le,rg int Ri,rg int Al,rg int Ar,rg int Num)
	{   if(Al>Ar) return 0;
		if(Al<=Le&&Ri<=Ar) return Push_Lan(S,Num),0;   rg int Mid=(Le+Ri)>>1;
		Push_down(S),Al<=Mid?Modify(S<<1,Le,Mid,Al,Ar,Num):0,Mid<Ar?Modify(S<<1|1,Mid+1,Ri,Al,Ar,Num):0;
	}
	inline int Query(rg int S,rg int Le,rg int Ri,rg int Aim)
	{   if(Le==Ri) return Mint[S];   rg int Mid=(Le+Ri)>>1;
		return Push_down(S),Aim<=Mid?Query(S<<1,Le,Mid,Aim):Query(S<<1|1,Mid+1,Ri,Aim);
	}
	inline void Get_Ans1()
	{   rg int Pos1=0,Pos2=0,Pos3=0,Pos4=0,Lim=0;
		for(rg int i=1;i<=n&&!Pos1;i++) if(A[i]==Ls||B[i]==Ls) Pos1=i;
		for(rg int i=1;i<=n&&!Pos4;i++) if(A[i]==1||B[i]==1) Pos4=i;
		for(rg int i=1;i<=n;i++) if(A[i]==Ls||B[i]==Ls) Pos3=i;
		for(rg int i=1;i<=n;i++) if(A[i]==1||B[i]==1) Pos2=i;
		if(Pos1==Pos3&&Pos2==Pos4&&Pos1==Pos2) return ;
		for(rg int i=1;i<=Ls<<2;i++) Mint[i]=Lan[i]=Inf;
		for(rg int i=1;i<=n;i++) Modify(1,1,Ls,A[i]+1,Ls,Lsh[A[i]]),Modify(1,1,Ls,B[i],A[i]-1,Lsh[B[i]]);
		for(rg int i=1;i<=n;i++) Lim=Max(Lim,B[i]);
		for(rg int i=Ls;i>=Lim;i--) Ans=Min(Ans,1ll*(Maxs-Mins)*(Lsh[i]-Query(1,1,Ls,i)));
	}
}using Part1::Get_Ans1;
inline void Get_Ans2()
{   rg int Minr=Inf,Maxb=0;
	for(rg int i=1;i<=n;i++) Minr=Min(Minr,A[i]),Maxb=Max(Maxb,B[i]);
	Ans=Min(Ans,1ll*(Maxs-Lsh[Minr])*(Lsh[Maxb]-Mins));
}
int main()
{   n=Read(),Mins=Inf;
	for(rg int i=1;i<=n;i++) A[i]=Read(),B[i]=Read(),A[i]<B[i]?swap(A[i],B[i]):(void)0;
	for(rg int i=1;i<=n;i++) Maxs=Max(Maxs,A[i]),Mins=Min(Mins,B[i]),Lsh[++Ls]=A[i],Lsh[++Ls]=B[i];
	sort(Lsh+1,Lsh+Ls+1),Ls=unique(Lsh+1,Lsh+Ls+1)-Lsh-1;
	for(rg int i=1;i<=n;i++) A[i]=lower_bound(Lsh+1,Lsh+Ls+1,A[i])-Lsh,B[i]=lower_bound(Lsh+1,Lsh+Ls+1,B[i])-Lsh;
	Get_Ans1(),Get_Ans2(),printf("%lld\n",Ans);
}


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

long long inf = (1 << 30);
long long mod = 1e9;

int main(){

    long long X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<long long> A(X), B(Y), C(Z);
    for(int i = 0; i < X; i++) cin >> A[i];
    for(int i = 0; i < Y; i++) cin >> B[i];
    for(int i = 0; i < Z; i++) cin >> C[i];

    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());

    vector<long long> ans;
    for(int i = 0; i < X; i++){
        for(int j = 0; j < Y; j++){
            for(int k = 0; k < Z; k++){
                if((i + 1) * (j + 1) * (k + 1) > K) continue;
                ans.emplace_back(A[i] + B[j] + C[k]);
            }
        }
    }

    sort(ans.rbegin(), ans.rend());
    for(int i = 0; i < K; i++) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 1404
#include<stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(W>=x+r&&0<=x-r&&H>=y+r&&0<=y-r){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2680
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fr(i, a, b) for(int i=a;i<b;++i)
#define fdr(i, a, b) for(int i=b-1;i>=a;--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

/////////////////

int const LEN = 15;
int cnt = 0;
string ans = "9990909";

string toInf(string s){
	while(sz(s) < LEN) s.pb('0');
	return s;
}

ll toInt(string s){
	ll r;
	sscanf(s.c_str(), "%lld",&r);
	return r;
}

bool query(string v){
#ifdef _DEBUG
	++cnt;
	bool ok = false;
	if(v <= ans && toInt(v) <= toInt(ans)) ok = true;
	if(v > ans && toInt(v) >  toInt(ans)) ok = true;
	return ok;
#endif
	cout << "? " << v << endl;
	fflush(stdout);
	string resp;
	cin >> resp;
	return (resp == "Y");
}

void answer(string v){
	cout << "! " << v << endl;
	fflush(stdout);
#ifdef _DEBUG
	++cnt;
	//assert(v == ans);
	//assert(cnt <= 64);
	cerr << "cnt = " << cnt << endl;
#endif
	exit(0);
}

string toString(ll v){
	string ret;
	char s[55];
	sprintf(s, "%lld",v);
	ret += s;
	return ret;
}

void solve(){
	string s;
	fr(i, 0, 10){
		int l = -1;
		int r = 10;
		if(i == 0) l = 0;
		string ns;
		while(r-l>1){
			int m = (l+r)/2;
			ns = s;
			ns.pb('0' + m);
			ns = toInf(ns);
			if(query(ns)) r = m;
			else l = m;			
		}
		if(i == 0 && r == 1){
			s = "1";
		}else{
			if(r == 0){
				s = toInf(s);
				break;
			}else{
				s += ('0' + (r - 1));
			}
		}
	}
	if(s.back() != '0'){
		int add = 1;
		fdr(i, 0, sz(s)){
			s[i] += add;
			if(s[i] > '9'){
				s.pop_back();
				add = 1;
			}else break;
		}
	}
	
	while(s.back() == '0') s.pop_back();
	while(true){
		s += '9';
		if(query(s)) break;
		s.back() = '0';
	}
	
	s.pop_back();
	int cnt9 = 0;
	fr(i, 0, sz(s)) if(s[i] == '9') ++cnt9;
	if(cnt9 == sz(s)){
		string ns;
		ns = s;
		--ns.back();
		ns += "0";
		if(query(ns)) s += "0";
	}else{
		ll val = toInt(s);
		++val;
		string ns;
		ns = toString(val);
		if(query(ns)){
		}else{
			s += "0";
		}
	}

	answer(s);
}



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

	solve();


	return 0;
}

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

int main(){
	int n,p,w;
	cin >> n;
	int max = 0;
	int maxp = 100;
	for(int i=0;i<n;i++){
		cin >> p;
		cin >> w;
		if(max < w){
			maxp = p;
			max = w;
		}else if(max == w){
			if(maxp > p){
			maxp = p;
			}
		}
	}
		cout << maxp << " " << max << endl;
		
		return 0;
}
	

Measured memory_bytes: 1168
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   String S = sc.next();
   String T = sc.next();
   String tmp = S ;
   boolean flg = false;
   
   for(int i=0;i<S.length();i++)
   {
     tmp = tmp.substring(S.length()-1,S.length()) + tmp.substring(0,S.length()-1);
     if(T.equals(tmp))
     {
       flg = true;
       break;
     }
   }
   
   if(flg) System.out.println("Yes");
   else System.out.println("No");
 }
}

Measured memory_bytes: 22868
#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

	int n, m, a[101][101], b[101], c;//縦横

	cin >> n >> m;

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

		for (int j = 0; j < m;j++) {

			cin >> a[i][j];
		}
	}

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

		cin >> b[i];
	}
	for (int i = 0; i < n;i++) {
		c = 0;
		for (int j = 0; j < m;j++) {

			c += a[i][j] * b[j];
		}
		cout << c << endl;
	}
	//cin >> /*変数他*/;
	//cout << /*文字列*/ << endl;
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

void solve(ll current, ll &count, int use, ll N) {
  if (current > N) return;
  if (use == 0b111) {
    // cout << current << endl;
    count++;
  }

  solve(current * 10 + 7, count, use | 0b001, N);
  solve(current * 10 + 5, count, use | 0b010, N);
  solve(current * 10 + 3, count, use | 0b100, N);
}

int main() {
  ll N;
  cin >> N;

  ll ans = 0;
  solve(0, ans, 0, N);
  cout << ans << endl;
  return 0;
}


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

int main(){

  string S,a;
  cin >> S;
  vector<int> b(26,0);
  a="abcdefghijklmnopqrstuvwxyz";
  
  for(int i=0; i<S.size(); i++){
  	for(int j=0; j<26; j++){
  	if(S[i]==a[j]) b[j]++;
    }
  }
  bool exist = 0;
  for(int i=0; i<26; i++){
    if(b[i] > 1){
      exist = 1;
      break;
    }
  }
  
 
  
  
  if(exist) cout << "no" << endl;
  else cout << "yes" << endl;
  
}

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

int main() {
  string s;

  cin >> s;

  int sum = 0;
  int j = s.size()-1;
  for (int i = 0; i < s.size()/2; i++) {
      if (s.at(i) != s.at(j)) {
          sum += 1;
      }
      j--;
  }

  cout << sum << endl;
}


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

vector<vector<int>> edges;
bool seen[5];

bool pos(const int idx, const int vis) {
   if (vis == 4)
      return 1;
   seen[idx] = 1;
   for (int i = 0; i < (int)edges[idx].size(); i++) {
      if (!seen[edges[idx][i]]) {
         if (pos(edges[idx][i], vis + 1))
            return 1;
      }//if
   }//for
   return 0;
}//pos

int main() {
   int t, f;
   edges.assign(5, vector<int>());
   for (int i = 0; i < 3; i++)
      scanf("%d %d", &t, &f), edges[t].push_back(f), edges[f].push_back(t);
   for (int i = 1; i <= 4; i++) {
      memset(seen, 0, sizeof(seen));
      if (pos(i, 1)) {
         puts("YES");
         return 0;
      }//if
   }//for
   puts("NO");
   return 0;
}//main


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int med(int a, int b, int c){
  int v[3] = {a, b, c};
  sort(v, v + 3);
  return v[1];
}
int check(int n, int x, vector<int> v){
  return 1;
  vector<int> nv[2];
  nv[0] = v;
  int s = 0;
  while(nv[s].size() > 1){
//    cout << nv[s].size() << endl;
    int o = s^1;
    nv[o].clear();
    for(int i = 1;i < nv[s].size() - 1;i++){
      nv[o].push_back(med(nv[s][i - 1], nv[s][i], nv[s][i + 1]));
    }
    s ^= 1;
  }
  return nv[s][0] == x;
}
int main(){
  int n;
  cin >> n;
  int x;
  cin >> x;
  vector<int> res;
  if(x == 2 * n - 1 || x == 1){
    cout << "No";
  }else if(x == n){
    cout << "Yes\n";
    for(int i = 1;i <= 2 * n - 1;i++)
      res.push_back(i);
    assert(check(n, x, res));
    for(auto el : res)
      cout << el << endl;
  }else{
    if(x == 2){
      cout << "Yes\n";
      int cnt = 0;
      int i = 5;

      for(;cnt < n - 3;i++, cnt++)
        res.push_back(i);
      res.push_back(3);
      res.push_back(2);
      res.push_back(1);
      res.push_back(4);
//      cout << 3 << endl;
//      cout << 2 << endl;
//      cout << 1 << endl;
//      cout << 4 << endl;
      for(;i <= 2*n - 1;i++)
        res.push_back(i);
      for(auto el : res)
        cout << el << endl;
//        cout << i <<endl;
      assert(check(n, x, res));
    }else{
      cout << "Yes\n";
      int cnt = 0;
      int i = 1;
      for(;cnt < n - 3;i++){
        if(i != x && i != x - 1 && i != x - 2 && i != x + 1){
          res.push_back(i);
//          cout << i << endl;
          cnt++;
        }
      }

//      cout << x - 1 << endl;
//      cout << x << endl;
//      cout << x + 1 << endl;
//      cout << x - 2 << endl;
      res.push_back(x - 1);
      res.push_back(x);
      res.push_back(x + 1);
      res.push_back(x - 2);
      for(;i <= 2 * n - 1;i++){
        if(i != x && i != x - 1 && i != x - 2 && i != x + 1){
          res.push_back(i);
//          cout << i << endl;
        }
      }
      for(auto el : res)
        cout << el << endl;
      assert(check(n, x, res));
    }
  }
  return 0;
}


Measured memory_bytes: 3188
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    mp[a]++;
  }

  vector<int> v;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    v.push_back(it->second);
  }
  sort(v.begin(), v.end());

  long long ans = 0;
  for (int i = 0; i < (int)v.size() - k; i++) {
    ans += v[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 10748