akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    int v = sc.nextInt() * 100 + sc.nextInt() * 10 + sc.nextInt();
    System.out.println(v % 4 == 0 ? "YES" : "NO");
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else 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;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		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() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k,i;cin>>a>>b>>k;
  for(i=0;i<k;i++){
    if(i%2){
	  if(b&0) --b;
      b/=2;
      a+=b;
    }
    else{
	  if(a&0) --a;
      a/=2;
      b+=a;
    }
  }
  cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int A = S[0] - '0';
  int B = S[1] - '0';
  int C = S[2] - '0';
  int D = S[3] - '0';
  if (A + B + C + D == 7){
    cout << A << '+' << B << '+' << C << '+' << D << "=7" << endl;
  } else if (A + B + C - D == 7){
    cout << A << '+' << B << '+' << C << '-' << D << "=7" << endl;
  } else if (A + B - C + D == 7){
    cout << A << '+' << B << '-' << C << '+' << D << "=7" << endl;
  } else if (A + B - C - D == 7){
    cout << A << '+' << B << '-' << C << '-' << D << "=7" << endl;
  } else if (A - B + C + D == 7){
    cout << A << '-' << B << '+' << C << '+' << D << "=7" << endl;
  } else if (A - B + C - D == 7){
    cout << A << '-' << B << '+' << C << '-' << D << "=7" << endl;
  } else if (A - B - C + D == 7){
    cout << A << '-' << B << '-' << C << '+' << D << "=7" << endl;
  } else if (A - B - C - D == 7){
    cout << A << '-' << B << '-' << C << '-' << D << "=7" << endl;
  }
}

Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

#include <stdexcept>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstring>
#include <cstdarg>
#include <cstdio>
#include <memory>
#include <random>
#include <cmath>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <limits>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <array>
#include <list>
#include <map>
#include <set>

using namespace std;

#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
 
 
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
 
const int mod = 1e9+7;
const int inf = 1e18;

int32_t main(){
    FAST;

    string s;   cin >> s;

    int n = s.size();
    s = "#" + s;

    for(int x=1;x<=n;x++){
        if(x % 2 == 0){
            if(s[x] != 'L' and s[x] != 'U' and s[x] != 'D')
                return cout << "No" , 0;
        }else{
            if(s[x] != 'R' and s[x] != 'U' and s[x] != 'D')
                return cout << "No" , 0;
        }
    }

    cout << "Yes";
    

    return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
const MOD: u64 = 1000000007;
fn main() {
    let buf = io::read_string();
    let mut sc = io::Scanner::new(&buf);
    let s: String = sc.read();
    let s = s.into_bytes();
    let abc: Vec<u8> = "ABC".bytes().collect();
    let n = s.len();
    let mut dp = vec![vec![0u64; 4]; n+1];
    dp[n][3] = 1;
    for i in (0..n).rev() {
        for j in (0..4).rev() {
            let k = if s[i] == b'?' { 3 } else { 1 };
            dp[i][j] = k * dp[i + 1][j];
            if j < 3 {
                let k2 = if s[i] == b'?' || s[i] == abc[j] { 1 } else { 0 };
                dp[i][j] += k2 * dp[i + 1][j + 1];
            }
            dp[i][j] %= MOD;
        }
    }
    println!("{}", dp[0][0]);
}
#[allow(dead_code)]
mod io {
    use std;
    use std::io::Read;
    use std::str::{FromStr, SplitWhitespace};
    pub struct Scanner<'a> {
        pub iter: SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.iter
                .next()
                .unwrap()
                .parse()
                .ok()
                .expect("parsing failed")
        }
        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

const string YES = "Yes";
const string NO = "No";

void solve(std::string N) {
  ll sum = 0;
  REP(i, N.size()) {
    sum += N[i] - '0';
    sum %= 9;
  }
  if (sum % 9 == 0) {
    cout << YES << endl;
  } else {
    cout << NO << endl;
  }
}

int main() {
  std::string N;
  std::cin >> N;
  solve(N);
  return 0;
}


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


int main (){
  int x;
  cin >> x;
  if(x <= 599) cout << 8 << endl;
  else if(x <= 799) cout << 7 << endl;
  else if(x <= 999) cout << 6 << endl;
  else if(x <= 1199) cout << 5 << endl;
  else if(x <= 1399) cout << 4 << endl;
  else if(x <= 1599) cout << 3 << endl;
  else if(x <= 1799) cout << 2 << endl;
  else cout << 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3644
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    while(1){
    ll n,d;
    cin>>n>>d;
        if(n==0){break;}
    vector<vector<ll>> a(n);
    vector<ll> s(n,0);
    ll sum=0;
    for(int i=0;i<n;i++){
        ll m;
        cin>>m;
        sum+=m;
        a[i].resize(m+1,0);
        for(int t=0;t<m;t++){
            cin>>a[i][t+1];
            s[i]+=a[i][t+1];
        }
    }
    bool j=true;
    int i;
    for(i=0;i<sum && j;){
        j=false;
        ll mx=-1;
        ll nmx=-1;
        ll w=-1;
        ll nw=-1;
        for(int t=0;t<n;t++){
            if(nmx<s[t]){
                nmx=s[t];
                nw=t;
                if(nmx>mx){
                    swap(mx,nmx);
                    swap(nw,w);
                }
            }
        }
        if(abs(s[w]-a[w].back()-nmx)<=d){
            j=true; i++;
            s[w]-=a[w].back();
            a[w].pop_back();
            mx=max(nmx,s[w]);
        }
        for(int t=0;t<n;t++){
            if(s[t]==0){continue;}
            if(mx-(s[t]-a[t].back())<=d){
                j=true; i++;
                s[t]-=a[t].back();
                a[t].pop_back();
            }
        }
    }
    cout<<(i==sum?"Yes":"No")<<endl;
    
    
    }
    
    
    
    return 0;
}




Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int n,k,mx =0,tp,ans=1e9,mid,d;
vector<int> v;

int main(){
	cin >> n>>k;
	REP(i,n){
    	cin>>tp;
		v.push_back(tp);
	}
	sort(v.begin(),v.end());

	REP(i,n - k + 1){
		//cout << v[i + k - 1] - v[i];
		ans = min(v[i + k - 1] - v[i] , ans);
	}

	cout<< ans <<endl;
} 


Measured memory_bytes: 892
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(deftype int32 () '(signed-byte 32))
(deftype int64 () '(signed-byte 64))


;;macros
(defmacro println (n)
  `(format t "~a~%" ,n))
(defmacro vint-out (vec)
  `(progn
     (rep i (length ,vec)
          (princ (vref ,vec i))
          (princ " "))
     (fresh-line)))
(defmacro aif (test-form then-form &optional else-form)
  `(let ((it ,test-form))
     (if it ,then-form ,else-form)))

;;vector
(defmacro vec (type &optional (num 100) (val 0))
  (let* ((g (gensym)))
    `(let* ((,g ,num))
       (make-array ,g :element-type ',type :initial-element ,val
                   :adjustable nil :fill-pointer ,g))))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vint (&optional (num 0) (val 0))
  `(vec int32 ,num ,val))

(defmacro double-vec (type &optional (dim1 100) (dim2 100) (val 0))
  `(make-array '(,dim1 ,dim2) :element-type ',type :initial-element ,val))

(defmacro vref (vector pos &optional value)
  (let ((g (gensym)))
    `(let ((,g ,value))
       (if ,g
           (setf (aref ,vector ,pos) ,g)
           (aref ,vector ,pos)))))

(defmacro chvar (sym comp predicate)
  (let ((g (gensym)))
    `(let ((,g ,comp))
       (if (or (null ,sym) (not (funcall ,predicate ,sym ,g)))
           (setf ,sym ,g)))))

(defmacro chmax (sym comp &optional (predicate #'>))
  `(chvar ,sym ,comp ,predicate))

(defmacro chmin (sym comp &optional (predicate #'<))
  `(chvar ,sym ,comp ,predicate))

(defmacro defchangef (name op default-val)
  `(defmacro ,name (var &optional (val ,default-val))
     `(setq ,var (,',op ,val ,var))))
(defmacro read-str ()
  `(write-to-string (read)))

;;本体
(defun main ()
  (let ((x (read)) (a (read)))
    (println (if (< x a) 0 10))))

#-swank(main)


Measured memory_bytes: 18272
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        long X = sc.NextInt();
        long A = sc.NextInt();
        long B = sc.NextInt();
        if (A >= B)
        {
            Console.WriteLine("delicious");
        }
        else if (-A + B <= X)
        {
            Console.WriteLine("safe");
        }
        else
        {
            Console.WriteLine("dangerous");
        }
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
from collections import Counter
N, K = map(int,input().split())
A = list(map(int,input().split()))
i = k = 0
B = [1]
while k <= 10 ** 6:
    i = A[i] - 1
    B.append(i + 1)
    k += 1
S = Counter(B)
idx = S.most_common(1)[0][0]
i = k = cnt = 0
k_s = None
while k < 10 ** 6:
    if B[k] == idx and cnt == 1:
        k_s = k
        break
    elif B[k] == idx:
        k_f = k
        cnt += 1
    k += 1
if k_s and k_s < K:
    k_max = (K - B.index(idx)) % (k_s - k_f) + B.index(idx)
else:
    k_max = K
i = k = 0
while k < k_max:
    i = A[i] - 1
    k += 1
print(i + 1) 

Measured memory_bytes: 199080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readS(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readS(String str) {
		S = str;
		System.out.println(check(3, 0));
	}

	String S;

	private int check(int digi, int left) {
		if (digi < 1)
			return 0;
		if (left >= N)
			return 0;
		int ans = 0;
		for (char c = '0'; c <= '9'; c++) {
			for (int pos = left; pos < N; pos++) {
				if (S.charAt(pos) != c)
					continue;
				// System.out.println(digi + " " + c + " " + pos);
				if (digi == 1)
					ans += 1;
				else
					ans += check(digi - 1, pos + 1);
				break;
			}
		}
		return ans;
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long double ld;
typedef pair<ld,ld> P;
int n;
P p[50];

ld getdis(P a,P b){
  return (a.f-b.f)*(a.f-b.f)+(a.s-b.s)*(a.s-b.s);
}

P cal(){
  ld a=0,cx=0,cy=0;
  for (int i=n,u=0;i-->0;u=i) {
    ld k=p[i].f*p[u].s-p[u].f*p[i].s;
    a+=k;
    cx+=k*(p[u].f+p[i].f);
    cy+=k*(p[u].s+p[i].s);
  }
  cx/=3*a;
  cy/=3*a;
  return P(cx,cy);
}

int main(){
  bool an=1;
  cin>>n;
  for(int i=0;i<n;i++)cin>>p[i].f>>p[i].s;
  P a=cal();
  for(int i=0;i<n/2;i++){
    if(getdis(a,p[i])!=getdis(a,p[n/2+i]))an=0;
  }
  double x=a.f,y=a.s;
  if(!an||n%2)cout<<"NA"<<endl;
  else printf("%.8f %.8f\n",x,y);
  return 0;
}

Measured memory_bytes: 3264
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  n <- getInt

  let nextTA t a pt pa = let mt = (pt + t - 1) `div` t
                             ma = (pa + a - 1) `div` a
                             m = max mt ma
                             t' = t * m
                             a' = a * m
                         in (t', a')

      solve :: Int -> Int -> Int -> IO Int
      solve i pt pa | i == n = return (pt + pa)
                    | otherwise = do
                        [t, a] <- getIntList
                        let (nt, na) = nextTA t a pt pa
                        solve (i+1) nt na

  ans <- solve 0 1 1
  print ans

Measured memory_bytes: 1276
//by sdfzchy
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
const int inf=(1<<30),N=100010;
int n,m,cnt[11];
char s[5];
inline int in()
{
	char ch=getchar();
	int f=1,tmp=0;
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {tmp=(tmp<<1)+(tmp<<3)+(ch-'0');ch=getchar();}
	return tmp*f;
}

int main()
{
//	freopen("in.in","r",stdin);
//	freopen("out.out","w",stdout);
	scanf("%s",s+1);
	if((s[1]==s[2]&&s[2]==s[3])||(s[2]==s[3]&&s[3]==s[4]))	 puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>


#define INPUT_MAX 101
#define KAKKO_MAX 49

using namespace std;

int main(void)
{
	int countMaru = 0;
	int countKaku = 0;
	int idx = 0;
	string stack(KAKKO_MAX, '\0');
	string dataset(INPUT_MAX, '\0');
	
	while(getline( cin, dataset))
	{
		if(dataset[0] == '.')
		{
			break;
		}
		for(int i = 0; i < INPUT_MAX; i++)
		{
			if(dataset[i] == '.')
			{
				if((countMaru == 0) && (countKaku == 0))
				{
					cout << "yes\n";
					break;
				}
				else
				{
					cout << "no\n";
					break;
				}
			}
			else if(dataset[i] == '(')
			{
				if(idx == KAKKO_MAX)
				{
					cout << "no\n";
					break;
				}
				countMaru++;
				stack[idx] = '(';
				idx++;
			}
			else if(dataset[i] == '[')
			{
				if(idx == KAKKO_MAX)
				{
					cout << "no\n";
					break;
				}
				countKaku++;
				stack[idx] = '[';
				idx++;
			}
			else if(dataset[i] == ')')
			{
				if(idx == 0)
				{
					cout << "no\n";
					break;
				}
				else if(stack[idx-1] == '[')
				{
					cout << "no\n";
					break;
				}
				else
				{
					idx--;
					stack[idx] = '\0';
					countMaru--;
				}
			}
			else if(dataset[i] == ']')
			{
				if(idx == 0)
				{
					cout << "no\n";
					break;
				}
				else if(stack[idx-1] == '(')
				{
					cout << "no\n";
					break;
				}
				else
				{
					idx--;
					stack[idx] = '\0';
					countKaku--;
				}
			}
			else
			{
				// 処理なし
			}
		}
		
		idx = 0;
		countMaru = 0;
		countKaku = 0;
	}
	
	return 0;
}




Measured memory_bytes: 3052
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;

#define EPS (1e-5)

typedef complex<double> P;

vector<P> crossPoint(P a, P b)
{
	vector<P> res;
	if (abs(abs(b - a) - 2.0) < EPS)
	{
		P c = a + b;
		res.push_back(P(c.real() / 2, c.imag() / 2));
	}
	else if (abs(b - a) < 2.0)
	{
		P ab = b - a;
		P center = a + P(ab.real() / 2, ab.imag() / 2);
		P un1 = (ab * P(0, +1)) / abs(ab);
		P un2 = (ab * P(0, -1)) / abs(ab);
		double dist = sqrt(1 - pow(abs(ab) / 2, 2));
		P c1 = center + un1 * dist;
		P c2 = center + un2 * dist;
		res.push_back(c1);
		res.push_back(c2);
	}
	return res;
}

void solve()
{
	int n;
	while (cin >> n, n)
	{
		vector<P> p(n);
		for (int i = 0; i < n; ++i)
		{
			double x, y;
			cin >> x >> y;
			p[i] = P(x, y);
		}
		int ans = 1;
		for (int i = 0; i < n; ++i)
		{
			for (int j = i + 1; j < n; ++j)
			{
				vector<P> v = crossPoint(p[i], p[j]);
				if (v.empty())
				{
					continue;
				}
				int countA = 2;
				int countB = 2;
				for (int k = 0; k < n; ++k)
				{
					if (i == k || j == k)
					{
						continue;
					}
					if (abs(v[0] - p[k]) - 1.0 < EPS)
					{
						countA++;
					}
					if (v.size() == 2 && abs(v[1] - p[k]) - 1.0 < EPS)
					{
						countB++;
					}
				}
				ans = max(ans, max(countA, countB));
			}
		}
		cout << ans << endl;
	}
}
int main(void)
{
	solve();
	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_N = 1000000005;

vector<int> prime_factorize(int N){
  vector<int> ret;
  FOR(i, 2, sqrt(N) + 1){
    while(!(N % i)){
      ret.push_back(i);
      N /= i;
    }
  }
  if(N > 1) ret.push_back(N);
  return ret;
}

int main() {
  int N; cin >>N;
  vector<int> ans = prime_factorize(N);
  cout <<N <<":";
  REP(i, ans.size()) cout <<" " <<ans[i];
  cout <<endl;
  return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {
	/* Java のメイン関数 */
	public static void main(String[] a) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		System.out.printf("%d %d\n", w*h, (h+w)*2);
	}
}



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

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

    if(s == "Sunny")
        cout<<"Cloudy";
    else if(s == "Cloudy")
        cout<<"Rainy";
    else if(s == "Rainy")
        cout<<"Sunny";
}


Measured memory_bytes: 256
#include <stdio.h>
 
int a[100][100], b[100];
 
int main()
{
    int i, j, n, m, ans;
    scanf("%d%d", &n, &m);
    for(i=0; i<n; i++) {
        for(j=0; j<m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for(i=0; i<m; i++) {
        scanf("%d", &b[i]);
    }
    for(i=0; i<n; i++) {
        ans=0;
        for(j=0; j<m; j++) {
            ans+=a[i][j]*b[j];
        }
        printf("%d\n", ans);
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;

set<char> good = {'A', 'C', 'G', 'T'};

bool isGood(char c) {
	return good.find(c) != good.end();
}

void solve() {
	//~ freopen("distance.in", "r", stdin);
	//~ freopen("distance.out", "w", stdout);
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr);
	
	
	string str;
	cin >> str;
	int l = 0;
	int r = 0;
	int n = str.size();
	int ans = 0;
	while (r < n) {
		if (isGood(str[r])) {
			ans = max(r - l + 1, ans);
		} else {
			while (r < n && !isGood(str[r]))
				r++;
			if (r == n)
				break;
			l = r;
		}
		r++;
	}
	cout << ans;
}

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




Measured memory_bytes: 256
void main()
{
    long n = rdElem;
    long[] a = rdRow;
    long[] b = rdRow;

    long monster;
    foreach (i; 0 .. n)
    {
        if (b[i] >= a[i])
        {
            monster += a[i];
            long diff = b[i] - a[i];
            long next = min(a[i+1], diff);
            a[i+1] -= next;
            monster += next; 
            a[i] = 0;
        }
        else
        {
            monster += b[i];
            a[i] -= b[i];
        }
    }

    monster.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 10440
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C,D=0;
  str N,N2;
  cin>>N>>N2;
  if(N[0]==N2[2]&&N[1]==N2[1]&&N[2]==N2[0])cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
string t;
void solve()
{
	cin>>s>>t;
}
int main()
{
	solve();
	string ans1="~";
	for(int i=(s.size())-(t.size());i>=0;i--)
	{
		string ans=s;
		int j=0;
		for(;j<t.size();j++)
		{
			if(ans[i+j]!='?'&&ans[i+j]!=t[j])
			break;
			if(ans[i+j]=='?')
			ans[i+j]=t[j];
		}
	 	if(j==t.size())
	 	{
	 		for(int k=0;k<s.size();k++)
	 		{
	 		if(ans[k]=='?')
	 		ans[k]='a';	
			}
	 		ans1=min(ans1,ans);
		}
	}
	if(ans1=="~")
	cout<<"UNRESTORABLE";
	else
	cout<<ans1;
	return 0;
	
}

Measured memory_bytes: 256
//B - Go to Jail
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

#define LL long long
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(int i=A;i<=B;i++)
#define BOR(i,A,B) for(int i=A;i>=B;i--)
#define Lowbit(X) (X & (-X))
#define INF 0x3f3f3f3f
#define Rson (X<<1|1)
#define Lson (X<<1)
using namespace std;
int read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch == '-') f = 1;ch = getchar();}
	while(isdigit(ch)) {x = x*10 + ch - '0';ch = getchar();}
	return f?-x:x;
}
const int N = 2e5+ 100;
int n,a[N],b[N],ans,res;
int main() 
{
	n = read();
	for(int i = 1;i <= n;i++) {
		a[i] = read();b[i] = read();
		if(a[i] == b[i]) res++;
		else res = 0;
		ans = max(res,ans);
	}
	if(ans >= 3) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3636
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ld> vec(n);
    rep(i, n) cin >> vec[i];
    sort(all(vec), greater<ld>());

    ld total = 0;
    rep(i, a){
        total += vec[i];
    }

    ld ave = total / (ld)a;

    ll cnt = 0;
    
    for(int i = a - 1; i >= 0; i--){
        if(vec[a - 1] == vec[i]){
            cnt++;
        }
    }

    ll cnt2 = 0;
    for(int i = a; i < n; i++){
        if(vec[a - 1] == vec[i]){
            cnt2++;
        }
    }

    cmemoInit();

    cout << fixed << setprecision(10) << ave << endl;
    if(cnt != a){
        cout << nCr(cnt2 + cnt, cnt) << endl;
    } else {
        ll ans = 0;
        for(int i = a; i <= b; i++){
            if(cnt2 + cnt < i) continue;
            ans += nCr(cnt2 + cnt, (ll)i);
        }
        cout << ans << endl;
    }


}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
const ll INF = 2*1e18;
const int inf = 1e9+7;

int main(void){
	ll N,K,Q;
	cin >> N >> K >> Q;
	vector<ll> P(N,K-Q);
	for(int i=0;i<Q;i++){
		int a;
		cin >> a;
		a--;
		P[a] ++;
	}
	for(auto x:P){
		if(x>0)cout << "Yes"<< endl;
		else cout <<"No"<<endl;
	}
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int kind=26;
const int INF=1e9;
const int max_queries=5e4;

int main(){
	int D;
	cin >> D;
	vector<int> c(kind);
	rep(i,kind) cin >> c[i];
	int c_sum=0;
	rep(i,kind) c_sum+=c[i];
	vector<vector<int>> s(D,vector<int>(kind));
	rep(i,D){
		rep(j,kind) cin >> s[i][j];
	}
	vector<int> t(D), max_score(D,-INF);
	vector<int> last(kind);
	int dec=0;
	for(int day=1; day<=D; day++){
		int k=-1;
		dec+=c_sum;
		rep(i,kind){
			int res=s[day-1][i];
			res-=dec;
			res+=c[i]*(day-last[i]);
			if(res>max_score[day-1]){
				max_score[day-1]=res;
				k=i;
			}
		}
		dec-=c[k]*last[k];
		last[k]=day;
		t[day-1]=k;
	}
	/*
	vector<set<int>> hold(kind);
	rep(i,kind) hold[i].insert(0);
	rep(i,D) hold[t[i]].insert(i+1);
	*/
	int M=max_queries;
	vector<int> d(M), q(M);
	q[0]=t[0];
	vector<int> t_new(D);
	rep(i,D) t_new[i]=t[i];
	int fin_score=0;
	rep(i,M){
		int ch_ans=0, ch_dec=0;
		vector<int> ch_last(kind);
		set<P> change;	
		t_new[d[i]]=q[i];
		for(int day=1; day<=D; day++){
			int k=t_new[day-1];
			ch_ans+=s[day-1][k];
			ch_dec+=c_sum;
			ch_ans-=ch_dec;
			ch_ans+=c[k]*(day-ch_last[k]);
			ch_dec-=c[k]*(day-ch_last[k]);
			int tot=s[day-1][k]-ch_dec+c[k]*(day-ch_last[k]);
			change.insert(P(tot,day));
			ch_last[k]=day;
		}
		if(fin_score>=ch_ans){
			t_new[d[i]]=t[d[i]];
		}
		else{
			fin_score=ch_ans;
			/*
			hold[t[d[i]]].erase(d[i]+1);
			hold[q[i]].insert(d[i]+1);
			*/
		}
		if(i!=M-1){
			auto itr=change.begin();
			int r=rand()%20, plus=0;
			if(r<=10) plus=0;
			else if (r<=15) plus=1;
			else if (r<=17) plus=2;
			else if (r<=18) plus=3;
			else plus=4;
			rep(j,plus) itr++;
			d[i+1]=(itr->second)-1;
			/*
			int res=-INF, n=-1;
			rep(j,kind){
				auto itr=hold[j].upper_bound(d[i+1]);
				itr--;
				int prev=*itr;
				int dif=c[j]*((d[i+1]+1)-prev);
				if(res<dif){
					res=dif;
					n=j;
				}
			}
			q[i+1]=n;
			*/
			q[i+1]=rand()%26;
		}
	}
	rep(i,D) cout << t_new[i]+1 << endl;

	return 0;
}

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

a = 0

divisors = []
for i in range(1, int(x**0.5)+1):
    if x % i == 0:
        divisors.append(i)
        if i != x // i:
            divisors.append(x//i)

while True:
    for divisor in divisors:
        b = a - divisor
        if a**5-x == b**5:
            break
    else:
        a += 1
        continue
    break

print(a, b)

Measured memory_bytes: 9444
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

#define ll long long

int K, S, ans = 0;

int main(){
    cin >> K >> S;

    for(int i = 0; i <= K;i++)
        for(int j = 0; j <= K; j++){
            int Z = S - i - j;
            if( 0 <= Z && Z <= K) ans++;
        }

    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k; cin >> k;
    ll ans = 0;
    vl t;
    for(ll i=1; i<=k; ++i) {
        for(ll j=1; j<=k; ++j) {
            for(ll kk=1; kk<=k; ++kk) {
                ans += gcd(gcd(i,j),kk);
            }
        }
    }
    ct(ans);
}



Measured memory_bytes: 3692
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;
  
typedef long long LL;
typedef long double LD;
typedef pair<int,int> P;
typedef pair<int,P> P1;
  
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>
  
const LL INF=100000000000000000;
const int dre_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dre_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};
  
int main(){
    while(1){
        int n,m;
        static LL ld[202][202]; rep(i,202)rep(j,202){ if(i==j)ld[i][j]=0; else ld[i][j]=INF; }
        static LL sd[202][202]; rep(i,202)rep(j,202){ if(i==j)sd[i][j]=0; else sd[i][j]=INF; }
          
        scanf("%d%d",&n,&m); if(n==0&&m==0)return 0;
        rep(i,m){
            int x,y,t; char sl;
            scanf("%d%d%d %c",&x,&y,&t,&sl);
            if(sl=='L'){
                ld[x][y]=t;
                ld[y][x]=t;
            }
            else {
                sd[x][y]=t;
                sd[y][x]=t;
            }
        }
          
        rep1(k,n)rep1(i,n)rep1(j,n)ld[i][j]=min(ld[i][j],ld[i][k]+ld[k][j]);
        rep1(k,n)rep1(i,n)rep1(j,n)sd[i][j]=min(sd[i][j],sd[i][k]+sd[k][j]);
          
        /*rep1(i,n){
            rep1(j,n){
                cout<<sd[i][j]<<" ";
            }
            cout<<endl;
        }*/
          
        int r,z[1002];
        static LL dp[1002][202]; rep(i,1002)rep(j,202)dp[i][j]=INF;
          
        scanf("%d",&r);
    	rep(i,r)scanf("%d",&z[i]);
        dp[0][z[0]]=0;
          
        rep1(i,r-1){
            rep1(j,n){
            	dp[i][j]=min(dp[i][j],dp[i-1][j]+ld[z[i-1]][z[i]]);
                if(ld[j][z[i]]!=INF){
                    rep1(k,n){
                        dp[i][j]=min(dp[i][j],dp[i-1][k]+ld[z[i-1]][k]+sd[k][j]+ld[j][z[i]]);
                    }
                }
            }
        }
    	
    	int ret=1000000000;
    	rep1(i,n){
    		ret=min(ret,(int)dp[r-1][i]);
    	}
          
        printf("%d\n",ret);
    }
}

Measured memory_bytes: 3392
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  char s;
  bool f[4]={};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    if(s=='P'){if(!f[0])cnt++;f[0]=true;}
    if(s=='Y'){if(!f[1])cnt++;f[1]=true;}
    if(s=='W'){if(!f[2])cnt++;f[2]=true;}
    if(s=='G'){if(!f[3])cnt++;f[3]=true;}
  }
  cout<<(cnt==3?"Three":"Four")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//---------------------------------------------------------------------------//
int n,m,a[110],b[110];
int main(){
        while(1) {
                cin>>n>>m;
                if(n==0) return 0;
                for(int i=0; i<n; i++) {
                        cin>>a[i];
                }
                for(int i=0; i<m; i++) {
                        cin>>b[i];
                }
                int abc=200;
                int amin,bmin;
                for(int i=0; i<n; i++) {
                        for(int j=0; j<m; j++) {
                                swap(a[i],b[j]);
                                int sum=0;
                                int sum2=0;
                                for(int k=0; k<n; k++) sum+=a[k];
                                for(int k=0; k<m; k++) sum2+=b[k];
                                swap(a[i],b[j]);
                                if(sum==sum2 && abs(a[i]-b[j])<abc) {
                                        abc=abs(a[i]-b[j]);
                                        amin=a[i];
                                        bmin=b[j];
                                }
                        }
                }
                if(abc!=200) cout<<amin<<" "<<bmin<<endl;
                else cout<< -1<<endl;
        }
}

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


class BIT{
    public:
    int size;
    vector<int> tree;
    
    void set(int n){
        size = n;
        tree = vector<int>(n+1, 0);
        return;
    }
    
    void add(int a, int n) {
        int x = n;
        while (x <= size){
            tree[x] += a;
            x += (x & -x);
        }
        return;
    }
    
    int sum(int a) {
        int x = a;
        int sum = 0;
        while (x > 0) {
            sum += tree[x];
            x -= (x & -x);
        }
        return sum;
    }
    
};


int main(){
    int N, K;
    cin >> N >> K;
    
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    
    vector<ll> sum(N+1, 0);
    for (int i = 1; i <= N; i++) sum[i] = sum[i-1] + a[i-1] - K;
    vector<ll> t;
    t = sum;
    sort(t.begin(), t.end());
    auto result = unique(t.begin(), t.end());
    t.erase(result, t.end());
    for (int i = 0; i < N+1; i++) {
        sum[i] = distance(t.begin(), lower_bound(t.begin(), t.end(), sum[i]))+1;
    }
    
    BIT bit;
    bit.set(N+1);
    ll ans = 0;
    for (int i = 0; i < N+1; i++) {
        bit.add(1, sum[i]);
        ans += bit.sum(sum[i]) - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>

main(){
  int i,j,k,w,h,a[20][20],jud,c,x,y;
  char n[22];
  while(1){
    scanf("%d%d",&w,&h);
    if(w==0&&h==0) break;
    for(i=0;i<h;i++){
      scanf("%s",&n);
      for(j=0;j<w;j++){
	if(n[j]=='.') a[j][i]=1;
	else if(n[j]=='#') a[j][i]=0;
	else if(n[j]=='@') {
	  a[j][i]=2;
	  x=j;
	  y=i;
	}
      }
    }
    jud=1;
    c=1;
    for(i=0;i<1100;i++){
      jud=0;
      if(a[x-1][y]==1&&x>0){
	a[x-1][y]=2;
	c++;
	x--;
	jud=1;
      }
      else if(a[x+1][y]==1&&x<w-1){
	a[x+1][y]=2;
	c++;
	x++;
	jud=1;
      }
      else if(a[x][y-1]==1&&y>0){
	a[x][y-1]=2;
	c++;
	y--;
	jud=1;
      }
      else if(a[x][y+1]==1&&y<h-1){
	a[x][y+1]=2;
        c++;
	y++;
	jud=1;
      }
      else{
	for(j=2;j<100;j++){     
	  if(a[x-1][y]==j&&x>0){
	    a[x-1][y]++;	   
	    x--;
	    jud=1;
	    break;
	  }
	  else if(a[x+1][y]==j&&x<w-1){
	    a[x+1][y]++;
	    x++;
	    jud=1;
	    break;
	  }
	  else if(a[x][y-1]==j&&y>0){
	    a[x][y-1]++;	    
	    y--;
	    jud=1;
	    break;
	  }
	  else if(a[x][y+1]==j&&y<h-1){
	    a[x][y+1]++;	  
	    y++;
	    jud=1;
	    break;
	  }
	}
      }
      if(jud==0) break;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 0
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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


use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        e: [u64; n]
    }

    let mut c = HashMap::new();
    for i in e {
        let h = c.entry(i).or_insert(0usize);
        *h += 1;
    }

    let mut c = c.iter().filter(|x| *x.1 > 1).map(|t| (*t.0, *t.1)).collect::<Vec<(u64, usize)>>();
    c.sort_by(|a, b| b.0.cmp(&a.0));

    let mut t = 0;
    let mut p = Vec::new();
    for (k, v) in c {
        if t >= 2 { break; }
        if v >= 4 {
            p.push(k);
            p.push(k);
            t += 2;
        } else if v >= 2 {
            p.push(k);
            t += 1;
        }
    }

    let ans = if p.len() >= 2 { p[0] * p[1] } else { 0 };
    println!("{}", ans);
}


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

using namespace std;

long long a, b;

set<long long> factor(long long a){
    set<long long> factors;
    while(a % 2 == 0){
        a /= 2; 
        factors.insert(2);
    }
    for(long long d = 3; d * d <= a; d += 2){
        while(a % d == 0){
            a /= d;
            factors.insert(d);
        }
    }
    if(a != 1) factors.insert(a);
    return factors;
}

int main(){
    cin >> a >> b;
    set<long long> f1 = factor(a);
    set<long long> f2 = factor(b);
    vector<long long> s;
    set_intersection(f1.begin(), f1.end(), f2.begin(), f2.end(), back_inserter(s));
    cout << s.size() + 1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int h,w;
		Scanner scan = new Scanner(System.in);
		while(true){
			h=scan.nextInt();
			w=scan.nextInt();
			if(h==0&&w==0)
				break;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}		
	}
}


Measured memory_bytes: 33424
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;

vector<int> E[SIZE];
int d[SIZE];

void bfs(int s){
  queue<int> que;
  que.push(s);
  fill(d,d+SIZE,INF);
  d[s] = 0; 
  while(!que.empty()){
    int v = que.front();que.pop();
    for(int to : E[v]) if(d[to] == INF){
      d[to] = d[v]+1;
      que.push(to);
    }
  }
}

int main(){
  cin >> n;
  rep(i,0,n){
    int u,k;
    cin >> u >> k;
    rep(i,0,k){
      int v;
      cin >> v;
      E[u].push_back(v);
    }
  }
  bfs(1);
  rep(i,1,n+1){
    cout << i << " ";
    if(d[i] == INF)cout << -1 << endl;
    else cout << d[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 8628
#include<iostream>
#include<cmath>
using namespace std;
int a, b[20], ok;
int main() {
	while (true) {
		ok = 0;
		cin >> a;
		if (a == -1) { break; }
		for (int i = 0; i < 15; i++) {
			b[i] = (a / (int)pow(4, i)) % 4;
		}
		for (int i = 14; i >= 0; i--) {
			if (b[i] >= 1) { ok = 1; }
			if (ok == 1 || i == 0) {
				cout << b[i];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1200