akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

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

    string ans = "";
    while(n != 0){
        if(n % 2 != 0){
            n--;
            ans = "1" + ans;
        }else{
            ans = "0" + ans;
        }
        n /= -2;
    }

    if(ans == "")
        ans = "0";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<deque>
using namespace std;
int main()
{
    deque<int> d;
    int T;
    cin>>T;
    while(T--)
    {
        int q;
        cin>>q;
        if(q==0)
        {
            int c,n;
            cin>>c>>n;
            if(c==0)
            {
                d.push_front(n);
            }
            else
            {
                d.push_back(n);
            }
        }else if(q==1)
        {
            int n;
            cin>>n;
            cout<<d[n]<<endl;
        }
        else
        {
            int n;
            cin>>n;
            if(n==0)
            {
                d.pop_front();
            }
            else
            {
                d.pop_back();
            }
        }
    }
}


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

int main()
{
    int n;
    scanf("%d", &n);
    int ok = 0;
    while(n)
    {
        if(n%10 == 9)ok = 1;
        n /= 10;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
/* dijkstra.cpp
    ダイクストラ法で、ある頂点から各頂点への最短距離を求めるアルゴリズム
    負の辺が含まれる場合はうまく計算出来ないので、ベルマンフォード法を用いる

    verified: AOJ GRL_1_A
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
*/

#include <bits/stdc++.h>
using namespace std;
// 1次元 vector
template <class T>
ostream &operator<<(ostream &s, vector<T> vec) {
    for (int i = 0; i < (int)vec.size(); ++i) {
        if (i > 0) {
            s << " ";
        }
        s << vec[i];
    }
    return s << endl;
}

using ll = long long;
template <typename T>
struct Edge {
    int to;
    T cost;
};
using Graph = vector<vector<Edge<long long>>>;  // 距離/コストの型 T を指定する
const ll INF = (1LL << 60);                     // 型 T のINF (完全な最大値は取らないように)

/* dijkstra(G,s,dis,prev)
    入力：グラフ G, 開始点 s, 距離を格納する dis, 最短経路の前の点を記録するprev
    計算量：O(|E|log|V|)
    副作用：dis, prevが書き換えられる
*/
template <typename T>
void dijkstra(const Graph &G, int s, vector<T> &dis, vector<ll> &cnt) {
    using P = pair<T, int>;
    int N = G.size();
    dis.resize(N, INF);
    cnt.resize(N, 0);
    cnt[s] = 1;
    priority_queue<P, vector<P>, greater<P>> pq;  // the least element is top. first:cost, second: node
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();  // the least element
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {
            continue;
        }
        for (auto &e : G[v]) {
            if (dis[e.to] > dis[v] + e.cost) {
                dis[e.to] = dis[v] + e.cost;
                pq.emplace(dis[e.to], e.to);
                cnt[e.to] = cnt[v];
            } else if (dis[e.to] == dis[v] + e.cost) {
                cnt[e.to] += cnt[v];
            }
        }
    }
}

using ull = unsigned long long;
//const int MOD = 1e9 + 7;

int N, M, K, Q, X, Y;
string S;

int main() {
    cin >> N >> X >> Y;
    Graph G(N);
    for (int i = 0; i < N - 1; i++) {
        G[i].push_back({i + 1, 1LL});
        G[i + 1].push_back({i, 1LL});
    }
    G[X - 1].push_back({Y - 1, 1LL});
    G[Y - 1].push_back({X - 1, 1LL});

    vector<ll> cnt_sum(N, 0);
    for (int i = 0; i < N; i++) {
        vector<ll> dis(N, INF);
        vector<ll> cnt(N, 0);
        dijkstra(G, i, dis, cnt);
        for (int j = 0; j < N; j++) {
            if (dis[j] < N) cnt_sum[dis[j]]++;
        }
    }

    for (int i = 1; i <= N - 1; i++) {
        cout << cnt_sum[i] / 2 << "\n";
    }

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (unsigned int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    ll A,B,C,D,N;
    ll ans=0;
    ll X[4];
    string S[4];
int main(){
    cin>>A>>B;
    cout<<(A*3+B)/2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N;
  cin>>N;
  int i;
  string S;
  for(i=0;i<N;i++){
    cin>>S;
    if(S=="Y"){
      cout<<"Four"<<endl;
      break;
    }
    else if (i==N-1){
      cout<<"Three"<<endl;
    }
  }
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;


void main(){
	auto n = readInt();
	const string[char] cmap = [
		'1': ".,!? ",
		'2': "abc",
		'3': "def",
		'4': "ghi",
		'5': "jkl",
		'6': "mno",
		'7': "pqrs",
		'8': "tuv",
		'9': "wxyz"
	];
	for(int i = 0; i < n; ++i) {
		string ans;
		string s = readln().strip();
		while(!s.empty) {
			while(!s.empty && s[0] == '0') {
				s = s.drop(1);
			}
			if(s.empty) {
				break;
			}
			char c = s[0];
			int count;
			while(!s.empty && s[0] == c) {
				s = s.drop(1);
				++count;
			}
			ans = ans ~ cmap[c][(count-1) % cmap[c].length];
		}
		writeln(ans);
	}
}

Measured memory_bytes: 2688
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>

#define REP(i,n) for(int i = 0; i < int(n); i++)

using namespace std;
using ll = long long;


int main() {
	string X, Y, A, B, C, D, E, F;
	A = "A";
	B = "B";
	C = "C";
	D = "D";
	E = "E";
	F = "F";
	cin >> X >> Y;
	int x, y;
	if (X[0] == A[0]) x = 10;
	if (X[0] == B[0]) x = 11;
	if (X[0] == C[0]) x = 12;
	if (X[0] == D[0]) x = 13;
	if (X[0] == E[0]) x = 14;
	if (X[0] == F[0]) x = 15;
	if (Y[0] == A[0]) y = 10;
	if (Y[0] == B[0]) y = 11;
	if (Y[0] == C[0]) y = 12;
	if (Y[0] == D[0]) y = 13;
	if (Y[0] == E[0]) y = 14;
	if (Y[0] == F[0]) y = 15;
	if (x < y) cout << "<" << endl;
	if (x > y) cout << ">" << endl;
	if (x == y) cout << "=" << endl;
	return 0;
}

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

public class Main{

	public static void main(String args[]){
		new Main().mainrun();
	}

	private Scanner scan;

	private int height[];

	private void mainrun() {
		scan = new Scanner(System.in);

		height = new int[10];

		for(int i = 0;i < 10;i++) {
			height[i] = scan.nextInt();
		}

		Arrays.sort(height);;

		for(int i = 0;i < 3;i++) {
			System.out.println(height[height.length - i - 1]);
		}

		scan.close();

	}
}


Measured memory_bytes: 26228
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define dump(x) cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else
const bool test = false;
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

signed main()
{
    cout << fixed << setprecision(20);
    solve();
    while (true)
    {
        char s[MAX];
        if (scanf("%s", s) == EOF)
            break;
        int n = strlen(s);
        for (int i = n - 1; i > -1; i--)
        {
            ungetc(s[i], stdin);
        }
        solve();
    }
    return 0;
}

int x;

void solve() {
    cin >> x;
    int res = x / 11 * 2;
    x %= 11;
    if (x > 6) res += 2;
    else if (x > 0) res += 1;
    cout << res << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main(){
    var s int
    fmt.Scan(&s)
   
    fmt.Printf("%d\n", solve(s))
}


func solve(s int) int {
    max := 1000001
    a := make([]int, max)
    
    a[1] = s
    for i:=2; i<max; i++ {
        a[i] = fn(a[i-1])
        for j:=1; j<i; j++{
            if a[i] == a[j] {
                return i
            }
        }
    }
    return -1
}

func fn(n int) int{
    if n %2 == 0 {
        return n/2
    }else{
        return 3*n + 1
    }
}


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

typedef pair<int,int> P;
const int INF = 500000000;

int main(){
    int n;
    cin >> n;
    ll save[200010];
    ll a[200010];
    ll sum = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        save[a[i]]++;
    }
    for (int i = 1; i <= n; i++){
        sum += save[i]*(save[i]-1)/2;
    }
    for (int i = 0; i < n; i++){
        ll res;
        ll hoge = save[a[i]]-1;
        res = sum - ( (save[a[i]]*(save[a[i]]-1)/2) - (hoge*(hoge-1)/2) );
        cout << res << "\n";
    }
}

Measured memory_bytes: 5504
a,b,c,k = map(int,input().split())

t= 0

if k < a:
    t += k
    k = 0
else:
    t += a
    k = k -a

if k < b:
    k = 0
else:
    k = k -b

if k < c:
    t += k*-1
    k = 0
else:
    t += c*-1

print(t)

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    
    ll res1 = -1;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        res1 = max(res1, a[i]);
    }

    ll diff = 1001001001;
    ll res2 = -1;
    for(int i = 0; i < n; ++i){
        if(a[i] == res1) continue;
        if(abs(res1 - a[i]*2) < diff){
            diff = abs(res1 - a[i]*2);
            res2 = a[i];
        }
    }

    cout << res1 << " " << res2 << endl;


}

Measured memory_bytes: 3952
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))

char m[55][55];
int h,w;
bool f(int a,int b)
{
    if(a<h&&a>=0&&b<w&&b>=0&&m[a][b]=='#'){ return true;
    }
    return false;
}
int dir[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
int main()
{
    //ios::sync_with_stdio(0);cin.tie(0);
    while(~scanf("%d%d",&h,&w)){
        for(int i=0;i<h;i++) scanf("%s",m[i]);
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(f(i,j)){printf("#");continue;}
                int ans=0;
                for(int k=0;k<8;k++){
                    if(f(i+dir[k][0],j+dir[k][1])) ans++;
                }
                printf("%d",ans);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;


    class MainClass
    {
    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());

        string[] input1 = Console.ReadLine().Split(' ');

        int[] A = new int[N-1];

      

        int[] result = new int[N];

        for(int i = 0; i <= N - 2; i++)
        {
            A[i] = int.Parse(input1[i]);

            result[A[i]-1]++;
        }


        for (int i = 0; i <= N - 1; i++)
        {
            Console.WriteLine(result[i]);
        }
    }
}

Measured memory_bytes: 39036
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15

/* Debug Begins */ 
# define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(bool f) { if(f) return "True"; else return "False";}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
/***************************************************************/



signed main()
{
    ios_base::sync_with_stdio(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        int n;
        cin >> n;
        vector<int> a(n);
        int x = 0;
        rep(i,0,n) cin >> a[i];
        rep(i,0,n) x ^= a[i];
        rep(i,0,n) cout << (a[i] ^ x) << " ";
    }
}

Measured memory_bytes: 4840
fun main(args: Array<String>) = yorukatsu14a()

fun yorukatsu14a() {
    val (a, b, k) = readLine()!!.split(' ').map { it.toInt() }

    val div = mutableListOf<Int>()

    for (i in 1..Math.max(a, b)) {
        if (a % i == 0 && b % i == 0) div.add(i)
    }

    val answer = div[div.lastIndex - k + 1]

    println(answer)
}


Measured memory_bytes: 36416
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w;
    cin>>h>>w;
    int a[h][w];
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            char c;
            cin>>c;
            if(c=='.')
            {
                a[i][j]=1;
            }
            else
            {
                a[i][j]=0;
            }
        }
    }
    int dp[h][w];
    int x=0;
    for (int i=0;i<h;i++)
    {
        dp[i][0] = 1-x;
        if(a[i][0]==0)
        {
            dp[i][0]=0;
            x=1;
        }
    }
    x=0;
    for (int i=0;i<w;i++)
    {
        dp[0][i] = 1-x;
        if(a[0][i]==0)
        {
            dp[0][i]=0;
            x=1;
        }
    }
    for(int i=1;i<h;i++)
    {
        for(int j=1;j<w;j++)
        {
            if(a[i][j]==0)
            {
                dp[i][j]=0;
            }
            else
            {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007;
            }
        }
    }
    cout<<dp[h-1][w-1];
    /*for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    return 0;
}









Measured memory_bytes: 8064
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Builder as BSB
import System.IO (stdout)
import Data.Monoid

warshallFloyd1 :: Int -> U.Vector (Int, Int, Int) -> V.Vector (U.Vector Int)
warshallFloyd1 !n !edges = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  U.forM_ edges $ \(a,b,c) -> do
    UM.unsafeWrite (arr `V.unsafeIndex` a) b c
    UM.unsafeWrite (arr `V.unsafeIndex` b) a c
  forM_ [0..n-1] $ \a -> do
    UM.unsafeWrite (arr `V.unsafeIndex` a) a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr `V.unsafeIndex` k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr `V.unsafeIndex` i
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.unsafeRead a_i k
        a_kj <- UM.unsafeRead a_k j
        UM.unsafeModify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

warshallFloyd2 :: Int -> Int -> V.Vector (U.Vector Int) -> V.Vector (U.Vector Int)
warshallFloyd2 !n !l !graph = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  forM_ [0..n-1] $ \a -> do
    let !a_a = arr `V.unsafeIndex` a
    forM_ [0..n-1] $ \b -> do
      let v = graph `V.unsafeIndex` a `U.unsafeIndex` b
      when (v <= fromIntegral l) $ do
        UM.unsafeWrite a_a b 1
    UM.unsafeWrite a_a a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr `V.unsafeIndex` k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr `V.unsafeIndex` i
      forM_ [0..n-1] $ \j -> do
        a_ik <- UM.unsafeRead a_i k
        a_kj <- UM.unsafeRead a_k j
        UM.unsafeModify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

main = do
  [n,m,l] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM m $ do
    [a,b,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a-1,b-1,c)
  let !w1 = warshallFloyd1 n edges
      !w2 = warshallFloyd2 n l w1
  q <- readLn
  queries <- U.replicateM q $ do
    [s,t] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (s,t)
  BSB.hPutBuilder stdout $ mconcat [ BSB.intDec (if d > 10^9 then -1 else d - 1) <> BSB.char7 '\n' | (s,t) <- U.toList queries, let d = w2 `V.unsafeIndex` (s-1) `U.unsafeIndex` (t-1) ]


Measured memory_bytes: 7676
import java.util.Scanner;

public class Main {
	int[] aArr;
	int aSize;
	int cnt;

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		aArr = new int[n];
		for (int i = 0; i < n; i++) {
			aArr[i] = sc.nextInt();
		}
		aSize = n;
		int q = sc.nextInt();

		for (int i = 0; i < q; i++) {
			boolean ans = rec(0, sc.nextInt());
			if (ans) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
		sc.close();
	}

	boolean rec(int n, int m) {
		if (m == 0) {
			return true;
		}
		if (n >= aSize) {
			return false;
		}
		if (m < 0) {
			return false;
		}
		return (rec(n + 1, m) || rec(n + 1, m - aArr[n]));
	}
}

Measured memory_bytes: 26888
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if (a.equals(b)) {
			System.out.println("H");
		} else {
			System.out.println("D");
		}
	}
}


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

long long N, K, A[1 << 18], dp[1 << 22];
long long pos[1 << 18];

void add(int pos) {
	pos += (1 << 20);
	while (pos >= 1) {
		dp[pos]++;
		pos >>= 1;
	}
}

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) A[i] ^= A[i - 1];
	for (int i = 1; i <= N; i++) pos[i] = 1;

	long long sum = 0, ans = 0;
	for (int i = 19; i >= 0; i--) {
		for (int j = 0; j < (1 << 21); j++) dp[j] = 0;

		add(0); long long prelim = sum;
		for (int j = 1; j <= N; j++) {
			if ((A[j] / (1LL << i)) % 2 == 0) { prelim += dp[pos[j] * 2 + 1]; }
			else { prelim += dp[pos[j] * 2]; }
			add(A[j]);
		}

		if (prelim < K) {
			// 答えは一定以下
			sum = prelim;
			for (int j = 1; j <= N; j++) {
				if ((A[j] / (1LL << i)) % 2 == 0) { pos[j] = pos[j] * 2; }
				else { pos[j] = pos[j] * 2 + 1; }
			}
		}
		else {
			// 答えは一定以上
			ans += (1 << i);
			for (int j = 1; j <= N; j++) {
				if ((A[j] / (1LL << i)) % 2 == 0) { pos[j] = pos[j] * 2 + 1; }
				else { pos[j] = pos[j] * 2; }
			}
		}
	}

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


Measured memory_bytes: 21040
#include<stdio.h>

int main(void)
{
	int i,j,s;
		for(i=1;i<=9;i++){
			for(j=1;j<=9;j++){
			s=i * j;
			printf("%dx%d=%d\n",i,j,s);
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,a;a=0;
    scanf("%d",&n);
    for(i=1;;i++)
    {
        a+=i;
        if(a>=n)
        {
            printf("%d",i);
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();	//トッピングの種類
		int baseprice = sc.nextInt();	//生地の値段
		int	topprice  = sc.nextInt();	//トッピングの値段
		int basecal = sc.nextInt();	//生地のカロリー
		int topcal [] = new int[N];
		for(int i = 0; i < N; i++){
			topcal [i] = sc.nextInt();	//トッピングのカロリー
		}
		Arrays.sort(topcal);
		for(int i=N;i>0;i--){
			if((basecal+topcal[i-1])/(baseprice+topprice)>=(basecal/baseprice)){
				basecal += topcal[i-1];
				baseprice += topprice;
				}
			}
		System.out.println(basecal/baseprice);
	}

}

Measured memory_bytes: 18336
# -*- coding: utf-8 -*-
n = int(input())
h = list(map(int, input().split()))

ans = 0
for i in range(n):
  ans += 1 if (i == 0) or ((i == 1) and (h[0] <= h[i])) or ((i > 1) and (max(h[:i]) <= h[i])) else 0

print(ans)

Measured memory_bytes: 3192
#include<stdio.h>
#include<math.h>


int main(void){


  int n, money=100000;
  int i;

  while(scanf("%d", &n)!=EOF){

    for(i=0; i<n; i++){
      money*=(1.05);
      if(money%1000 != 0){
	money = money / 1000 * 1000 + 1000;
      }
    }
    printf("%d\n", money);
  } 
  

  return(0);
}



Measured memory_bytes: 2044
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<set>
#include<vector>
#include<queue>
using namespace std;
#define in 0x3f3f3f
const int maxx = 2e6 + 100;
long long int cnt[maxx];
long long int vis[maxx];
int main()
{
   long long int n,m, l, r, maxn, minn;
   scanf("%lld%lld", &n,&m);
   maxn = -1;
   minn = in;
   memset(cnt, 0, sizeof(cnt));
   for(int i = 0; i < m; i++)
   {
       cin >> l >> r;
       vis[l]++;
       vis[r + 1]--;
       maxn = max(maxn, r);
       minn = min(minn, l);
   }
   for(int i = minn; i <= maxn; i++)
       vis[i] += vis[i - 1];
   for(int i = minn; i <= maxn; i++)
       cnt[vis[i]]++;
    cout<< cnt[m];
   return 0;
}


Measured memory_bytes: 17920
#include<iostream>
#include<algorithm>
using namespace std;
int n, k;
int a[100011];
int dp[100011];
int main (void) {
	cin>>n>>k;
	for(int i = 1; i <= n; i++){
		cin>>a[i];
	}
	dp[0] = 0;
	dp[1] = 0;
	for(int i = 2; i <= n; i++){
		dp[i] = 1234567890;
		for(int j = 1; j <= k; j++){
			if(i <= j) break;
			dp[i] = min(dp[i], dp[i - j] + abs(a[i - j] - a[i]));
		}
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}
ll s[N];
int main()
{
	ll n,i,j,k;
	sl(n);
	ll sum = 0;
	for(i = 0;i < n;i++)
		sl(s[i]),sum+=s[i];
	double ave = sum*1.0/n;
	double maxx = 1e18;
	ll pos = 0;
	for(i = 0;i < n;i++)
	{
		if(fabs(s[i]-ave) < maxx)
		{
			maxx = fabs(s[i]-ave);
			pos = i;
		}
	}
	printf("%lld\n",pos);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main(){
  //入力
  int N;
  cin>>N;
  vector<unsigned long long>A(N+1);
  vector<unsigned long long>B(N);
  unsigned long long cnt=0;
  for(int i=0;i<N+1;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
  }
  for(int i=N;i>0;i--){
    if(A[i]>B[i-1]){
      cnt+=B[i-1];
    }else{
      cnt+=A[i];
      if(A[i-1]<=B[i-1]-A[i]){
        cnt+=A[i-1];
        A[i-1]=0;
      }else{
        cnt+=(B[i-1]-A[i]);
        A[i-1]-=(B[i-1]-A[i]);
      }
    }
  }
  //出力
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 1792
a, b, deg = STDIN.gets.split.map(&:to_i)
rad = deg * Math::PI / 180.0
puts "%.8f\n%.8f\n%.8f" % [
  0.5 * a * b * Math.sin(rad),
  a + b + (a ** 2 + b ** 2 - 2 * a * b * Math.cos(rad)) ** 0.5,
  b * Math.sin(rad)
]

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

#define PAUSE system("pause")
#define LLI long long int
#define LD long double
#define PB push_back
#define PF push_front
#define MP make_pair
#define FORi(i, a, b) for(int i = a; i < b ; ++i)
#define FORd(i, a, b) for(int i = a; i > b ; --i)

using namespace std;

const int MOD = 1e9+7;

int main() {	
//	ifstream fin("in.txt");
//	ofstream fout("out.txt");
	
	int n;
	cin >> n;
	vector<int> x(n);
	FORi(i,0,n){
		cin >> x[i];
	}
	
	LLI ans = 1, place = 1;
	FORi(i,1,n){
		place += x[i-1] <= 2*(i-place);
//		cout << place << ' ';
		ans *= (i + 2 - place);
		ans %= MOD;
	}
//	cout << endl;
	
	cout << ans;
//	PAUSE;
//	fin.close();
//	fout.close();
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();

            if(H == 0 && W == 0) break;
            else{
                for(int i=0; i<H; i++){
                    for(int j=0; j<W; j++){
                        if(i == 0 || i == H-1){
                            System.out.print("#");
                        }else if(j == 0 || j == W-1){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }
                    System.out.printf("\n");
                }
                System.out.printf("\n");
            }
        }
    }
}


Measured memory_bytes: 34572
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll ans = 0;
    char lastChar = 'A';
    rep(i, N){
        if(S[i] != lastChar){
            ans++;
        }
        lastChar = S[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  int x = 800*n;
  int y = n/15*200;
  cout << x-y << endl;

  return 0;
}

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

long long int gcd(int a, int b, int c){
  /*
  int min = 0;
  if(min>a) min = a;
  if(min>b) min = b;
  if(min>c) min = c;
  */
  int max = 0;
  if(max<a) max = a;
  if(max<b) max = b;
  if(max<c) max = c;
  
  for(int i=max; i>1; i--){
    if(a%i == 0 && b%i == 0 && c%i == 0) return i;
  }
  return 1;
}

int main(void) {
  long long int k=0;
  cin >> k;
  
  
  
  long long int gcdtri[201][201][201] = {0};
  
  for(int a=1; a<=k; a++){
    for(int b=1; b<=k; b++){
      for(int c=1; c<=k; c++){
        if(gcdtri[a][b][c] == 0 &&
           gcdtri[a][c][b] == 0 &&
           gcdtri[b][a][c] == 0 &&
           gcdtri[b][c][a] == 0 &&
           gcdtri[c][a][b] == 0 &&
           gcdtri[c][b][a] == 0) {
           
           long long int tmp = gcd(a, b, c);
           gcdtri[a][b][c] = tmp;
           gcdtri[a][c][b] = tmp;
           gcdtri[b][a][c] = tmp;
           gcdtri[b][c][a] = tmp;
           gcdtri[c][a][b] = tmp;
           gcdtri[c][b][a] = tmp;
        }
      }
    }
  }
  
  long long int ans = 0;
  for(int a=1; a<=k; a++){
    for(int b=1; b<=k; b++){
      for(int c=1; c<=k; c++){
        ans = ans + gcdtri[a][b][c];
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 67020
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{
	fast;
	ll a,b,c;cin>>a>>b>>c;
	for(ll i = 1; i < 10000 ;i++)
	{
		ll ans = i*a - c;
		if(ans % b == 0)
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

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

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int n;
int dp[100000];
 

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	memset(dp,0, sizeof dp);
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	dp[0] = 0;
	dp[1] = abs(arr[0] - arr[1]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]));
	}
	cout << dp[n - 1];
	
}


Measured memory_bytes: 4424
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(x-r<0 || y-r<0 || x+r>W || y+r>H){
        cout << "No" <<endl;
    }else{
        cout << "Yes" <<endl;
    }
    return 0;

}



Measured memory_bytes: 3104
import sys
sys.setrecursionlimit(10**5)

n,m,k = map(int, input().split())

F = [[] for _ in range(n+1)]
B = [[] for _ in range(n+1)]

for _ in range(m):
    x,y = map(int, input().split())
    F[x].append(y)
    F[y].append(x)

for _ in range(k):
    x,y = map(int, input().split())
    B[x].append(y)
    B[y].append(x)

belongs = [-1 for _ in range(n+1)]
group_ID = 0

def f_search(root, group_ID):
    for j in F[root]:
        if belongs[j] == -1:
            belongs[j] = group_ID
            f_search(j, group_ID)

for i in range(n+1):
    if belongs[i] == -1:
        belongs[i] = group_ID
        f_search(i, group_ID)
        group_ID += 1

cnt_members = [0 for _ in range(len(set(belongs)))]
for i in belongs[1:]:
    cnt_members[i] += 1

ans = [0 for _ in range(n+1)]
for i in range(1, n+1):
    tmp = 0
    for j in B[i]:
        if belongs[j] == belongs[i]:
            tmp += 1
    ans[i] = cnt_members[belongs[i]] - 1 - len(F[i]) - tmp

print(*ans[1:])


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

using namespace std;

const int maxn=1e5+5,mod=1e9+5;

typedef long long ll;

int main()
{
    int H,W,N;
    while(scanf("%d%d%d",&H,&W,&N)!=EOF)
    {
        int maxnum=max(H,W);
        if(N%maxnum==0)
            printf("%d\n",N/maxnum);
        else
            printf("%d\n",N/maxnum+1);
    }
    return 0;
}


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

int main(){
  int w;
  int t=0;
  while(cin >> w && w){
    int n,dp[2][1001],wait[1000],value[1000];
    cin >> n;
    for(int i=0;i<n;i++) scanf("%d,%d",&value[i],&wait[i]);

    fill(dp[0],dp[2],0);
    for(int i=0;i<n;i++){
      for(int j=wait[i];j<=w;j++) dp[1][j] = max(dp[1][j], dp[0][j-wait[i]]+value[i]);
      for(int j=0;j<=w;j++) dp[0][j] = dp[1][j];
    }

    int ans = 0, answ;
    for(int i=0;i<=w;i++){
      if(ans < dp[0][i]){
        ans = dp[0][i];
        answ = i;
      }
    }

    cout << "Case " << ++t << ':' << endl;
    cout << ans << endl;
    cout << answ << endl;
  }
}

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

int main() {
    int n,m,R;
    cin >> n >> m >> R;
    vector<int> r(R);
    rep(i,R) cin >> r.at(i);
    int qq,ww,ee;
    pp v;
    vector<vector<pp>> d(n+1,vector<pp>(0));
    vector<vector<int>> df(n+1,vector<int>(n+1));
    rep(i,n+1){
        rep(j,n+1) df.at(i).at(j)=inf;
    }
    rep(i,m){
        cin >> qq >> ww >> ee;
        v.first=ww;v.second=ee;
        d.at(qq).push_back(v);
        v.first=qq;v.second=ee;
        d.at(ww).push_back(v);
    }
    queue<int> q;
    for (int i=1;i<n+1;i++){
        df.at(i).at(i)=0;
        q.push(i);
        while (!q.empty()){
            int o=q.front();
            q.pop();
            rep(j,d.at(o).size()){
                if (df.at(i).at(o)+d.at(o).at(j).second<df.at(i).at(d.at(o).at(j).first)){
                    df.at(i).at(d.at(o).at(j).first)=df.at(i).at(o)+d.at(o).at(j).second;
                    q.push(d.at(o).at(j).first);
                }
            }
        }
    }
    int ans=inf;
    sort(r.begin(),r.end());
    do{
        int u=0;
        for (int i=1;i<R;i++){
            u+=df.at(r.at(i-1)).at(r.at(i));
        }
        ans=min(ans,u);
            }while(next_permutation(r.begin(),r.end()));
            cout << ans << endl;
}


Measured memory_bytes: 896
a, b, c, d = map(int, input().split())

if a >= 0 and c >= 0:
    print(b * d)

elif b <= 0 and d <= 0:
    print(a * c)

elif a >= 0 and d <= 0:
    print(a * d)

elif b <= 0 and c >= 0:
    print(b * c)
    
else:
    print(max(a * c, b * d))

Measured memory_bytes: 9180
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {

	buf := make([]byte, 1000)
	sc.Buffer(buf, 1400000000)

	// input
	nx := inputLineAsNumArray(2)
	N := nx[0]
	X := nx[1]

	sum := 0
	// var budgets []int
	minBudget := X
	for i := 0; i < N; i++ {
		budget := inputLineAsNumArray(1)[0]
		// budgets = append(budgets, budget)
		sum += budget
		if budget < minBudget {
			minBudget = budget
		}
	}

	fmt.Println(N + (X-sum)/minBudget)
}

func inputLineAsNumArray(length int) []int {

	line := strings.Split(readLine(), " ")
	var nums []int
	for i := 0; i < length; i++ {
		num, _ := strconv.Atoi(line[i])
		nums = append(nums, num)
	}
	return nums
}

func readLine() string {

	sc.Scan()
	return sc.Text()
}


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

int main(){
  long long n, m, l, b[100][100], a[100][100], c[100][100] = {};
  cin >> n >> m >> l;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    for(int j = 0; j < l; j++){
      cin >> b[i][j];
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      for(int k = 0; k < l; k++){
        c[i][k] += a[i][j] * b[j][k];
      }
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      cout << (j == 0 ? "": " ") << c[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 1396
#include <stdio.h>

int main()
{
	char a[11], b[11], c[11];
	int i, enda, endb;

	scanf("%s %s %s", a, b, c);

	for (i = 0; a[i] != '\0';  i++);
		
		enda = i - 1;
		for (i = 0; b[i] != '\0'; i++);
			;
		endb = i -1;

	if (a[enda] == b[0] && b[endb] == c[0])
		printf("YES\n");
	else printf("NO\n");

	return 0;
}

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

int main(){
    
    int N,A,B;cin>>N>>A>>B;
    int C=N*10+1;
    int dp[C][C];
    for(int i=0;i<C;i++){
        for(int j=0;j<C;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<N;i++){
        int a,b,c;cin>>a>>b>>c;
        for(int j=C-1;j>=0;j--){
            for(int k=C-1;k>=0;k--){
                if(j==0&&k==0){
                    if(dp[a][b]==0) dp[a][b]=c;
                    else dp[a][b]=min(dp[a][b],c);
                }else if(dp[j][k]!=0){
                    if(dp[j+a][k+b]==0) dp[j+a][k+b]=dp[j][k]+c;
                    else dp[j+a][k+b]=min(dp[j+a][k+b],dp[j][k]+c);
                }
            }
        }
    }
    int ans=1000000;
    for(int i=1;i<=(C-1)/max(A,B);i++){
        if(dp[A*i][B*i]!=0){
            ans=min(ans,dp[A*i][B*i]);
        }
    }
    if(ans==1000000) cout<<-1<<endl;
    else cout<<ans<<endl;
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());
 
vector<int> color;
bool dfs(vvl &g,int v,int now = 0){
    color[v] = now;
    for (auto next_v : g[v]) {
        // 隣接頂点がすでに色確定していた場合
        if (color[next_v] != -1) {
            if (color[next_v] == now) return false; // 同じ色が隣接したらダメ
            continue;
        }

        // 隣接頂点の色を変えて、再帰的に探索 (一回でも false が返ってきたら false)
        if (!dfs(g, next_v , 1 - now)) return false;
    }
    return true;
}
signed main()
{   
    gearup;
    int n; cin >> n;
    vvl g(n);
    vs s(n);
    vvl dp(n,vl(n,L_INF));
    rep(i,n)cin>>s[i];
    rep(i,n){
        rep(j,n){
            if(s[i][j] == '1'){
                g[i].push_back(j);
                dp[i][j] = 1;
            }
        }
    }
    color.resize(n,-1);
    bool is_bipartite = true;
    for (int v = 0; v < n; ++v) {
        if (color[v] != -1) continue; // v が探索済みだったらスルー
        if (!dfs(g, v)) is_bipartite = false;
    }

    if (is_bipartite == false){
        out(-1);
        return 0;
    }

    for(int i=0;i<n;i++){
        dp[i][i] = 0;
    }

    //ワーシャルフロイド法
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                chmin(dp[i][j],dp[i][k]+dp[k][j]);
            }
        }
    }

    ll res = 0;
    rep(i,n)rep(j,n)res = max(res,dp[i][j]+1);
    out(res);
}

Measured memory_bytes: 4276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N); // N個の数学の点数データ
 vector<int> B(N); // N個の数学の点数データ
  vector<int> C(N-1); // N個の数学の点数データ
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
   
  }
  
   for (int i = 0; i < N; i++) {
    cin >> B.at(i);
    
  }
  
   for (int i = 0; i < N-1; i++) {
    cin >> C.at(i);
     
  }
  
  int answer;
  int zenkaiNo;
  zenkaiNo = 80;
  
  for (int i = 0; i < N; i++) {
    answer += B.at(A.at(i)-1);
    if(A.at(i) == zenkaiNo + 1){
      
    answer +=  C.at(zenkaiNo-1);
    }
    zenkaiNo = A.at(i);
     
  }
  
    cout << answer << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

def find_array(N: int, Y: int):
    for a in range(N + 1):
        for b in range(N + 1):
            if a + b > N:
                break
            c = N - a - b
            if a * 10000 + b * 5000 + c * 1000 == Y:
                return [a, b, c]
    return [-1, -1, -1]

def solve(N: int, Y: int):
    array = find_array(N, Y)
    # print(array)
    print(' '.join(map(str,array)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(N, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n,i;
  cin >> n >> i;
  cout << n-i+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <deque>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll A,B;
    cin >> A >> B;

    ll ct=1;
    ll ans=0;
    while(ct<B){
        ct+=A-1;
        ans++;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
N = int(input())
d = []
for i in range(N):
  d.append(int(input()))

num = [0]*(max(d)+1)
for i in range(N):
  num[d[i]] +=1

res = 0

for i in range(max(d)+1):
  if num[i]:
    res += 1

print(res)

Measured memory_bytes: 9104
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt() + 1;
		int maxTime = sc.nextInt();
		String str = "1"+sc.next();
		int group[] = new int[num];
		int crt = 0;
		int numG = 1;
		group[0] = 0;
		for(int i = 1; i < num; i ++) {
			if(str.charAt(i) != str.charAt(i - 1)) {
				group[numG] = crt;
				numG ++;
			}
			crt ++;
		}
		group[numG] = crt;

		int can[] = new int[numG];
		for(int i = 0; i < numG; i ++) {
			can[i] = group[i + 1] - group[Math.max(0, i - maxTime * 2 + i % 2)];
		}

		int max = 0;
		for(int i = 0; i < numG; i ++) {
			max = Math.max(max, can[i]);
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 28244
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
struct UnionFind {
  vector<int> parent,s;
  UnionFind(int n): parent(n), s(n){
    rep(i,n) {
      parent[i] = i;
      s[i] = 1;
    }
  }
  int root(int x) { return parent[x]==x ? x : parent[x] = root(parent[x]); }
  bool same(int x, int y) { return root(x)==root(y); }
  int size(int x){ return s[root(x)]; }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (s[x] < s[y]) {
      parent[x] = y;
      s[y] += s[x];
    } else {
      parent[y] = x;
      s[x] += s[y];
    }   
  }
};

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  rep(i,m) cin >> a[i] >> b[i];
  rep(i,m) --a[i], --b[i];
  
  int ans = 0;
  rep(i,m){
    UnionFind u(n);
    rep(j,m) if(i!=j) u.unite(a[j],b[j]);
    if(!u.same(a[i],b[i])) ++ans;
  }
  cout << ans << endl;
}


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

using namespace std;

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

    unordered_map<char, int> res;

    for(int i = 0; i < s.size(); i++) {
        res[s[i]]++;
    }

    // check
    bool size = true, val = true;

    if(res.size() != 2) {
        size = false;
    }

    for(auto i = res.begin(); i != res.end(); ++i) {
        if(i->second != 2){
            val = false;
            break;
        }
    }
    
if(size && val) {
    cout << "Yes" << endl;
} else {
    cout << "No" << endl;
}
    

    return 0;
}

Measured memory_bytes: 256