akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	m, _ := strconv.Atoi(stringLineScan())
	if len(PrimeFactors(m)) == 1 && n != m {
		fmt.Println(1)
	} else {
		for i := n; i <= m; i++ {
			if m%i == 0 {
				fmt.Println(m / i)
				break
			}
		}
	}
}
func PrimeFactors(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}
	if n > 2 {
		pfs = append(pfs, n)
	}
	return
}


Measured memory_bytes: 640
odd = raw_input()
even = raw_input()

oddlength = len(odd)
evenlength = len(even)

i = 0
s = ''

while i < evenlength:
	s += odd[i]
	s += even[i]
	i += 1
	
if oddlength > evenlength:
	s += odd[oddlength-1]

print s


Measured memory_bytes: 2568
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

from math import ceil

n = readint()
a = readints()

ans = 0
for i in range(n):
    a.sort()
    if a[-1]<n:
        break
    ans += 1
    for j in range(n-1):
        a[j]+=1
    a[-1]-=n

a.sort()
while a[-1]-a[0]>n+1:
    x = ceil((a[-1]-a[0]-n-1)/(n+1))
    ans += x
    for j in range(n-1):
        a[j] += x
    a[-1] -= n*x
    a.sort()
if a[-1]>=n:
    ans += (a[0]-n+1)*n
    A = a[0]
    for i in range(n):
        a[i] -= A-n+1

while a[-1]>=n:
    ans += 1
    for j in range(n-1):
        a[j]+=1
    a[-1]-=n
    a.sort()

print(ans)




Measured memory_bytes: 67244
#include <iostream>

using namespace std;

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

  if(A == 1)
    A += 20;
  if(B == 1)
    B += 20;
  
  if(A < B)
    cout << "Bob" << endl;
  else if(A > B)
    cout << "Alice" << endl;
  else
    cout << "Draw" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int N, S;
  cin >> N >> S;
  int A, B, C;
  A = B = C = -1;
  rep(i, N) {
    rep(j, N - i) {
      if(i * 10000 + j * 5000 + (N - i - j) * 1000 == S) {
        A = i;
        B = j;
        C = N - i - j;
      }
    }
  }
  cout << A << " " << B << " " << C << endl;
}

Measured memory_bytes: 3604
package main

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

type point struct {
	x float64
	y float64
}

type line struct {
	start point
	end   point
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	lines := koch(n, []line{line{point{0, 0}, point{100, 0}}})
	fmt.Printf("%f %f\n", lines[0].start.x, lines[0].start.y)
	for i := 0; i < len(lines); i++ {
		fmt.Printf("%f %f\n", lines[i].end.x, lines[i].end.y)
	}
}

func koch(n int, lines []line) []line {
	if n == 0 {
		return lines
	} else {
		nextLines := make([]line, 0)
		for _, line := range lines {
			nextLines = append(nextLines, createKoch(line)...)
		}
		return koch(n-1, nextLines)
	}
}

func createKoch(l line) []line {
	midLeft := point{
		l.end.x/3 + l.start.x*2/3,
		l.end.y/3 + l.start.y*2/3,
	}
	midRight := point{
		l.end.x*2/3 + l.start.x/3,
		l.end.y*2/3 + l.start.y/3,
	}
	mid := rotate(midLeft, midRight)
	return []line{
		line{l.start, midLeft},
		line{midLeft, mid},
		line{mid, midRight},
		line{midRight, l.end},
	}
}

func rotate(o, p point) point {
	rad := math.Pi / 3
	moved := point{
		p.x - o.x,
		p.y - o.y,
	}
	moved = point{
		math.Cos(rad)*moved.x - math.Sin(rad)*moved.y,
		math.Sin(rad)*moved.x + math.Cos(rad)*moved.y,
	}
	return point{
		moved.x + o.x,
		moved.y + o.y,
	}
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    bool flg = false;
    if (a==0) {
        a = 1;
        flg = true;
    }
    ll ans = b/x-(a-1)/x;
    if (flg) ans++;
    
    cout << ans << endl;
    return 0;
}


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

long long a[200010], tot[200010];

int main() {
	long long n,x;
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		tot[i] = tot[i-1]+a[i];
	}
	long long ans = tot[n]*5+x*n*2;
	for (int t = n-1; t >= 1; t--) {
		int k = n/t;
		//if  (n%t) k++;
		long long tmp = tot[n]*5+x*(n+t);
		int cur = n;
		while (cur)  {
			int l = cur-t;
			if (l >= 0) {
				if (cur < n) tmp += (tot[cur]-tot[l])*((n-cur)/t-1)*2;
				cur -= t;
			}
			else {
				tmp += tot[cur]*((n-cur)/t-1)*2;
				break;
			}
			if (tmp >= ans) break;
		}
		ans = min(ans,tmp);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3328
module WeightedDirectedGraph
  (* 辺の重み *)
  (Weight : sig
    type t
    val inf : t (* max_intとかを突っ込むとオーバーフローで死ぬので気をつけること *)
    val zero : t
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  (* 頂点を[0, n)の自然数に限定したグラフに対してのダイクストラ法 *)
  val raw_dijkstra :
    (* 頂点数 *)
    int ->
    (* 隣接リスト *)
    (int -> (int * Weight.t) list) ->
    (* 始点 *)
    int ->
    (* 始点から辿り着けなければWeight.infを返す関数 *)
    (int -> Weight.t)
end =
struct
  module WMap = Map.Make (Weight)

  let raw_dijkstra n es s =
    let d = Array.make n Weight.inf in
    d.(s) <- Weight.zero;
    let rec dijkstra_aux q =
      match WMap.min_binding_opt q with
      | None -> ()
      | Some (w, us) ->
          dijkstra_aux @@
          ListLabels.fold_left ~init:(WMap.remove w q) us ~f:(fun q u ->
            if 0 < Weight.compare w d.(u)
            then q
            else ListLabels.fold_left ~init:q (es u) ~f:(fun q (v, c) ->
              let open Weight in
              if Weight.compare d.(v) (w + c) <= 0
              then q
              else begin
                d.(v) <- w + c;
                WMap.add (w + c) (v :: try WMap.find (w + c) q with Not_found -> []) q
              end)) in
    dijkstra_aux (WMap.singleton Weight.zero [s]);
    Array.get d
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let ( + ) = ( + )
  let compare = compare
  let inf = 12345678901234
end)

let () = Scanf.scanf "%d %d %d\n" @@ fun n m s ->
  let es = Array.make n [] in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d %d %d\n" @@ fun u v a b ->
      es.(u - 1) <- (v - 1, a, b) :: es.(u - 1);
      es.(v - 1) <- (u - 1, a, b) :: es.(v - 1);
  done;
  let vs = Array.init n @@ fun _ -> Scanf.scanf "%d %d\n" @@ fun c d -> (c, d) in
  let f (v, w) = n * w + v in
  let finv x = (x mod n, x / n) in
  let d = Fun.flip (G.raw_dijkstra (n * 2501)) (f (0, min 2500 s)) @@ fun p ->
    let (v, w) = finv p in
    (let (c, d) = vs.(v) in (f (v, min 2500 (w + c)), d)) ::
      Fun.flip List.filter_map es.(v) (fun (u, a, b) ->
        if w < a
        then None
        else Some (f (u, w - a), b)) in
  for v = 1 to n - 1 do
    Printf.printf "%d\n" @@
    List.fold_left min max_int @@
    List.init 2501 @@ fun w -> d (f (v, w))
  done


Measured memory_bytes: 19804
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:128777216")

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>

#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>

#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>

#include <memory.h>
#include <cassert>
#include <time.h>
#include <functional>

using namespace std;

#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)

#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;

const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;

#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif

void prepare(string s) {
#ifdef MY_DEBUG
  freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#endif
}

int n;
char s[15];
lint d[32];

void read() {
  forn(i, 32) d[i] = 0;
  scanf("%d", &n);
  forn(i, n) {
    scanf(" %s", s);
    d[s[0] - 'A']++;
  }
}

void solve() {
  int id[] = {'M' - 'A', 'A' - 'A', 'R' - 'A', 'C' - 'A', 'H' - 'A'};
  lint ans = 0;
  forn(i, 5) {
    forab(j, i + 1, 4) {
      forab(k, j + 1, 4) {
        ans += d[id[i]] * d[id[j]] * d[id[k]];
      } 
    }
  }
  printf("%lld\n", ans);
}

int main() {
  prepare("");

  read();
  solve();
  dbg("Clock = %.3f\n", clock() / (double)CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 256
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    long a, b, k;
    cin >> a >> b >> k;

    if (a < k) {
        k -= a;
        a = 0;
        
        if (b < k) {
            b = 0;
        } else {
            b -= k;
        }
    } else {
        a -= k;
    }

    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
long long x,y,z,k;
cin >> x >> y >> z >> k;
vector<long long> A(x);
vector<long long> B(y);
vector<long long> C(z);
REP(i,x)cin >> A[i];

REP(i,y)cin >> B[i];

REP(i,z)cin >> C[i];

vector<long long> AB;
for(int i = 0;i <x; i++){
    for(int j = 0; j < y;j++){
        AB.push_back(A[i]+B[j]);
    }
}
sort(AB.begin(),AB.end());
reverse(AB.begin(),AB.end());
vector<long long> ABC;
for(int i = 0; i < min(k,(long long)AB.size()); i++){
    for(int j = 0; j < z;j++){
    ABC.push_back(AB[i]+C[j]);
}
}
sort(ABC.begin(),ABC.end());
reverse(ABC.begin(),ABC.end());
for(int i = 0; i<k;i++){
cout << ABC[i] << endl;
}
}

Measured memory_bytes: 43032
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int N, i;
	scanf("%d", &N);

	int ans = 0;
	while (N--) {
		int t;
		scanf("%d", &t);
		while (t % 2 == 0) {
			ans++;
			t /= 2;
		}
	}
	return !printf("%d\n", ans);
}

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n, q;
    cin >> n >> q;
    vector<queue<ll> > vs(n);
    rep(i,q){
        ll com, t; 
        cin >> com >> t;
        ll x;
        if(com == 0){
            cin >> x;
            vs[t].push(x);
        }else if(com == 1 && vs[t].size() > 0)cout << vs[t].front() << endl;
        else if(vs[t].size() > 0)vs[t].pop();
    }
    return 0;
} 


Measured memory_bytes: 5088
using System;
using System.Collections.Generic;
using System.Linq;


namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var lists = Console.ReadLine()
                .ToArray();
            var unko = new List<KeyValuePair<string, int>>();
            
            unko.Add(new KeyValuePair<string, int>(lists[0].ToString(), int.Parse(lists[0].ToString())));
            for (int i = 1; i < 4; i++)
            {
                unko = Unkoman(unko, int.Parse(lists[i].ToString()));
            }
            foreach (var item in unko)
            {
                if(item.Value == 7)
                {
                    Console.WriteLine(item.Key +"=7");
                    break;
                }
            }
            Console.ReadLine();
        }

        static List<KeyValuePair<string,int>> Unkoman(List<KeyValuePair<string, int>> vs, int unko)
        {
            var ls = new List<KeyValuePair<string, int>>();
            foreach (var item in vs)
            {
                var key = new KeyValuePair<string, int>(item.Key + "+" + unko,item.Value + unko);
                var key2 = new KeyValuePair<string, int>(item.Key + "-" + unko, item.Value - unko);
                ls.Add(key);
                ls.Add(key2);
            }
            return ls;
        }
    }
    
}


Measured memory_bytes: 13268
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ll fact(ll n, ll mod) {
    ll val = 1;
    for (int i = 1; i <= n; i++) {
        val = val * i % mod;
    }
    return val;
}

int main() {
    ll n, mod = 1e9 + 7;
    cin >> n;
    string s;
    vector<bool> t;
    t.push_back(0);
    cin >> s;
    if (s[0] == 'W' || s[2*n - 1] == 'W') {
        cout << 0 << endl;;
        return 0;
    }

    ll ans = 1, l = 0;
    for (int i = 1; i < 2 * n; i++) {
        if (s[i] != s[i - 1]) {
            t.push_back(t[i - 1]);
        }
        else t.push_back(t[i - 1] ^ 1);
    }
    for (int i = 0; i < 2*n; i++) cerr << t[i];
    cerr << endl;
    for (int i = 0; i < 2 * n; i++) {
        if (t[i] == 0) l++;
        else {
            ans = ans * l % mod;
            l--;
        }
        if (l < 0) {
            cout << 0 << endl;;
            return 0;
        }
    }
    cout << (l == 0 ? ans * fact(n, mod) % mod : 0) << endl;
    
    
}

Measured memory_bytes: 640
import fractions
N,K=map(int,input().split())
A=list(map(int,input().split()))
g=A[0]
for i in range(N):
  g=fractions.gcd(g,A[i])
flag=False
for i in range(N):
  if((A[i]-K)>=0 and (A[i]-K)%g==0):
    flag=True
if flag:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 16048
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int rev_mod(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

int main(){
	long long int n, k;
	cin >> n >> k;
	k = min(k, n - 1);
	long long int ans = 1, S1 = 1, S2 = 1;
	for(int i = 0; i < k; i++){
		S1 *= n - i;
		S1 %= MOD;
		S1 *= rev_mod(i + 1);
		S1 %= MOD;
		S2 *= n - i - 1;
		S2 %= MOD;
		S2 *= rev_mod(i + 1);
		S2 %= MOD;
		ans += S1 * S2 % MOD;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2]){
        cout << "Yes" << endl;
    }
    else if(s[1] == s[2] && s[2] == s[3]){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  vector<long long> S(N);
  long long K=0;
  for(int i=0; i<N; i++){
    cin>>S.at(i);
  }
  for(int i=1; i<N; i++){
    if(S.at(i-1)>S.at(i)){
      K+=S.at(i-1)-S.at(i);
      S.at(i)=S.at(i-1);
    }
    else continue;
  }
  cout<<K<<endl;
}

Measured memory_bytes: 4812
/*
Dear ToM,
Congratulations on your graduation!
You did a great job!
     ☆ﾟ*＠*ﾟ☆
　　(＠*｡☆｡*＠
　 /☆｡*＠ﾟ*☆
▲/／｡＠｡*☆＠*
　▼―ｰ｡*＠ﾟ*☆
*/

#include <bits/stdc++.h>
using namespace std;

#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;

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

	int ans = 0;
	if(stoi(s) % 2 == 0) ans++;
	rep(i, int(s.size()-1)){
		string sa = s.substr(0, i+1);
		string wa = s.substr(i+1);
		if(wa[0] == '0') continue;
		int i_sa = stoi(sa);
		int i_wa = stoi(wa);
		if((i_sa + i_wa) % 2 != 0) continue;
		int tmp = i_wa - i_sa;
		if(tmp < 0) continue;
		if(tmp % 2 != 0) continue;
		ans++;
	}

	cout << ans << endl;

	return 0;
}



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

vector<int> pre, in, post;
int n;

void rec(int p, int s, int t){
        if(t<=0) return;
        int v = pre[p];
        int i = s;
        while(in[i]!=v) i++;
        rec(p+1, s, i-s);
        rec(p+i-s+1, i+1, t-(i-s)-1);
        post.push_back(v);
}


int main(){
        cin>>n;
        pre.resize(n);
        in.resize(n);
        for(int i=0;i<n;i++) cin>>pre[i];
        for(int i=0;i<n;i++) cin>>in[i];

        rec(0,0,n);

        for(int i=0;i<post.size();i++){
                cout<<post[i];
                if(i==post.size()-1) cout<<endl;
                else cout<<" ";
        }
        return 0;
}


Measured memory_bytes: 3164
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long k = sc.nextLong();
        if (k % 2 == 0) {
            System.out.println(a - b);
        } else {
            System.out.println(b - a);
        }
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<vector>
#define PP std::pair<char,int>
std::vector<char> ans;
char memo = '(';
int N;
char S;
int F;
int main() {
	std::cin >> N;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		std::cin >> S;
		ans.push_back(S);
		if (S == '(')sum++;
		else {
			if (sum) {
				sum--;
			}
			else {
				F++;
			}
		}
	}
	for (int i = 0; i < F; i++)std::cout << '(';
	for (auto u : ans)std::cout << u;
	for (int i = 0; i < sum; i++)std::cout << ')';
	std::cout << std::endl;
	return 0;
}


Measured memory_bytes: 256
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


A, B, C, D = lmi()
takahashi = A
aoki = C
i = 0
while takahashi > 0 and aoki > 0:
    if i % 2 == 0:
        aoki -= B
    else:
        takahashi -= D
    i += 1
print("Yes" if aoki <= 0 else "No")


Measured memory_bytes: 9492
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N;
    vector<int> a;
    int count[9] = {};
    cin >> N;
    for(int i=0; i<N; i++)
    {
    	int b;
    	cin >> b;
    	a.push_back(b);
    }
    for(int i=0; i<N; i++)
    {
    	int x = a[i]/400;
        if(x<8) count[x]++;
        else count[8]++;
    }

    int ans1 = 0, ans2 = 0; 
    for(int i=0; i<8; i++)
    {
       if(count[i]>0) ans1++;
    }
    ans2 = ans1 + count[8];
    ans1 = max(ans1,1);
    cout << ans1 << " " << ans2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long int ;
// Its  a Greedy Problem and we just going to k bigest elements as 0 and sum the rest;
int main()
{
  ll n,k,sum=0;
  cin>>n>>k;
  ll arr[n];
  for(int i=0;i<n;i++)
  {
    ll x;
    cin>>x;
    sum+=x;
    arr[i]=x;
  }
  
  sort(arr,arr+n);
  
  if(k==0)
    cout<<sum<<endl;
  else
  {
    if(n-k>0)
    {
      ll sum1=0;
      for(int j=0;j<n-k;j++)
      {
        sum1+=arr[j];
      }
      cout<<sum1<<endl;
    }
    else
    {
      cout<<0<<endl;
    }
  }
}


Measured memory_bytes: 5136
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  const usize n = scan<usize>();
  const usize k = scan<usize>();
  std::vector<char> s(n);
  for (auto &e : s) {
    std::cin >> e;
  }
  usize conf = 0_z;
  for (const auto i : rep(1_z, n)) {
    if (s[i - 1_z] != s[i]) {
      ++conf;
    }
  }
  if (conf < k * 2_z) {
    conf = 0_z;
  } else {
    conf -= k * 2_z;
  }
  std::cout << n - 1_z - conf << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <string>
#include <regex>

using namespace std;

int main() {
    char buf[131072];
    scanf("%s", buf);
    string S(buf);
    
    regex re(R"((?:dream(?:er)?|eraser?)+$)");

    printf("%s\n", regex_match(S, re)? "YES":"NO");
    return 0;
}


Measured memory_bytes: 32128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef set<ll> sl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) v.begin(), v.end()
//bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
//bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll N, ans=0;
int main() {
  ll H, W;
  cin >> H >> W;
  char a[H][W];
  rep(i, H) rep(j, W) cin >> a[i][j];
  
  bool line[H],row[W];
  
  rep(i, H) {
    line[i]=false;
    rep(j, W) if(a[i][j] == '#') {line[i]=true; break;}
  }
  
  rep(j, W) {
    row[j]=false;
    rep(i, H) if(a[i][j] == '#') {row[j]=true; break;}
  }
  
  rep(i, H) {
    if(line[i]==false) continue;
    rep(j, W) if(row[j]==true) cout << a[i][j];
    cout << endl;
  }
  return 0;
}


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

int main() {
  
  int A, B, ans = 0;
  
  char op;
  
  cin >> A >> op >> B;
  
  if(op == '+') {
    
    ans = A + B;
    
  }
    
  else {
    
    ans = A - B;
    
  }
  
  cout << ans << endl;
  
}

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

void call(int n){
    for (int i = 1; i <= n; i++) {
        int x = i;
        if ( x % 3 == 0 ){
            cout << " " << i;
            continue;
        }
        while(x) {
            if ( x % 10 == 3 ){
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    call(n);
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  int64_t N;
  cin >> N;
  int64_t B[N-1];
  for(int i=0;i<N-1;i++){
    cin >> B[i];
  }
  int64_t ans = B[0];
  for(int i=0;i<N-2;i++){
    int a = min(B[i], B[i+1]);
    ans += a;
  }
  ans += B[N-2];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long N,A[100005]={0},i,ans=0,all=0;
	cin>>N;
	for(int n=1;n<=N;n++)
	{
		cin>>A[n];
		all=all+abs(A[n]-A[n-1]);
	}
	all=all+abs(0-A[N]);
	for(i=1;i<=N;i++)
	{
		ans=all-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2048
// @author: Amirul Islam

#include <bits/stdc++.h>
using namespace std;
#define LLI long long int
#define PII pair <int, int>

const int mx = 1e5+5;
const LLI INF = 1e10;

LLI dp[mx], w, val, N, W;

LLI max(LLI a, LLI b) {
    return (a > b ? a : b);
}

LLI knapsack(int N, int W) {
    for (int i = 0; i < mx; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%lld %lld", &w, &val);
        for (int j = mx; j >= 0; j--) {
            if (j >= val) dp[j] = min(dp[j], dp[j-val] + w);
        }
    }
    LLI ret = 0;
    for (int i = 0; i < mx; i++) {
        if (dp[i] <= W) ret = max(ret, i);
    }
    return ret;
} 

int main() {
    scanf("%lld %lld", &N, &W);
    printf("%lld\n", knapsack(N, W));
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,a[N],pos[N];
void init(){
    cin >> n;
    for(int i=1;i<=n;i++){
    	cin >> a[i];
    	pos[a[i]]=i;
	}
}
void work(){
    int i,cnt=0,now=0;
    for(int i=n-1;i!=0;i--){
        if(!cnt){
            if(pos[i]>pos[i+1]){
            	cnt++;
				now=i+1;
			}
            continue;
        }
        if(pos[now]<=pos[i]&&pos[i]<=pos[i+1]) continue;
        if(pos[i]<=pos[i+1]&&pos[i+1]<=pos[now]) continue;
        if(pos[i+1]<=pos[now]&&pos[now]<=pos[i]) continue;
        cnt++;
		now=i+1;
    }
    cout << cnt;
}

int main(){
    init();
	work();
    return 0;
}

Measured memory_bytes: 1792
/**
*    created: 23.05.2020 01:09:02
**/
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b, k;
    cin >> a >> b >> k;
    int d = __gcd(a,b);
    vector<int> g;
    rep2(i,1,sqrt(d)+1) {
        if (d % i == 0) {
            g.push_back(i);
            if (d / i != i) g.push_back(d / i);
        }
    }
    sort(g.rbegin(), g.rend());
    cout << g[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include<iomanip>

int main() {

	int N;
	std::cin >> N;

	std::vector<int> A(N);
	for (auto& a : A) {
		std::cin >> a;
	}

	int max;
	int better;

	auto tmp = A;
	std::sort(tmp.begin(), tmp.end());

	max = tmp.back();
	tmp.pop_back();
	better = tmp.back();

	//std::cout << max << better;

	
	for (auto& a : A) {
		if (a != max) {
			std::cout << max << std::endl;
		}
		else {
			std::cout << better << std::endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3200
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef	long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()),((v).end())
#define PI(n) ((double)acos(n))
#define clr0(n) (memset(n,0,sizeof n))
#define clr1(n) (memset(n,-1,sizeof n))
int dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#else
	// online submission
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
}

set<string>s;
void gen(string x){

	if (x.size() == 8)
		return;
	if (x.size()==5)
	s.insert(x);
	gen(x + "0");
	gen(x + "1");
	gen(x + "B");
}
int main()
{
	string x;
	cin >> x;
	string y;
	for (int i = 0; i < (int)x.size(); i++){
		char ch = x[i];
		if (ch == '0' || ch == '1')
			y += ch;
		else if(y.size()!=0){
			y.pop_back();
		}
	}
	cout << y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    string s;
    cin >> s;
    stack<char> st;
    
    /*
    auto show = [](stack<char> st) -> void {
        string s;
        while (!st.empty()) {
            s += st.top();
            st.pop();
        }
        reverse(s.begin(), s.end());
        cout << s << endl;
    };
    */
    
    repeat (i, s.length()) {
        if (!st.empty() and st.top() == '0' and s[i] == '1') {
            st.pop();
        }
        else if (!st.empty() and st.top() == '1' and s[i] == '0') {
            st.pop();
        }
        else {
            st.push(s[i]);
        }
    }
    cout << s.length() - st.size() << endl;
}

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i < n; i++){
    ans += (n-1)/i;
  } 
  cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;
    int i;
    int h=0;
    for(i=0;i<6;i++){
        if(s.at(i)=='1'){
            h++;
        }
    }
    cout << h << endl;
    return 0;
}

Measured memory_bytes: 256
n, l = map(int, input().split())
apples = [l+i-1 for i in range(1, n+1)]
mn = float('inf')
idx = 0
for i in range(n):
    if mn>abs(apples[i]):
        mn = abs(apples[i])
        idx = i

print(sum(apples)-apples[idx])


Measured memory_bytes: 9144
#include "iostream"
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b ;
	if (a < b)
	{
		cout <<"a < b"<< endl;
	}
	else if (a > b)
	{
		cout <<"a > b"<< endl;
	}
	else
	{
		cout << "a == b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>

int n;
int a;  // answer

int main(void) {
    scanf("%d", &n);
    
    if (n >= 64) {
        a = 64;
    } else if (n >= 32) {
        a = 32;
    } else if (n >= 16) {
        a = 16;
    } else if (n >= 8) {
        a = 8;
    } else if (n >= 4) {
        a = 4;
    } else if (n >= 2) {
        a = 2;
    } else {
        a = 1;
    }
    
    printf("%d\n", a);
    return 0;
}

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

int main() {
    int h, w, a, b; cin >> h >> w >> a >> b;
    rep(i,h){
        rep(j,w){
            if((i < b && j < a) || (i >= b && j >= a)){
                cout << 1;
            }
            else cout << 0;
        }
        cout << endl;
    }
}


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

using i64 = long long int;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }
    int c = 10000, ans = 0;
    for(int i=1;i<n;++i){
        if(v[i] == v[i-1]){
            v[i] = c;
            c--;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll, ll>pll;

vector<int>a;
vector<ll>sum;
int visited[404][404];
ll memo[404][404];
int n;

void init() {
	sum.resize(n + 1);
	rep(i, 0, n)sum[i+1] = sum[i] + a[i];
}
ll get(int l,int r){
	return sum[r + 1] - sum[l];
}
ll dp(int l, int r) {
	if (visited[l][r])return memo[l][r];
	if (l == r)return 0;

	visited[l][r] = 1;
	ll res = inf;
	rep(i,l,r)res = min(res,dp(l,i)+dp(i+1,r)+get(l,r));
	return memo[l][r] = res;
}

int main(){
	cin >> n;
	a.resize(n);
	rep(i, 0, n)cin >> a[i];
	init();
	cout << dp(0, n - 1) << endl;
	
	return 0;
}



Measured memory_bytes: 2176
n = int(input())


dic_blue = {}
for i in range(n):
    a = str(input())
    if a in dic_blue:
        dic_blue[a] += 1
    else:
        dic_blue[a] = 1

m = int(input())
dic_red = {}
for i in range(m):
    b = str(input())
    if b in dic_red:
        dic_red[b] += 1
    else:
        dic_red[b] = 1

total_list = []
total_list.append(0)
for j in dic_blue.keys():
    total = 0
    if j in dic_red:
        total = dic_blue[j] - dic_red[j]
        total_list.append(total)
    else:
        total = dic_blue[j]
        total_list.append(total)

print(max(total_list))

Measured memory_bytes: 8944
#include <algorithm>
#include <cstdio>
const int MAXN = 1E5+5;
const int LOGN = 18;
int array[MAXN]{ };
int    dp[MAXN]{ };
int spars[LOGN][MAXN]{ };
//  spars[I][J] = Farthest Child of [J] after [1<<I] days
int A, B, D, N, Q;

void solve()
{
	dp[1] = 0;
	int head=1, tail=1;
	while(head <= N)
	{	// Init Sparse Table
		if(tail < head)
			tail = head;
		bool end = (array[tail]-array[head] > D);
		spars[0][head] = tail-end;
		while((tail <= N) && (array[tail]-array[head] <= D))
		{
			dp[tail] = std::min(dp[head]+1, dp[tail]);
			spars[0][head] = tail;
			++tail;
		}
		++head;
	}
}

int main()
{
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i)
	{
		scanf("%d", &array[i]);
		dp[i] = MAXN;
	}
	scanf(" %d%d", &D, &Q);
	array[N+1] = array[N]+D+1;
	solve();
	for(int day = 1; day < LOGN; ++day) // f^(2^day)(x)
		for(int hot = 1; hot <= N; ++hot) // Hotel ID
			spars[day][hot] = spars[day-1][spars[day-1][hot]];
	/* for(int day = 0; day < LOGN; ++day)
		for(int hot = 1; hot <= N; ++hot)
			printf("%d%c", spars[day][hot], (hot==N)?'\n':' '); */
	while(Q --> 0)
	{
		scanf(" %d%d", &A, &B);
		if(A > B) std::swap(A, B);
		int cnt, K = B-A, ret=0;
		do {
			cnt = 0;
			while((cnt+1 < LOGN) && (spars[cnt+1][A] < B)) ++cnt;
			// printf("%d -[%d]-> %d\n", A, cnt, spars[cnt][A]);
			A = spars[cnt][A];
			ret += 1<<cnt;
		} while(A < B);
		printf("%d\n", ret);
	}
	return 0;
}
/*
9
1 3 6 13 15 18 19 29 31
10
4
1 9
5 9
7 9
8 9
*/

Measured memory_bytes: 8576
from collections import deque


def bfs(y,x):
    global s
    global fl
    global h
    global w
    global ans
    dx = [0,1,0,-1]
    dy = [1,0,-1,0]
    count = 1
    black = 0
    d = deque()
    # appendするときに計算する
    d.append([y,x])
    fl[y][x] = 1
    if s[y][x]=='#':
        black+=1
    while len(d):
        p = d.pop()
        for k in range(4):
            if 0<=p[1]+dx[k] <w and 0<=p[0]+dy[k] <h and s[p[0]][p[1]]!=s[p[0]+dy[k]][p[1]+dx[k]]:
                if fl[p[0]+dy[k]][p[1]+dx[k]]:
                    continue
                d.append([p[0]+dy[k],p[1]+dx[k]])
                count += 1
                fl[p[0]+dy[k]][p[1]+dx[k]] = 1
                if s[p[0]+dy[k]][p[1]+dx[k]]=='#':
                    black+=1
    ans += black*(count-black)


h, w = map(int, input().split())
s = [input() for i in range(h)]
fl = [[0 for _ in range(w)] for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if not fl[i][j]:
            bfs(i,j)
print(ans)

Measured memory_bytes: 14868
#include<bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    string s; cin >> s;
    bool nikui=false;
    rep(i, s.length()){
        if(i % 2 == 0 and s[i] == 'L'){
            nikui = true;
        }
        if(i % 2 == 1 and s[i] == 'R'){
            nikui = true;
        }
    }
    if(nikui){cout << "No" << endl;}
    else {cout << "Yes" << endl;}
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   
        
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int  i,j;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
    return 0;
}

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

int main() {
  int n, i = 0, now = 0;
  cin >> n;
  vector<int> a(n + 1), b(n + 1, 1);
  for (int i = 1; i <= n; i++) cin >> a[i];

  now = 1;
  while (b[now]) {
    b[now] = 0;
    now = a[now];
    i++;
    if (now == 2) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
}

Measured memory_bytes: 1024
def main():
    S = input()

    n = len(S)
    ans = 0
    for i in range(n):
        for j in range(i, n):
            x = S[i:j+1]
            tmp = len(x)
            for c in x:
                if c not in "ACGT":
                    tmp = -1
                    break
            ans = max(ans, tmp)

    print(ans)


if __name__ == '__main__':
    main()


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

#define SZ(x) ((int(x.size())))

typedef long long ll;
typedef long double ld;

using namespace std;

const int maxn = 100*1000+10;
int n, a[maxn];
ll dp[maxn][4], tmp;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] > 3)
        {
            tmp += (a[i] - 2) / 2;
            a[i] -= (a[i] - 2) / 2 * 2;
        }
    }
    dp[0][2] = dp[0][3] = 1;
    for (int i = 1; i < n; i++)
    {
        dp[i][0] = dp[i - 1][a[i - 1]];
        dp[i][1] = dp[i - 1][a[i - 1]];
        if (a[i - 1] > 0)
            dp[i][1] = max (dp[i][1], dp[i - 1][a[i - 1] - 1] + 1);
        dp[i][2] = dp[i - 1][a[i - 1]] + 1;
        if (a[i - 1] > 0)
            dp[i][2] = max (dp[i][2], dp[i - 1][a[i - 1] - 1] + 1);
        dp[i][3] = dp[i - 1][a[i - 1]] + 1;
        if (a[i - 1] > 0)
            dp[i][3] = max (dp[i][3], dp[i - 1][a[i - 1] - 1] + 2);
    }
    cout << dp[n - 1][a[n - 1]] + tmp;
	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll X;
    cin >> X;
    vector<ll> l(N,0);
    for(ll i=0;i<N;i++){
        cin>>l[i]
    ;}
    ll sum=0;
    ll count=0;
    while(sum<=X){
        if(count==N+1)break;
        sum+=l[count];
        count++;
    }
    cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys

S = list(sys.stdin.readline().rstrip())
cnt_w = S.count('W')
loc_w = [i+1 for i,c in enumerate(S) if c == 'W']
print(sum(loc_w)-cnt_w*(cnt_w+1)//2)

# BW  BBW  WBWB
# ↓   ↓     ↓
# WB  WBB  WWBB

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

typedef long long ll;

const int Maxn = 6005;
const int Maxm = 2005;

int n, mod;
int dp[Maxn][Maxm];

int main()
{
    scanf("%d %d", &n, &mod);
    dp[0][0] = 1;
    for (int i = 1; i <= 3 * n; i++)
        for (int j = 0; j <= n; j++) {
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            if (i >= 2 && j >= 1)
                dp[i][j] = (dp[i][j] + ll(dp[i - 2][j - 1]) * (i - 1)) % mod;
            if (i >= 3 && j >= 1)
                dp[i][j] = (dp[i][j] + ll(dp[i - 3][j - 1]) * (i - 1) % mod * (i - 2)) % mod;
        }
    int res = 0;
    for (int j = 0; j <= n; j++)
        res = (res + dp[3 * n][j]) % mod;
    printf("%d\n", res);
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int k;
    cin>>k;
    ll cur = 0;
    for(int i=1;i<=10000000;++i){
        cur = (cur*10 +7)%k;
        if(cur == 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
    
}


Measured memory_bytes: 3600
n,x = [int(i) for i in input().split()]
array = [int(i) for i in input().split()]

y=x

array.sort()

cnt = 0
for i in range(n):
  x -= array[i]
  if x >= 0:
    cnt += 1
    
if cnt == n and sum(array) !=y:
  cnt = cnt-1
    
print(cnt)

Measured memory_bytes: 3064