akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (a + b > c + d){
    cout << "Left" <<endl;
  }else if (a + b < c + d){
    cout << "Right" <<endl;
  }else {
    cout << "Balanced" <<endl;
  }
}

Measured memory_bytes: 256
// Template.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include "bits/stdc++.h"

#pragma region Template

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define llint long long int;

using namespace std;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#pragma endregion

bool is_valid(int num, const vector<bool>& NGs) {
	while (num) {
		if (NGs[num % 10]) return false;
		num /= 10;
	}
	return true;
}

/* Entry Point */
int main()
{
	/* fast_io */
	cin.tie(0);
	ios::sync_with_stdio(false);
	//

	int N, K;
	cin >> N >> K;
	vector<bool> NGs(N, false);
	for (int i = 0; i != K; ++i) {
		int d;
		cin >> d;
		NGs[d] = true;
	}
	int ans = N;
	while (not is_valid(ans, NGs)) ++ans;
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int( 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

int K = 0;
int ans[MAX];
struct edge{
    int to,id;
};
vector<edge> E[MAX];

bool DFS(int v, int color){
    int c = 1;
    itrfor(itr,E[v]){
        if( ans[itr->id] != -1) continue;
        if(c == color) c++;
        ans[itr->id] = c;
        chmax(K,c);
        DFS(itr->to,c);
        c ++;
    }
}

signed main(){
    int n;
    cin >> n;
    REP(i,n) ans[i] = -1;
    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        a --;
        b --;
        E[a].push_back( edge{b,i} );
        E[b].push_back( edge{a,i} );
    }

    DFS(0,-1);

    cout << K << endl;
    REP(i,n-1){
        cout<< ans[i] << endl;
    }

}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n;
  cin >> n;
  if(n % 1000 == 0) {
    cout << 0 << endl;
  } else {
    cout << 1000 - (n % 1000) << endl;
  }
  return 0;
}


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

int main() {
	string S;
	cin >> S;
	int N = S.length();
	vector<int> cnt(N,0);
	int Lg(1), Rg(0);
	for(int i(0);i<N-1;++i){
		if(S[i+1] == 'R'){
			if(i%2==0) Rg++;
			else Lg++;
		}
		if(S[i] == 'R' && S[i+1] == 'L'){
			if(i%2 == 0){
				cnt[i] += Lg; cnt[i+1] += Rg;
			}else{
				cnt[i] += Rg; cnt[i+1] += Lg;
			}
			Lg = Rg = 0;
		}
	}
	Lg = 0;
	Rg = 1;
	for(int i(0);i<N-1;++i){
		if(S[N-2-i] == 'L'){
			if(i%2==0) Lg++;
			else Rg++;
		}
		if(S[N-2-i] == 'R' && S[N-1-i] == 'L'){
			if(i%2 == 0){
				cnt[N-2-i] += Lg; cnt[N-1-i] += Rg;
			}else{
				cnt[N-2-i] += Rg; cnt[N-1-i] += Lg;
			}
			Lg = Rg = 0;
		}
	}
	for(int i(0);i<N;++i) cout << cnt[i] << ' ';
	cout << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<string>
#include<tuple>
using namespace std;
/*
2019/05/26
*/
int main(){
  int n;
  cin>>n;
  vector<tuple<string,int,int>> a;//what tuple?
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;//点数が高いほど小さくなる（上に）
    a.emplace_back(tie(s,p,i));//tie...?
  }
  //sort*tupleのソート
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    cout<<get<2>(a[i])<<endl;
    /*
    string s;
    int p;
    int id;
    tie(s,p,i)=a[i];
    cout<<id<<endl;
    */
  }
  //実装するなら――構造体を用意して比較関数を使う
  //pairの多重もやるっぽいーたくさん要素があるときはtupleがよいです
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  bool is_equal = true;
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
    if(A[i] != B[i]) is_equal = false;
  }

  int max_ind = 0;
  ll min_B = 1e14;
  for(int i = 0; i < N; i++){
    if(A[i] > B[i]){
      chmin(min_B, B[i]);
    }
  }

  ll ans = 0;
  for(int i = 0; i < N; i++){
    ans += A[i];
  }
  ans -= min_B;

  if(is_equal){
    cout << 0 << endl;
  }else{
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>

#define INF 10000000
#define MAX_N 3000000

using namespace std;
using P = pair<int, int>;


long d[MAX_N];       //頂点kから各点への距離
vector<P> G[MAX_N];  //隣接行列
int n, m;
void dijkstra(int k) { 
    fill(d, d + MAX_N, INF);
    d[k] = 0;
    priority_queue<P, vector<P>, greater<P> > que;
    que.push(P(0, k));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int now = p.second;
        if (d[now] < p.first) continue;
        for (auto g : G[now]) {
            int to = g.second;
            long newd = g.first + d[now];
            if (d[to] > newd) {
                d[to] = newd;
                que.push(P(d[to], to));
            }
        }
    }
}

long key(P p) { return (long) p.first * (long)1e9 + p.second; }

int main() {
    cin >> n >> m;
    map<long, int> um;
    for (int i=1; i<=n; i++) um[key({i, -1})] = i;
    int msize = n;
    for (int i=0; i<m; i++) {
        int p, q, c;
        cin >> p >> q >> c;
        long pk = key({p, c}), qk = key({q, c});
        if (um[pk] == 0) {
            msize++;
            um[pk] = msize;
            G[p].push_back({1, um[pk]});
            G[um[pk]].push_back({0, p});
        }
        if (um[qk] == 0) {
            msize++;
            um[qk] = msize;
            G[q].push_back({1, um[qk]});
            G[um[qk]].push_back({0, q});
        }
        G[um[pk]].push_back({0, um[qk]});
        G[um[qk]].push_back({0, um[pk]});
    }
    dijkstra(1);
    cout << (d[n] < INF ? d[n] : -1) << '\n';
    return 0;
}

Measured memory_bytes: 145524
#include<iostream>
#include<string>
using namespace std;
int main(){
	string S;
	cin >> S;
	for (int i = 0; i < 4; i++){
		if (S[i] == S[i + 1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}	 

Measured memory_bytes: 256
use std::io::stdin;

#[allow(dead_code)]
fn input_strs() -> Vec<char> {
    let mut s = String::new();
    match stdin().read_line(&mut s) {
        Ok(_) => s.chars().collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(dead_code)]
fn input_ints() -> Vec<u64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(unused_variables)]
fn solve() {
    let l = input_ints();
    let n = l[0] as usize;
    let m = l[1] as usize;

    let mut city = vec![0; n];

    for _ in 0..m {
        let road = input_ints();
        let a = (road[0] - 1) as usize;
        let b = (road[1] - 1) as usize;
        city[a] += 1;
        city[b] += 1;
    }

    for c in city {
        println!("{}", c);
    }

}

fn main() {
    solve();
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1e3;

int n, m, x[N], y[N], c[2];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", x + i, y + i);
		c[(x[i] + y[i]) & 1]++;
	}
	if (c[0] && c[1]) return puts("-1"), 0;
	printf(c[0] ? "32\n1 " : "31\n");
	for (int i = 30; i >= 0; i--) printf("%d%c", 1 << i, " \n"[!i]);
	for (int i = 1; i <= n; i++) {
		if (c[0]) putchar('R'), x[i]--;
		for (int j = 30; j >= 0; j--)
			if (abs(x[i]) > abs(y[i])) {
				if (x[i] > 0)
					x[i] -= 1 << j, putchar('R');
				else
					x[i] += 1 << j, putchar('L');
			} else {
				if (y[i] > 0)
					y[i] -= 1 << j, putchar('U');
				else
					y[i] += 1 << j, putchar('D');
			}
		puts("");
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORS(i,a,b) for(int i=a+1;i<=b;i++)
#define REP(i,N) FOR(i,0,N)
#define REPS(i,N) FORS(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){REP(i,N){REP(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
const int INF=100000000;
#define MAX_N 3*100000
//--------------------------------------//
int main(){
	cint(n);
	bool s[MAX_N+1000];
	int cnt=0;
	int ans=0;
	REP(i,n){
		char c;
		cin>>c;
		if(c=='W') s[i]=true;
		else {
			s[i]=false;
			if(i!=0)cnt++;
		}
	}
	ans=cnt;
	REPS(i,n-1) {
		if(s[i-1]) cnt++;
		if(!s[i]) cnt--;
		ans=min(cnt,ans);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn enough(v: &Vec<usize>, t: usize, a: usize, b: usize) -> bool {
    let mut t_min = 0;
    let damage = t * b;
    for z in v {
        if damage < *z {
            if (*z - damage) % (a - b) == 0 {
                t_min += (*z - damage) / (a - b);
            } else {
                t_min += 1 + (*z - damage - (*z - damage) % (a - b)) / (a - b);
            }
        }
    }
    if t_min > t {
        false
    } else {
        true
    }
}

fn main() {
    let (n, a, b): (usize, usize, usize);
    input!(n, a, b);
    let mut v = Vec::new();
    for _ in 0..n {
        let buf: usize;
        input!(buf);
        v.push(buf);
    }

    let mut from = 0;
    let mut to = usize::max_value() / 2;

    while to - from > 1 {
        let mid = (from + to) / 2;
        if enough(&v, mid, a, b) {
            to = mid;
        } else {
            from = mid
        }
    }
    p(to);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <queue>
#include <utility>

using namespace std;

typedef pair<int,int> P;

int solve(int h, int w, string *s) {
    int ans = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.')
                ans++;
        }
    }
    int **dist = new int*[h];
    for (int i = 0; i < h; i++) {
        dist[i] = new int[w];
        for (int j = 0; j < w; j++)
            dist[i][j] = -1;
    }
    dist[0][0] = 0;

    queue<P> que;
    que.push(P(0,0));

    int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

    while (!que.empty()) {
        P p = que.front();
        que.pop();
        int y = p.first, x = p.second;

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

            if (ny < 0 || h <= ny || nx < 0 || w <= nx || dist[ny][nx] != -1 || s[ny][nx] == '#')
                continue;
            
            dist[ny][nx] = dist[y][x] + 1;
            que.push(P(ny, nx));
        }
    }

    if (dist[h-1][w-1] == -1)
        return -1;
    else
        return ans - dist[h-1][w-1] - 1;    
}

int main() {
    int h, w;   cin >> h >> w;
    string *s = new string[h];
    for (int i = 0; i < h; i++)
        cin >> s[i];

    cout << solve(h, w, s) << endl;

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int vis[15];
int check(int n)
{
    while(n)
    {

        if(vis[n%10])
            return 0;
        n/=10;
    }
    return 1;
}
int main()
{
    int n,k;
    cin>>n>>k;
    int s;
    for(int i=0;i<k;i++)
    {
        cin>>s;
        vis[s]=1;
    }
    for(int i=n;;i++)
    {
        if(check(i))
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE CPP #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Main where

import qualified Data.Vector.Unboxed as V
import Debug.Trace
import Data.Ord
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Char
import qualified Data.List as L

dump :: (Show a) => a -> IO ()

#if __GLASGOW_HASKELL__ >= 800
dump x = print x
#else
dump _ = pure ()
#endif

-- "101010" -> [1,0,1,0,1,0]
readToList :: String -> [ Int ]
readToList [] = []
readToList (x : xs) = read [ x ] : readToList xs

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getList :: IO [ Int ]
getList = (fmap (read . BS.unpack) . BS.words) <$> BS.getLine

-- "10 10 10" -> [10, 10, 10]
getIntVec :: Int -> IO (V.Vector Int)
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readmat :: Int -> IO [ [ Int ] ]
readmat rows = replicateM rows getList

newtype UF a = UF (M.Map a a)
    deriving ( Show ) -- Map node parent

makeuf :: Int -> UF Int
makeuf n = let m = M.fromList $ zip [ 0 .. n ] [ 0 .. n ] in UF m

unionUF :: ( Eq a, Ord a ) => a -> a -> UF a -> UF a
unionUF l r uf @ (UF m) = let lp = findUF l uf
                              rp = findUF r uf in if lp == rp then uf
    else if size l uf < size r uf then UF $ M.update (const $ Just rp) lp m
        else UF $ M.update (const $ Just lp) rp m

findUF :: ( Eq a, Ord a ) => a -> UF a -> a
findUF x uf @ (UF m) = let px = m M.! x in if px == x then px else findUF px uf -- TODO 貼り直し

size :: ( Eq a, Ord a ) => a -> UF a -> Int
size x (UF m) = M.size $ M.filter (\par -> par == x) m

genbit :: Int -> [ [ Int ] ]
genbit 0 = []
genbit 1 = [ [ 0 ], [ 1 ] ]
genbit len = do
    x <- [ 0, 1 ]
    map (x :) $ genbit (len - 1)

base :: Int
base = 10 ^ 9 + 7

forn :: ( Num a, Enum a, Monad m ) => a -> (a -> m b) -> m [ b ]
forn x = forM [ 0 .. (x - 1) ]

count :: (Eq a) => a -> [ a ] -> Int
count y = length . filter (== y)

f :: Int -> ( Int, Int, Int ) -> [ [ Int ] ] -> Int
f m ( p, q, r ) nss
    = let nss' = L.sortOn (\ns -> let x = (!! 0) ns
                                      y = (!! 1) ns
                                      z = (!! 2) ns in Down $ p * x + q * y + r * z)
              nss in sum $ map (\[ x, y, z ] -> p * x + q * y + r * z) $ traceShowId $ take m nss'

main :: IO ()
main = do
    [ n, m ] <- getList
    nss <- readmat n
    traceShowM nss
    let pqrs = [ ( p, q, r )
               | let piyo = [ 1, -1 ], p <- piyo, q <- piyo, r <- piyo
               ]
    print $ maximum $ map (\pqr -> f m pqr nss) pqrs


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

using namespace std;

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

  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  cout << string(ty-sy,'U')+string(tx-sx,'R') 
       << string(ty-sy,'D')+string(tx-sx,'L') 
       << 'L'+string(ty-sy+1,'U')+string(tx-sx+1,'R')+'D'
       << 'R'+string(ty-sy+1,'D')+string(tx-sx+1,'L')+'U'
       << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define For(i,l,r) for(res i=(l),_=(r);i<=_;++i)
#define Dor(i,l,r) for(res i=(r),_=(l);i>=_;--i)
#define Sor(i,l,r) for(res i=(l),_=(r);i<_;++i)
#define fz(a,b) memset(a,b,sizeof a)
#define qd(a) while(!a.empty())a.pop()
#define JB(a,b)(T[++t]=b,E[t]=H[a],H[a]=t)
#define ll long long
#define N 1001
#define M 1000000007
int A[N][N],K[N],P[N],Q1[N],l1,r1,Q2[N],l2,r2;
int main() {
	int a,t,f,v,w;
	cin>>a,w=a*(a-1)/2;
	For(i,1,a) {
		P[i]=1,Q1[++r1]=i;
		Sor(j,1,a)scanf("%d",&A[i][j]);
	}
	for(t=1;; ++t) {
		f=v=0,fz(K,0);
		if(t&1) {
			r2=0;
			For(i,1,r1) {
				int x=Q1[i];
				if(!K[x]&&P[x]<a) {
					int p=A[x][P[x]];
					if(!K[p]&&A[p][P[p]]==x)++P[x],++P[p],K[x]=K[p]=f=1,--w,Q2[++r2]=x,Q2[++r2]=p;
				}
			}
		} else {
			r1=0;
			For(i,1,r2) {
				int x=Q2[i];
				if(!K[x]&&P[x]<a) {
					int p=A[x][P[x]];
					if(!K[p]&&A[p][P[p]]==x)++P[x],++P[p],K[x]=K[p]=f=1,--w,Q1[++r1]=x,Q1[++r1]=p;
				}
			}
		}
		if(w==0)break;
		if(!f) {
			puts("-1");
			return 0;
		}
	}
	cout<<t;
}

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

int main() {
    int h, n;
    cin >> h >> n;
    int a = 0;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a += t;
    }

    cout << (a >= h ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

//----------------library in this time--------------------------------
template <typename T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <typename T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <typename T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}
//------------------------main function-------------------------------
void Main(){
    u64 n;
    cin >> n;
    if(n < 10){//1 <= n <= 9
        cout << n << endl;
    }else if(n < 100){//10 <= n <= 99
        cout << 9 << endl;
    }else if(n < 1000){//100 <= n <= 999
        cout << 9 + (n - 99) << endl;
    }else if(n < 10000){//1000 <= n <= 9999
        cout << 909 << endl;
    }else if(n < 100000){//10000 <= n <= 99999
        cout << 909 + (n - 9999) << endl;
    }else{//n == 100000
        cout << 90909 << endl;
    }
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    
    Main();
    return 0;
}


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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==7||a==5)
		if(b==7||b==5)
			if(c==7||c==5)
				if(a+b+c==17)
					cout<<"YES";
	else
	{
		cout<<"NO";
	}
	return 0;
}

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

#define int long long
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define moduloP 1e9 + 7

void dfs(int n, vector<bool>& visited, vector < vector< int> >& nodes){
    visited[n] = true;
    for(int i=0;i< (int)nodes[n].size();i++){
        if(visited[nodes[n][i]] == false)
            dfs(nodes[n][i], visited, nodes);
    }
}


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

    int n,m,counts=0;
    cin>>n>>m;

    vector < vector < int > > nodes(n);

    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;

        nodes[x].push_back(y);
        nodes[y].push_back(x);
    }

    vector < bool > visited(n, false);    
    
    for(int i=1;i<=n;i++){
        if(visited[i] == false){
            dfs(i, visited, nodes);
            counts++;
        }
    }

    cout<<counts-1;

    return 0;
}


Measured memory_bytes: 10328
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define mod 1000000007 
#define rep(i,j,l) for(int i=j;i<=l;i++)
#define dec(i,j,l) for(int i=j;i>=l;i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull; 
int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};


int main() {                                     
 ll a,b;
 cin>>a>>b;  
 if(a==1 || b==1)
 cout<<1;
 else {
 a=a*b;
 a=(a+1)/2;
 cout<<a;
 }
}


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

int main() {
	int K, X;
	cin >> K >> X;

	if(K * 500 >= X)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;

int N, D, X, A;

int main() {
	cin >> N >> D >> X;
	for (int i = 0; i != N; ++i) {
		cin >> A;
		for (int i = 1; i <= D; ++i) {
			if ((i - 1) % A == 0)
				++X;
		}
	}
	cout << X << endl;
	return 0;
}

Measured memory_bytes: 256
main = mapM_ (print . solve) . analyze . map (map read . words) . lines =<< getContents
analyze [] = []
analyze ([n]:cs) = as:analyze bs where (as,bs) = splitAt n cs
solve = foldr (\[a,b] c -> ((b-((a+c)`mod`b))`mod`b)+c) 0

Measured memory_bytes: 34428
s = input()[::-1]
length = len(s)
a = [0] * length
d = [0] * length
ans = [0] * 2019
x = 10

a[0] = int(s[0])
d[0] = a[0]
ans[d[0]] += 1

for i in range(1, length):
    a[i] = int(s[i]) * x % 2019
    d[i] = (d[i-1] + a[i]) % 2019
    ans[d[i]] += 1
    x = x * 10 % 2019

ans_c = [i for i in ans if i != 0]

print(int(sum([ans_c[i] * (ans_c[i]-1) for i in range(len(ans_c))]) / 2) + ans[0])

Measured memory_bytes: 23376
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);


int main (){
  ll x,y;
  cin>>x>>y;
  while(x!=0||y!=0){
    if(x<y)cout<<x<<" "<<y<<endl;
    else cout<<y<<" "<<x<<endl;
    cin>>x>>y;
  }
}



Measured memory_bytes: 2980
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
typedef long long LL;
const LL P = 1e9+7;
const int INF = 0x3fffffff;
const int N = 1e5+5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int x;

int main(){
	cin>>x;
	cout<<(x-1>>1)<<endl;
	return 0;
}

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

//最長経路問題 dfs
//visitedは、DAGとしてトポロジカルソートされている場合は初期化いらない
//visitedは到達済み、flagは計算済みでそれぞれ異なる
//隣接リストtoは、頂点数分のサイズを確保

vector<bool> visited; vector<bool> flag;
vector<int> dp;

vector<vector<int>> graph;
    

int dfs(int a){
   
  if( visited[a]){
    if(!flag[a]){ return -1;} //この時、ループ検出, 返す値は問題による点に注意
     else{ return dp[a];}} //メモ化再帰
  
   visited[a] = true; dp[a] = 1; //この値は、始点を0にする場合は0。
  for(int u : graph[a]){
    int res = dfs(u);
    if(res == -1){ return -1;}
    dp[a] = max(dp[a], res+1);}
    flag[a] = true;
  return dp[a];}

int id[1010][1010];

int toId(int a, int b){
  if( a > b){ swap(a,b);}
  return id[a][b];}




int main(){
  int N; cin >> N;
  
  visited = vector<bool> (N*(N-1)/2 + 10,false); 
  flag = vector<bool> (N*(N-1)/2,false);
  vector<vector<int>> to(N); dp.resize(N*(N-1)/2+10); graph.resize(N*(N-1)/2+10);
  
  for(int i = 0; i < 1010; i++){
    for(int j = 0; j < 1010; j++){
      id[i][j] = 0;}}
  
  int cnt = 0;
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if( i >= j){ continue;}
      id[i][j] = cnt;  cnt++;}}
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N-1; j++){
      int a; cin >> a; a--; to[i].push_back(toId(i,a));}
  }
    
    for(int i = 0; i < N; i++){
      for(int j = 0; j < (int) to[i].size() - 1; j++){
        graph[to[i][j]].push_back(to[i][j+1]);}}
    
    //graph　上に　グラフを表現
    int ans = 0;
    for(int i = 0; i < N*(N-1)/2; i++){
      int res = dfs(i);
      if(res == -1){ cout << -1 << endl; return 0;}
      ans = max(res,ans);}
    
    cout << ans << endl; return 0;}
    

Measured memory_bytes: 37760
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define MAX 100000
using namespace std;
typedef long long ll;
int main()
{
	int N, M;
  	int P[MAX], Y[MAX];
  	vector<int> yd[MAX + 1];
  	cin >> N >> M;
  	for (int i = 0; i < M; i++){
    	cin >> P[i] >> Y[i];
      	yd[P[i]].push_back(Y[i]);
    }
  	for (int i = 0; i < N; i++){
    	sort(yd[i + 1].begin(), yd[i + 1].end());
    }
  	for (int i = 0; i < M; i++){
    	printf("%012lld\n", ll(P[i]) * 1000000 + int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin()) + 1);
    }
}

Measured memory_bytes: 7808
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

//#define PI 3.141592653589

using namespace std;



int main()
{
	int l[10];
	int v[2];
	int sum;
	double point;	//すれ違う地点
	int sum2;	//計算に使う駅間の距離の合計
	
	while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
	&l[0], &l[1], &l[2], &l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v[0], &v[1]) != EOF)
	{
		sum = 0;
		sum2 = 0;
		for (int i=0; i<10; i++) sum += l[i];
		//cout << "sum = " << sum << endl;
		point = 1.0 * sum * v[0] / (v[0] + v[1]);
		//cout << "point = " << point << endl;
		for (int i=0; i<10; i++)
		{
			sum2 += l[i];
			if (sum2 >= point)
			{
				cout << i+1 << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1208
let g=print_newline;;let rec f()=Scanf.scanf"%d %d
"(fun h w->if h>0&&w>0then(for i=1to h do let b=ref(i mod 2=0)in for j=1to w do print_char(if!b then '.'else '#');b:=not!b;done;g()done;f(g())));;f()

Measured memory_bytes: 2256
// 143 B - TAKOYAKI FESTIVAL 2019
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    long int tairyoku = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            tairyoku += d[i] * d[j];
        }
    }

    cout << tairyoku << endl;

}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1005;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
char mp[N][N];int vis[N][N],dis[N][N],qx[N*N],qy[N*N],n,m,k,res,sx,sy;
inline int calc(R int x,R int y){
	cmin(res,(x-1+k-1)/k),cmin(res,(n-x+k-1)/k);
	cmin(res,(y-1+k-1)/k),cmin(res,(m-y+k-1)/k);
}
void bfs(){
	int h=1,t=0,x,y,tx,ty;qx[++t]=sx,qy[t]=sy,vis[sx][sy]=1,dis[sx][sy]=0;
	while(h<=t){
		x=qx[h],y=qy[h++];
		if(dis[x][y]==k)continue;
		fp(i,0,3){
			tx=x+dx[i],ty=y+dy[i];
			if(!vis[tx][ty]&&tx>=1&&tx<=n&&ty>=1&&ty<=m)
				++t,qx[t]=tx,qy[t]=ty,vis[tx][ty]=1,dis[tx][ty]=dis[x][y]+1;
		}
	}
	fp(i,1,t)calc(qx[i],qy[i]);
}
int main(){
	scanf("%d%d%d",&n,&m,&k),res=2333333;
	fp(i,1,n){
		scanf("%s",mp[i]+1);
		fp(j,1,m){
			if(mp[i][j]=='S')sx=i,sy=j;
			if(mp[i][j]=='#')vis[i][j]=1;
		}
	}
	bfs();
	printf("%d\n",res+1);
	return 0;
}

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

vector<long long> input(long long N){
  vector<long long> res(N);
  for (int i = 0; i < N; i++)scanf("%lld", &res[i]);
  return res;
}

int main(){
    int N;
    long long A, B;
    long long sum = 0;
    scanf("%d%lld%lld", &N, &A, &B);
    vector<long long> X(N);
    X = input(N);
    for(int i = 1; i < N; i++)sum += min(A * (X[i] - X[i - 1]), B);
    printf("%lld\n", sum);
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main ()
{
    int a,b ;
    scanf("%d%d",&a,&b);
    if (b%a==0)
    {
        printf("%d\n",a+b);
    }
    else
    {
        printf("%d\n",b-a);
    }
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair <int,int> PAIR;
const int maxn = 5e5 + 7;
const double pi = acos(-1);
const ll mod = 1e9 + 7;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

int main(){
    int n;
    scanf("%d",&n);
    n %= 1000;
	if(n) printf("%d\n",1000-n);
	else printf("0\n"); 
}

Measured memory_bytes: 3812
import math

A, B, H, M = map(int,input().split())
A_d = math.radians(30 * H + 0.5 * M)
B_d = math.radians(M * 6)

A_g = (math.cos(A_d) * A, math.sin(A_d) * A)
B_g = (math.cos(B_d) * B, math.sin(B_d) * B)

D = ((A_g[0] - B_g[0]) ** 2 + (A_g[1] - B_g[1]) ** 2) ** 0.5

print(D)

Measured memory_bytes: 62620
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int h, w;
	char c[100][100];
	cin >> h >> w;
	REP(i, h){
		REP(j, w){
			cin >> c[i][j];
		}
	}

	REP(i, h){
		REP(k, 2){
			REP(j, w){
				cout << c[i][j];
			}
			cout << endl;
		}
	}
	rtn 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) throws IOException {
        int buf, lose = 0;
        while ((buf = System.in.read()) != '\n') {
            if (buf == 'x') lose++;
        }
        
        if (lose < 8) System.out.print("YES");
        else System.out.print("NO");
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32512
#include <iostream>
#include <algorithm>
#include <functional>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int mod = 1000000007;
int n;
int c[200000];
int fact[200001];
int factInv[200001];

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 1) return (a * powmod(a, n - 1, mod)) % mod;
	return powmod((a * a) % mod, n / 2, mod);
}

int comb(int n, int k) {
	return fact[n] * factInv[k] % mod * factInv[n - k] % mod;
}

signed main() {
	int i, j;
	
	fact[0] = 1;
	factInv[0] = 1;
	rep(i, 200000) {
		fact[i + 1] = (i + 1) * fact[i] % mod;
		factInv[i + 1] = powmod(fact[i + 1], mod - 2, mod);
	}
	
	cin >> n;
	rep(i, n) cin >> c[i];
	sort(c, c + n, greater<int>());
	
	int ans = 0;
	int s = 1;
	rep(i, n) {
		ans += s * c[i] % mod * powmod(2, n - 1 - i, mod) % mod;
		ans %= mod;
		s = 2 * s + powmod(2, i, mod);
		s %= mod;
	}
	ans *= powmod(2, n, mod);
	ans %= mod;
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
N,W=map(int,input().split())
listN=[[0 for i in range(W+1)] for k in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for k in range(1,W+1):
    if k>=w:
      listN[i+1][k]=max(listN[i][k],listN[i][k-w]+v)
    else:
      listN[i+1][k]=listN[i][k]     
ans=listN[N][W]
print(ans)

Measured memory_bytes: 171400
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif
string s;
string t;
cin>>s>>t;

ll count=0;
for (int i = 0; i < s.length(); ++i)
{
	if (s[i]==t[i])
	{
		count++;
		/* code */
	}
	/* code */
}
cout<<count<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

//Monday-Saturday Prime Factors
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] msf = new int[85713];
		int id = 0;
		msf[id++] = 6;
		for(int i=7;i<300000;i+=7){
			if(i+1<300000){
				msf[id++] = i+1;
			}
			if(i+6<300000){
				msf[id++] = i+6;
			}
		}
		boolean[] mspf = new boolean[300000];
		Arrays.fill(mspf, true);
		for(int i=0;i<85713;i++){
			int x = msf[i];
			if(mspf[x]){
				for(int j=2*x;j<300000;j+=x){
					mspf[j] = false;
				}
			}
		}
		while(true){
			int x = sc.nextInt();
			if(x==1)break;
			System.out.print(x + ":");
			PriorityQueue<Integer> q = new PriorityQueue<Integer>();
			for(int i=0;i<85713;i++){
				if(x < msf[i])break;
				if(mspf[msf[i]] && x%msf[i]==0){
					if(!q.contains(msf[i]))q.add(msf[i]);
				}
			}
			while(!q.isEmpty())System.out.print(" " + q.poll());
			System.out.println();
		}
	}
}

Measured memory_bytes: 13000
#!/usr/bin/env python3
from collections import defaultdict

(n, ), *p = [[*map(int, i.split())] for i in open(0)]
d = defaultdict(int)
for i in range(n):
    for j in range(n):
            d[(p[i][0] - p[j][0], p[i][1] - p[j][1])] += i!=j
print(n - max(d.values()))


Measured memory_bytes: 9656
#include<cstdio>
#include<ctype.h>
#include<cstring>
#include<string>
#include<iostream>
using namespace std;

int sum = 0;
string W, T;

int main(void){
    cin >> W;
    for (int i = 0; i < W.size(); i++){
            if (isupper(W[i])) W[i] = tolower(W[i]);
    }
    while(1){
        cin >> T;
        if (T == "END_OF_TEXT") break;
        for (int i = 0; i < T.size(); i++){
            if (isupper(T[i])) T[i] = tolower(T[i]);
        }
        if (T == W) sum++;
    }
    printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 3236
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n; cin >> n, n;){
        vvi t(n, vi(n + 1));
        rep(i, n){
            rep(j, n + 1){
                cin >> t[i][j];
            }
        }

        vi dp(1 << n, inf);
        dp[0] = 0;

        rep(j, 1 << n){
            rep(k, n){
                if(j & (1 << k)){
                    int m = t[k][0];
                    rep(l, n){
                        if(l == k || !(j & (1 << l))) continue;

                        m = min(m, t[k][l + 1]);
                    }
                    dp[j] = min(dp[j], dp[j & (~(1 << k))] + m);
                }
            }
        }

        cout << *(dp.end() - 1) << endl;
    }

	return 0;
}

Measured memory_bytes: 1476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> cities(n);
    rep(i, n) cin >> cities[i];
    cities.push_back(x);
    sort(cities.begin(), cities.end());
    if(n == 1){
        cout << cities[1] - cities[0] << endl;
        return 0;
    }
    
    ll ans;
    ans = __gcd(cities[1] - cities[0], cities[2] - cities[1]);
    for(int i = 3; i < n + 1; i++){
        ans = __gcd(ans, cities[i] - cities[i - 1]);
    }

    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define maxn 16
using namespace std;
 
int arr[maxn][maxn] = {};
int dp[1 << maxn], sum[1 << maxn] = {};
int n;
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> arr[i][j];
        }
    }

    //soma de todos os grupos possiveis
    for(int S = 0; S < (1 << n); S++) {
        for(int j = 0; j < n; j++) {
            if(!(S & (1 << j))) continue;
            for(int k = j + 1; k < n; k++) {
                if(S & (1 << k)) {
                    sum[S] += arr[j][k];
                }
            }
        }
    }
    for(int S = 0; S < (1 << n); S++) {
        int x = S;
        dp[x] = sum[x];
        while(x) {
            x = (x - 1) & S;

            /*
            dp[S] = soma de todos do grupo
            dp[S ^ x] + sum[x] = soma do grupo(S ^ x) e do grupo(x)
            ex: dp[S] = soma do 1,2;1,3;2,3
				mas a soma de S posso fazer tambem um grupo {2,3} + {1} ou {1,3} + {2} ou {1,2} + {3}->esse ele nao calcula	
			*/
            dp[S] = max(dp[S], dp[S ^ x] + dp[x]);
        }
    }
    cout << dp[(1 << n) - 1] << '\n';
    return 0;
}

Measured memory_bytes: 4572
using System;

namespace ConsoleApplication17
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                string[] str = Console.ReadLine().Split(' ');
                int W = int.Parse(str[0]);
                int H = int.Parse(str[1]);
                int x = int.Parse(str[2]);
                int y = int.Parse(str[3]);
                int r = int.Parse(str[4]);
                if ( x > 0 && y > 0 && (x - r) >= 0 && (x + r) <= W && (y - r) >= 0 && (y + r) <= H)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
                
            }
        }
    }
}

Measured memory_bytes: 8864
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
unordered_map<int,vector<int> >  nei[100005];
unordered_map<int,int> dp[100005];
vector<pair<int,int> >alnei[100005];
struct Node
{
	int cost,color,v;
	Node (int cos,int col,int u)
	{
		cost=cos;
		color=col;
		v=u;
	}
	bool operator <(Node a) const
	{
		return cost>a.cost;
	}
};
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		x--,y--;
		nei[x][z].push_back(y);
		nei[y][z].push_back(x);
		alnei[x].push_back(make_pair(y,z));
		alnei[y].push_back(make_pair(x,z));
	}
	priority_queue<Node> q;
	q.push(Node(0,0,0));
	while(!q.empty())
	{
		Node tmp=q.top();
		q.pop();
		int v=tmp.v,cost=tmp.cost,col=tmp.color;
		if(dp[v][col]!=cost) continue;
		if(dp[v].find(0)==dp[v].end()||dp[v][0]>cost)
		{
			dp[v][0]=cost;
			q.push(Node(cost,0,v));
		}
		if(col==0)
		{
			for(int i=0;i<alnei[v].size();i++)
			{
				int u=alnei[v][i].first,colu=alnei[v][i].second;
				if(dp[u].find(colu)==dp[u].end()||dp[u][colu]>cost+1)
				{
					dp[u][colu]=cost+1;
					q.push(Node(cost+1,colu,u));
				}
			}
			continue;
		}
		for(int i=0;i<nei[v][col].size();i++)
		{
			int u=nei[v][col][i],colu=col;
			if(dp[u].find(colu)==dp[u].end()||dp[u][colu]>cost)
			{
				dp[u][colu]=cost;
				q.push(Node(cost,colu,u));
			}
		}
	}
	int mi=1e9;
	for(unordered_map<int,int>::iterator it=dp[n-1].begin();it!=dp[n-1].end();it++)
	{
		mi=min(it->second,mi);
	}
	if(mi==1e9) cout<<-1; else cout<<mi;
}

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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int ans = 0;
		for(int i = 0; i < k; i++) {
			ans += a[i];
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32964