akhauriyash/Code-Regression huggingface dataset:
bingo_list = [list(map(int,input().split())) for i in range(3)]
bingo_list = sum(bingo_list,[])
n = int(input())
bingo_number = [int(input())for i in range(n)]
check_list = [0 for i in range(9)]

for j in bingo_number:
    if j in bingo_list:
        check_list[bingo_list.index(j)] = 1

if  [1,1,1]  in [check_list[:3], check_list[3:6], check_list[6:], check_list[0:7:3], check_list[1:8:3],check_list[2:9:3],check_list[0:9:4],check_list[2:7:2]]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int d, n, ans = 0;;
    cin >> n >> d;
    vector<double> a(d);
    vector<vector<double>> x(n);
    for(int j = 0;j < n;j++){
        for(int i = 0;i < d;i++){
            cin >> a[i];
        }
        x[j] = a;
    }

    for(int i = 0;i < n - 1;i++){
        for(int j = i + 1;j < n;j++){
            double dis = 0;
            for(int k = 0;k < d;k++){
                dis += (abs(x[i][k] - x[j][k])) * (abs(x[i][k] - x[j][k])); 
            }
            dis = sqrt(dis);
            if(dis == (int)dis){
                ans++;
            }
        }
    }

    cout << ans;
    
    return 0;
}

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

const int ALPHABET = 26;

int main(){
    int n, q;
    string s;
    cin >> n >> s >> q;
    set<int> idx[ALPHABET];
    for(int i = 0; i < n; i++){
        idx[s[i]-'a'].insert(i);
    }
    for(int j = 0; j < q; j++){
        int t;
        cin >> t;
        if(t == 1){
            int i; char c;
            cin >> i >> c;
            i--;
            idx[s[i]-'a'].erase(i);
            s[i] = c;
            idx[s[i]-'a'].insert(i);
        } else {
            int l, r;
            cin >> l >> r;
            int cnt = 0;
            for(int k = 0; k < ALPHABET; k++){
                auto itr = idx[k].lower_bound(l-1);
                if(itr != idx[k].end() && *itr < r) cnt++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 27248
#include<bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans;
    int cntr=0, cntw=0;
	for(int i=0;i<n;i++){
	if(s[i]=='R')
	cntr++;
	else
	cntw++;
	}
	int ch=0;
	for(int i=0;i<cntr;i++)
	if(s[i]=='W')
	ch++;
	ans=min(ch,min(cntr,cntw));
	

	cout<<ans;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, s, x;
	cin >> n >> m;
	s = 0;
	vector<int> a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i];
	}
	sort(a.rbegin(), a.rend());
	if (a[m - 1] * 4 * m >= s) cout << "Yes\n";
	else cout << "No\n";


	return 0;
}



Measured memory_bytes: 256
string = input()
n = int(input())
for x in range(n):
    command = tuple(map(str, input().split()))
    if command[0] == "print":
        a = int(command[1])
        b = int(command[2]) + 1
        print(string[a:b])
    elif command[0] == "reverse":
        a = int(command[1])
        b = int(command[2]) + 1
        old = string[a:b]
        new = ""
        for y in old:
            new = y + new
        string = string[:a] + new + string[b:]
    else:
        a = int(command[1])
        b = int(command[2]) + 1
        p = command[3]
        string = string[:a] + p + string[b:]



Measured memory_bytes: 5612
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll>Q;


int main(void){
    int n;
    ll T;
    cin>>n>>T;
    vector<ll>t(n);
    for(int i=0;i<n;i++)cin>>t[i];
    ll ans = 0;
    ll now=0;
    ll next = 0;
    for(ll i=0;i<n;i++){
        if(i==0){
            now = t[i];
            next = t[i]+T;
        }
        else{
            if(next < t[i]){
                ans+=next-now;
                now = t[i];
                next = t[i]+T;
            }
            else{
                next = t[i]+T;
            }
        }
    }
    ans+=next-now;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
    int n, s;
    double mean, sd, sum = 0;
    vector<int> ss;
    while (1) {
        cin >> n;
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            cin >> s;
            sum += s;
            ss.push_back(s);
        }
        mean = sum / n;
        sum = 0;
        for (int i = 0; i < n; i++) {
            sum += pow((ss[i] - mean), 2.0);
        }
        sd = sqrt(sum / n);
        printf("%.5f\n", sd);
        sum = 0;
        vector<int>().swap(ss);  // Force free
    }
    return 0;
}

Measured memory_bytes: 1248
#include <iostream>

using namespace std;

int n;
string s;

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

	char last = 'A';
	int ans = 0;

	for (char c : s)
	{
		if (c == last)
			continue;

		last = c;
		++ans;
	}

	cout << ans << endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n; scanf("%d",&n);
    vector<int> a(n);
    rep(i,0,n)scanf("%d",&a[i]);
    int ans=a[0];
    rep(i,1,n)ans+=max(0,a[i]-a[i-1]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};

fn main() {
    let xs = read_vec_i64();
    let (v,e,r) = (xs[0] as usize, xs[1] as usize, xs[2] as usize);
    let mut edges = vec![];
    for _ in 0..e {
        let ys = read_vec_i64();
        let (s,t,d) = (ys[0] as usize, ys[1] as usize, ys[2]);
        edges.push((s,t,d));
    }
    let mut dists = vec![None; v];
    dists[r] = Some(0);
    for _ in 0..v {
        for k in 0..e {
            let (s,t,d) = edges[k];
            if let Some(sd) = dists[s] {
                let nd = sd + d;
                if dists[t].is_none() || nd < dists[t].unwrap() {
                    dists[t] = Some(nd);
                }
            }
        }
    }
    for &(s,t,d) in &edges {
        if dists[s].is_some() && dists[t].is_some() {
            if dists[s].unwrap() + d < dists[t].unwrap() {
                println!("NEGATIVE CYCLE");
                return;
            }
        }
    }
    for &d in &dists {
        match d {
            Some(x) => println!("{}", x),
            None => println!("INF"),
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}



Measured memory_bytes: 5036
n,m=map(int,input().split())
li = [list(map(int, input().split())) for i in range(m)]
 
a=li[0][0]
b=li[0][1]
for i in range(m-1):
  if li[i+1][0]>a:
    a=li[i+1][0]
  if li[i+1][1]<b:
    b=li[i+1][1]
 
if b<a:
  print(int(0))
  exit()
  
if b-a+1<n:
  print(b-a+1)
else:
  print(n)

Measured memory_bytes: 27340
local function array(dimension, default_val) local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local MOD = math.floor(10^9)+7
local S = io.read()
local N = #S
local ti = array(1, 0)
local tio = array(1, 0)
tio[0] = 1
for i=1,N do
    local c = S:sub(i,i)
    if c == '?' then
        local oldsum = tio[0] + tio[1] + tio[2] + tio[3] + tio[4] + tio[5] + tio[6] + tio[7] + tio[8] + tio[9] + tio[10] + tio[11] + tio[12]
        ti[0] = (oldsum - tio[4] - tio[8] - tio[12]) % MOD
        ti[1] = (oldsum - tio[3] - tio[8] - tio[12]) % MOD
        ti[2] = (oldsum - tio[3] - tio[7] - tio[12]) % MOD
        ti[3] = (oldsum - tio[3] - tio[7] - tio[11]) % MOD
        ti[4] = (oldsum - tio[2] - tio[7] - tio[11]) % MOD
        ti[5] = (oldsum - tio[2] - tio[6] - tio[11]) % MOD
        ti[6] = (oldsum - tio[2] - tio[6] - tio[10]) % MOD
        ti[7] = (oldsum - tio[1] - tio[6] - tio[10]) % MOD
        ti[8] = (oldsum - tio[1] - tio[5] - tio[10]) % MOD
        ti[9] = (oldsum - tio[1] - tio[5] - tio[9]) % MOD
        ti[10] = (oldsum - tio[0] - tio[5] - tio[9]) % MOD
        ti[11] = (oldsum - tio[0] - tio[4] - tio[9]) % MOD
        ti[12] = (oldsum - tio[0] - tio[4] - tio[8]) % MOD
    else
        c = tonumber(c)
        ti[(0 + c) % 13] = tio[0]
        ti[(10 + c) % 13] = tio[1]
        ti[(20 + c) % 13] = tio[2]
        ti[(30 + c) % 13] = tio[3]
        ti[(40 + c) % 13] = tio[4]
        ti[(50 + c) % 13] = tio[5]
        ti[(60 + c) % 13] = tio[6]
        ti[(70 + c) % 13] = tio[7]
        ti[(80 + c) % 13] = tio[8]
        ti[(90 + c) % 13] = tio[9]
        ti[(100 + c) % 13] = tio[10]
        ti[(110 + c) % 13] = tio[11]
        ti[(120 + c) % 13] = tio[12]
    end
    tio, ti = ti, tio
end
print(tio[5])

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      	int n = sc.nextInt();
		String s = sc.next();
        int k = sc.nextInt();
        String a[] = s.split("");
        int i;
        String ans = a[k - 1];
      	for(i = 0;i < n;i++){
          if(!a[i].equals(ans)){
            a[i] = "*";
          }
        }
        
      	for(i = 0;i < s.length();i++){
          System.out.print(a[i]);
        }
      
    }
}

Measured memory_bytes: 35824
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf = 1e6+9;

int main(){

    ll k;
    cin>>k;
    ll cur = 7;
    for(ll i=1;i<=inf;i++){
        if( (cur % k) == 0)
            cout<<i<<endl,exit(0);
        cur = (cur*10)%k;
        cur = (cur+7)%k;
    }
    cout<<-1<<endl;
}


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

P f(int x) {
  int a = x%10;
  int b = 0;
  while (x) {
    b = x;
    x /= 10;
  }
  return P(a,b);
}

int main() {
  int n;
  cin >> n;
  map<P,int> freq;
  for (int i = 1; i <= n; ++i) {
    P p = f(i);
    freq[p]++;
  }
  ll ans = 0;
  for (int i = 1; i <= n; ++i) {
    P p = f(i);
    P q(p.second, p.first);
    ans += freq[q];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

H, N = map(int, input().split(" "))
dp = [1e10 for i in range(H + 1)]
dp[0] = 0

for i in range(N):
    A, B = map(int, input().split(" "))
    for j in range(H + 1):
        if dp[j] != 1e10:
            dp[min(j + A, H)] = min(dp[min(j + A, H)], dp[j] + B)
print(dp[H])


Measured memory_bytes: 49116
#include <stdio.h>

int main(){
  int a, b;
  scanf("%d %d", &a, &b);
  if(a < b){
    printf("a < b\n");
  }
  else if(a > b){
    printf("a > b\n");
  }
  else{
    printf("a == b\n");
  }
  return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define qrep(i, q) for(auto i : q)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int maxn = 100005;
const int inf = 0x3f3f3f3f;

int main()
{
	//std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
	ll x;
	cin >> x;
	ll p = 100;
	rep(i, 1, 4000){
		p = floor(p+p*0.01);
		if(p >= x) return cout << i << endl, 0;
	}
	return 0;
}


Measured memory_bytes: 3744
N, K, S = map(int, input().split())

A = [S for i in range(K)]

if S == 1:
  A = A[:] + [2 for i in range(N - K)]
elif S == int(1e+9):
  A = A[:] + [S - 1 for i in range(N - K)]
else:
  A = A[:] + [int(1e+9) for i in range(N - K)]

for i in range(N):
  if i != N - 1:
    print(A[i], end = ' ')
  else:
    print(A[i])

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

using namespace std;

const int max_n = 100111, mod = 998244353;

int n, a[max_n];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 1;
    for (int i = 0; i < n; ++i) {
        ans = 1LL * ans * __gcd(a[i], i) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
type Index = Int
type Total = Int
type MinN = Int
type Material = Int

func :: Index -> Total -> MinN -> Material -> [Int] -> Int
func index total minN mat [] = (mat - total) `div` minN + index
func index total minN mat (x:xs) =
  func (succ index) (total+x) (min minN x) mat xs

main = do
  line <- getLine
  contents <- getContents
  let
    [_,x] = map read $ words line :: [Int]
    xs = map read $ lines contents :: [Int]
    ans = func 0 0 10000 x xs
  putStrLn $ show ans


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

map <int, int> mp;

void solve(void){
    int N;
    cin >> N;
    rep(N, i) {
        int A; scanf("%d ", &A);
        mp[A]++;
    }
    int ans = 0;
    for (auto p : mp) {
        int x = p.first, n = p.second;
        if (x <= n) ans += n - x;
        else ans += n;
    }
    cout << ans << '\n';
}

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


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

int main(){
  ll Q, T,F;
  string S;
  string a;
  ll c=0;
  
  cin>>S>>Q;
  
  rep(i,Q){
    cin>>T;
    if(T==1){
      c++;
    }
    
    if(T==2){
      cin>>F>>a;
      if((c%2==0 && F==1) || (c%2==1 && F==2) ){
        S.insert(0,a);
      }
      else{
        S+=a;
      }
    }
  }
         
         
    if(c%2==0){
      cout<<S;
    }
    
    if(c%2==1){
      reverse(S.begin(),S.end());
      cout<<S;
    }
         
         
}
     


Measured memory_bytes: 900
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int A,B;
string S;

bool solve(){
    for(int i = 0; i < S.size(); i++){
        char cur = S[i];
        if(i == A){
            if(cur != '-') return false;
        }else{
            if((cur - '0') > 9 || (cur - '0') < 0) return false;
        }
    }
    return true;
}

int main(){
    cin >> A >> B >> S;

    if(solve()) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll, ll>
#define psi pair<string, ll>
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define PI 3.14159265
#define r0 return 0
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
const char char_max = (char)(((unsigned char) char(-1)) / 2);

ll answer(ll n,ll b){
    ll count=0;
    while(n>0){
        count++;
        n/=b;
    }
    return count;
}

int main() {
  fast
  ll n,b;
  cin>>n>>b;
  cout<<answer(n,b);
}



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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;

int X1, Y1, X2, Y2;
int n;

const double pi = acos(-1);

const int maxn = 2e5 + 5;
int l[maxn], r[maxn];
int v[maxn], tot;
int dp[maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> X1 >> Y1 >> X2 >> Y2;
    cin >> n;
    if(X1 > X2){
        swap(X1, X2);
        swap(Y1, Y2);
    }
    cout << setprecision(15) << fixed;
    if(X1 == X2){
        if(Y1 > Y2){
            swap(Y1, Y2);
        }
        double ans = abs(Y1 - Y2) * 100.0;
        for(int i = 1;i <= n;i++){
            int a, b;
            cin >> a >> b;
            if(a == X1 and Y1 <= b and b <= Y2){
                ans = abs(Y1 - Y2) * 100.0 + pi * 10 - 20; 
            }
        }
        cout << ans << endl;
    }else if(Y1 == Y2){
        if(X1 > X2){
            swap(X1, X2);
        }
        double ans = abs(X1 - X2) * 100.0;
        for(int i = 1;i <= n;i++){
            int a, b;
            cin >> a >> b;
            if(a >= X1 and a <= X2 and b == Y1){
                ans = abs(X1 - X2) * 100.0 + pi * 10 - 20;
            }
        }
        cout << ans << endl;
    }else{
        tot = 0;
        for(int i = 1;i <= n;i++){
            cin >> l[i] >> r[i];
        }
        if(Y1 > Y2){
            Y1 = -Y1;
            Y2 = -Y2;
            for(int i = 1;i <= n;i++){
                r[i] = -r[i];
            }
        }
        vector<pair<int, int> > A;
        for(int i = 1;i <= n;i++){
            if(l[i] >= X1 and l[i] <= X2 and r[i] >= Y1 and r[i] <= Y2){
                v[++tot] = r[i];
                A.eb(l[i], r[i]);
            }
        }
        sort(A.begin(), A.end());
        int m = tot;
        vector<int> B(m, 0);
        sort(v + 1, v + 1 + tot);
        tot = unique(v + 1, v + 1 + tot) - v - 1;
        for(int i = 0;i < m;i++){
            B[i] = lower_bound(v + 1, v + 1 + tot, A[i].se) - v;
        }
        memset(dp, 0x3f, sizeof(dp));
        dp[0] = 0;
        int ans = 0;
        for(int i = 0;i < m;i++){
            int id = lower_bound(dp, dp + n + 1, B[i]) - dp - 1;
            dp[id + 1] = min(dp[id + 1], B[i]);
        }
        for(int i = 0;i <= n;i++){
            if(dp[i] != 0x3f3f3f3f){
                ans = max(ans, i);
            }
        }
        if(ans == min(Y2 - Y1, X2 - X1) + 1){
            cout << (abs(X1 - X2) + abs(Y1 - Y2)) * 100.0 + (ans - 1) * (pi * 5 - 20) + (pi * 10 - 20) << endl;
        }else{
            cout << (abs(X1 - X2) + abs(Y1 - Y2)) * 100.0 + ans * (pi * 5 - 20) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 5744
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

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

    for (int i = X - (K - 1); i <= X + (K - 1); i++)
    {
        /* code */
        cout << i << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define inf 20000000000007
using namespace std;

int n,minv=inf,pos;
int a[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	
	sort(a+1,a+n+1);
	
	int now=a[n]/2;
	for (int i=1;i<=n-1;i++)
	{
		if (abs(a[i]-now)<=minv)
		{
			minv=abs(a[i]-now);
			pos=a[i];
		}
	}
	cout<<a[n]<<' '<<pos<<endl;
	
	return 0;
} 

Measured memory_bytes: 4420
#include<bits/stdc++.h>
#include <cstdio>
using namespace std;
#define ll  long long
#define PB push_back
#define ld long double
#define ff first
#define ss second
# define st(v) (v).begin(),(v).end()
#define   pr pair<int,int>
using namespace std::chrono;
const int N = 1e5+4 , M=N,inf=(int)1e9;
const ll mod=1e9+7;
int fastAbs(int n) { return (n ^ (n >> 31)) - (n >> 31); }
ll multiply(ll a, ll b){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
int ans ;
map< pair<int,int> , int > mp;
const int dx[4] = {1,0,0,-1};
const int dy[4] = {0,-1,1,0};
void solve(){
    int n ;
    cin >> n ;
    vector < ll > a(n) ;
    for( int i = 0 ; i < n ; i++)   cin >> a[i] ;
    vector < vector < ll >  > dp(n,vector < ll > (2,0));
    dp[0][0] = a[0] ;
    dp[0][1] = -a[0] ;
    for( int i = 1 ; i < n-1 ; i++){
            dp[i][0] = max(dp[i-1][0]+a[i],dp[i-1][1]-a[i]);
            dp[i][1] = max(dp[i-1][0]-a[i],dp[i-1][1]+a[i]);
    }
    //for( int i = 0 ; i < n ; i++) cout << dp[i][0] << " " << dp[i][1] << "\n";
    cout << max(dp[n-2][1]-a[n-1],dp[n-2][0]+a[n-1]);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int q=1;
    //cin >> q;
    while(q--)
        solve();
}


Measured memory_bytes: 6528
#include <stdio.h>

int main(void) {
	int H, W, h, w;
	int total;

	scanf("%d%d%d%d", &H, &W, &h, &w);
	total = H * W;
	total = total - W * h;
	total = total - (H - h)*w;

	printf("%d\n", total);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        double[] v = new double[n];

        for(int i = 0;i<n;i++){
            v[i] = Double.parseDouble(sc.next());
        }
        Arrays.sort(v);
        double ans = 0;
        ans = (v[0] + v[1]) / 2.0;
        for(int i = 1;i <n - 1;i++){
            ans = (ans + v[i + 1]) / 2.0;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
int main()
{
    long long n;
    scanf("%lli",&n);
    if (n%2 == 0) {
        double l = 0.5;
        printf("%lf",l);
    } else {
        long long u = n+1;
        long long d = 2*n;
        double m = (double)u/(double)d;
        printf("%lf",m);
    }
    return 0;
}

Measured memory_bytes: 1720
import numpy as np

n = int(input())
x_str = input().split()
xs = np.array([int(c) for c in x_str])

xs_len = len(xs)
center = (xs_len - 1)//2

c_xs = np.sort(xs)

for x in xs:
    if x <= c_xs[center]:
        print(c_xs[center+1])
    else:
        print(c_xs[center])


Measured memory_bytes: 35724
import java.util.*;

public class Main {
	private static Scanner sc=new Scanner(System.in);;

	public static void main(String args[]) {
		while(sc.hasNextInt()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int l = sc.nextInt();
			long temp1[][] = new long[n][m];
			long  temp2[][] = new long[m][l];
			for (int i=0;i<n;i++) {
				for (int j=0;j<m;j++) {
					temp1[i][j] = sc.nextLong();
				}
			}
			for (int i=0;i<m;i++){
				for(int j=0;j<l;j++) {
					temp2[i][j]=sc.nextLong();
				}
			}
			for(int i=0;i<n;i++){
				for(int j=0;j<l;j++) {
					long ans=0;
					for (int k=0;k<m;k++) {
						ans+=temp1[i][k]*temp2[k][j];
					}
					System.out.printf(j==l-1?"%d%n":"%d ",ans);
				}
			}
		}
	}
}

Measured memory_bytes: 56936
#include<stdio.h>

int main(void){
int a,b,c;
int count = 0;
int i;
scanf("%d %d %d",&a,&b,&c);
for(i=a;i<=b;i++){
if(c%i==0)count++;
}
printf("%d\n",count);
return 0;
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }
 
int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    char s[n];
    for (ll i = 0; i < n; i++){
        cin >> s[i];
    }

    ll all = 0, fo = 0;
    for (ll i = 0; i < n; i++){
        // cout << i << endl;
        if (s[i] == 'c'){
            cout << "No" << endl;
        }else if(s[i] == 'a'){
            if(all < (a + b)){
                cout << "Yes" << endl;
                all++;
            }else{
                cout << "No" << endl;
            }
        }else if(s[i] == 'b'){
            if(all < (a + b) & fo < b){
                cout << "Yes" << endl;
                all++;
                fo++;
            }else{
                cout << "No" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        boolean[] isZoro = new boolean[n];
        for(int i = 0; i < n; i++){
            if(scan.nextInt() == scan.nextInt()) isZoro[i] = true;
        }
        for(int i = 0; i < n - 2; i++){
            if(isZoro[i] && isZoro[i + 1] && isZoro[i + 2]){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

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


Measured memory_bytes: 36024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ld long double
#define u128 __int128
#define ff first
#define ss second
#define pb push_back

#define MOD 1000000007
#define INTMAX 1000000009
#define N 100050

void solve()
{
	ll n;
	cin >> n;
	ll a[n];
	ll mean = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		mean += a[i];
	}
	ll sum = mean;
	
	for (int i = 0; i < n; ++i)
	{
		if((sum - a[i]) * n == mean * (n-1))
		{
			cout << i + 1 << "\n";
			return;
		}
	}
	cout << "Impossible\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(6);
	int n;
	cin >> n;
	double ans = 0;
	string u;
	double x;
	for (int i = 0; i < n; ++i)
	{
		cin >> x >> u;
		if(u == "JPY")
		{
			ans += x;
		}
		else
		{
			ans += 380000.0 * x;
		}
	}
	cout << fixed << ans << "\n";
	return 0;	
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;


int main(int argc, char *argv[]) {
	int n;
	cin >> n;

	int c = 0;
	if (n / 100 <= 12 && n / 100 >= 1)
		c += 1;
	if (n % 100 <= 12 && n % 100 >= 1)
		c += 2;
	switch (c) {
		case 0:
			cout << "NA" << endl;
			break;
		case 1:
			cout << "MMYY" << endl;
			break;
		case 2:
			cout << "YYMM" << endl;
			break;
		case 3:
			cout << "AMBIGUOUS" << endl;
			break;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define boost std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
using LL = long long;

constexpr int MAXN = 2e5 + 4;
constexpr LL M = 998244353;

template <typename T> inline void read(T &x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

LL n, m, cnt[MAXN];

int main() {
    boost;
    cin >> n;
    for (int i = 2, tmp; i <= n; i++) {
        cin >> tmp;
        cnt[tmp]++;
    }
    for (int i = 1; i <= n; i++)
        cout << cnt[i] << endl;
    return 0;
}

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

int main() {
  long long n;
  cin >> n;
  
  vector <long long> b;
  b.reserve(n-1);
  for (int i = 0; i < n-1; i++) {
    int t;
    cin >> t;
    b.push_back(t);
  }

  vector <long long> a;
  a.reserve(n);
  a[0] = b[0];
  a[1] = b[0];
  for (int i = 1; i < n-1; i++) {
    if (a[i] > b[i]) a[i] = b[i];
    a[i+1] = b[i];
  }
  
  long long sum = 0;
  for (int i = 0; i < n; i++) sum += a[i];
  
  cout << sum << endl;
  
  return 0;
}

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

int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

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

	int k;
	cin >> k;
	string s;
	cin >> s;
	string ans;
	int n = s.length();
	int x = min(k, n);
	for (int i = 0; i < x; i++) {
		ans += s[i];
	}
	if (s.length() > k) {
		ans += "...";
	}

	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 3680
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())

priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


void solve(){
    int a,b,x;
    cin >> a >> b >> x;
    if(x-a<=b && x-a>=0)cout << "YES" << endl;
    else cout << "NO" << endl;
}

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




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

#define MAX 200001
int a[MAX];

int main(){
	int n,k;	cin>>n>>k;
	for(int i=0;i<n;i++){
		int x;	cin>>x;
		a[x]++;
	}
	sort(a, a+MAX, greater<>());

	int ans=0;
	for(int i=0;i<n;i++){
		if(i>=k) ans+=a[i];
	}
	cout<<ans<<endl;

	return 0;
}


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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int k,t; cin >> k >> t;
  vector<int> a(t);
  for(int i = 0; i < t; i++){
    cin >> a[i];
  }

  sort(a.begin(),a.end());
  cout << max(0LL,a[t-1] - (k - a[t-1] + 1)) << endl;

  return 0;
}


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

#define int long long
#define pb push_back
#define mod 1000000007
#define endl '\n'
#define w(x) int x;cin>>x; while(x-->0)

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
vector<vector<int>> v(100011);
// bool visited[10001]={false};
int dp[100011];
int n, m;
int ans = 0;
int dfs(int id)
{
    if (dp[id] != -1)
        return dp[id];
    int t = 0;
    for (int i : v[id])
        t = max(t, dfs(i) + 1);
    // ans = max(ans, t);
    return dp[id] = t;
}
void mysol()
{
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        v[a].pb(b);
    }
    for (int i = 1; i <= n; i++)
    {

        ans = max(ans , dfs(i));
    }
    cout << ans;
}

int32_t main()
{
    //fast();
    // w(t)
    {
        mysol();
    }
    return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){  
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> mp;
  REP(i, N){
    cin >> A[i];
    mp[A[i]]++;
  }
  
  int ans = 0;
  REP(i, N){
    if(mp[A[i]] >= 2) continue;
    if(A[i] != 1 && mp[1]) continue;
    bool flag = true;
    for(int x = 2; x*x <= A[i]; x++){
      if(A[i] % x != 0) continue;
      if(mp[A[i]/ x]) flag = false;
      if(mp[x]) flag = false;
    }
    if(flag) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

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

const int N = (int)1e5 + 123, mod = (int)1e9 + 7;
const ll inf = (ll)1e18;

ll n, q, ans[N];
vector< ll > v;
set< pll > st;

void add(ll x, ll c){
	auto it = st.lower_bound({-x, -inf});
	if((*it).f == -x){
		c += (*it).s;
		st.erase(it);
	}
	st.insert({-x, c});
}
int main(){    
	scanf("%d%d", &n, &q);
	v.pb(n);	
	for(int i = 0; i < q; i++){
		ll x;
		scanf("%lld", &x);
		while(!v.empty() && v.back() >= x)
			v.pop_back();
		v.pb(x);	
	}         
	st.insert({0, 0});	
	st.insert({-v.back(), 1});
	while(!v.empty()){
		ll cur = v.back();
		/*
		cerr << cur << endl;
		for(auto it : st)
			cerr << -it.f << " " << it.s << endl;
		*/
		v.pop_back();
		while(true){                
			ll x = -(st.begin() -> f);
			ll c = (st.begin() -> s);
			if(x <= cur)
				break;			
			st.erase(st.begin());
            add(x % cur, c);
			add(cur, x / cur * c); 
		}
		
		/*
		cerr << "BBB" << endl;
		for(auto it : st)
			cerr << -it.f << " " << it.s << endl;
		cerr << "AAA" << endl;
		*/
	}
	for(auto it : st)
		ans[-it.f] += it.s;
	for(int i = n; i >= 1; i--)
		ans[i] += ans[i + 1];
	for(int i = 1; i <= n; i++)
		printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 9332
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define tc int t; cin>>t; while(t--)
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mod 1000000007
#define pb push_back
#define vi vector<int>
#define vc vector<char>
#define eb emplace_back
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fo(i,x,n) for(int i=x;i<n;i++)
#define csb(x) __builtin_popcount(x)
#define tz(x) __builtin_ctz(x)
#define lsbp(x) __builtin_ffs(x)
#define msbp(x) __lg(x)
#define btoi(str,i) stoi(str,0,i)
#define ff first
#define ss second
const int inf=0x3f3f3f3f3f3f3f3f;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int32_t main(){
// zz();
int n;cin>>n;
int d=0;int cnt=0;
vector<vi>dp(3,vi(n+1,0));
for(int i=0;i<n;i++){
   int a,b,c;cin>>a>>b>>c;
   if(i==0){
     dp[0][i+1]=a;
     dp[1][i+1]=b;
     dp[2][i+1]=c;
   }
   else{
      // if(i==2)cout<<b<<endl;
       dp[0][i+1]=max(dp[1][i],dp[2][i])+a;
       dp[1][i+1]=max(dp[0][i],dp[2][i])+b;
       dp[2][i+1]=max(dp[1][i],dp[0][i])+c;
      //  cout<<dp[0][i+1]<<" "<<dp[1][i+1]<<" "<<dp[2][i+1]<<endl;
   }
}
// cout<<dp[1][3]<<endl;
// for(int i=1;i<=n;i++){
   
// }

int ans=max({dp[0][n],dp[1][n],dp[2][n]});
cout<<ans<<endl;
}

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

int main() {
    string s, p;
    cin >> s >> p;
    string s2 = s + s;
    bool pisins = false;
    for (int i = 0; i < s2.size(); i++) {
        pisins = true;
        for (int j = 0; j < p.size(); j++) {
            if (s2[i + j] != p[j]) {
                pisins = false;
            }
        }
        if (pisins) {
            break;
        }
    }
    if (pisins) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3220
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 16
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N][N],dp[1<<N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n;  
		rep(i,0,n)rep(j,0,n)cin>>ar[i][j];

		rep(mask,1,1<<n)
		{
			vi active;
			rep(pos,0,n)if(mask&(1<<pos))active.pb(pos);
			//for(auto i:active)cout<<i<<" ";
			//	cout<<endl;
			rep(i,0,active.size())rep(j,i,active.size())
			dp[mask]+=ar[active[i]][active[j]];

			for(int sub=mask;sub>0;sub=(sub-1)&mask)
			{
				dp[mask]=max(dp[mask],dp[sub]+dp[sub^mask]);
			}
			//cout<<dp[mask]<<endl;
		}

		cout<<dp[(1<<n)-1]<<endl;

    }
    return 0;
        
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        if(k==0){
            System.out.println(n);
            return;
        }
        n = n%k;
        System.out.println(Math.min(n,k-n));
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define MOD 1000000007 
#define MOD1 998244353
#define ll long long int
#define db double
#define endl "\n"
#define INF 1000000000000000000
#define INF1 1000000000
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define debx cout<<" X "<<endl;
#define deby cout<<" Y "<<endl;
#define debz cout<<" Z "<<endl;
#define deb(x) cout << '>' << #x << ':' << x << endl;
using namespace std;
 
ll mpow(ll a, ll b){
    if(!b)
        return 1;
    ll temp=mpow(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2)
        return (a*temp)%MOD;
    return temp;
}
ll mod_in(ll n){
    return mpow(n,MOD-2);
}
ll cl(ll a, ll b){
    if(a%b)
        return 1+a/b;
    return a/b;
}
ll dig(ll n){
    if(!n)
        return 0;
    return 1 + dig(n/10);
}
int main(){
    // fastio
    ll a,b;
    cin>>a>>b;
    cout<<1+2+3-a-b<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a, b = [0]*M, [0]*M
for i in range(M):
    tmp_a, tmp_b = map(int, input().split())
    a[i], b[i] = tmp_a, tmp_b
ab = zip(a,b)

# 添え字:都市,値:本数
num = [0]*(N+1)

for a_i, b_i in ab:
    num[a_i] += 1
    num[b_i] += 1

for i in range(len(num)):
    if i==0:
        continue
    else:
        print(num[i])

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	static int[] make_div_point(int state, int H) {
		TreeSet<Integer> set = new TreeSet<Integer>();
		for(int i = 0; i < (H - 1); i++) {
			if(((state >> i) & 1) == 1) {
				set.add(i + 1);
			}
		}
		set.add(0);
		set.add(H);
		int[] ans = new int[set.size()];
		int i = 0;
		while(!set.isEmpty()) {
			ans[i] = set.pollFirst();
			i++;
		}
		return ans;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt(), W = sc.nextInt(), K = sc.nextInt();
		int[][] S = new int[H][W];
		for(int i = 0; i < H; i++) {
			String str = sc.next();
			for(int j = 0; j < W; j++) S[i][j] = str.charAt(j) - '0';
		}

		int ans = H + W;
		// check all patter in H
		for(int ptn = 0; ptn < (1 << (H - 1)); ptn++) {
			// encode ptn
			int num_block = Integer.bitCount(ptn) + 1;	// number of blocks after dividing
			int[] white_counter = new int[num_block];	// number of white choco in each blocks
			Arrays.fill(white_counter, 0);
			int[] div_point = make_div_point(ptn, H);	// array of split point
			int div_count = 0;
			boolean impossible = false;					// over K...

			// cutting greedy
			for(int i = 0; i < W; i++) {
				// need splitting ?
				boolean need_splitting = false;
				for(int d = 0; d < num_block; d++) {
					int sum = 0;
					for(int j = div_point[d]; j < div_point[d + 1]; j++) sum += S[j][i];
					if(sum > K) {
						impossible = true;
						break;
					}
					if(white_counter[d] + sum > K) {
						need_splitting = true;
						break;
					}
				}
				if(impossible) break;

				// if need -> splitting
				if(need_splitting) {
					Arrays.fill(white_counter, 0);
					div_count++;
				}
				for(int d = 0; d < num_block; d++) {
					int sum = 0;
					for(int j = div_point[d]; j < div_point[d + 1]; j++) sum += S[j][i];
					white_counter[d] += sum;
				}
			}

			// update answer
			if(impossible) continue;
			ans = Math.min(ans, div_count + num_block - 1);
		}

		// output answer
		System.out.println(ans);
	}
}

Measured memory_bytes: 25656
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x,k,d;
    cin >> x >>k >> d;
    ll ans = abs(x);
    if(k%2==1){
        ans = min(abs(x-d),abs(x+d));
        k--;
    }
    if(k==0){
        cout << ans;
        return 0;
    }
    ll a = ans/(2*d);
    if(k <= 2*a){
        cout << ans - d * k << endl;
        return 0;
    }else{
        k -= 2*a;
        ans -= 2 * d * a;
        ans = min(ans,abs(ans-2*d));
        cout << ans;
        return 0;
    }







    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
int stack[10];
int i=0;
void push(int x);
void pop(void);
int main(){
  int x;
  while(scanf("%d",&x)!=EOF){
    if(x==0)pop();
    else push(x);
  }
  return(0);
}
void push(int x){
  stack[i]=x;
  i++;
}
void pop(void){
  i--;
  printf("%d\n",stack[i]);
}

Measured memory_bytes: 600
# 適当に10**5ぐらい回して無限に続けられたら-1でよくね？
A, B, C = map(int, input().split())


def update(A, B, C):
    return B // 2 + C // 2, C // 2 + A // 2, A // 2 + B // 2


for i in range(10 ** 5):
    if A & 1 or B & 1 or C & 1:
        print(i)
        exit()
    A, B, C = update(A, B, C)

print(-1)


Measured memory_bytes: 38768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[n];
		int n = sc.nextInt();
		int w = sc.nextInt();
		if(w>=n)
			System.out.println("unsafe");
		else
			System.out.println("safe");
	}
}

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

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll a[N], b[N];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll A, B, n;
	cin >> A >> B >> n;

	for(int i = 1; i <= A; i++) cin >> a[i];
	for(int i = 1; i <= B; i++) cin >> b[i];
	ll ans = (*min_element(b + 1, b + B + 1)) + (*min_element(a + 1, a + A + 1));
	ll x, y, z;
	for(int i = 0; i < n; i++){
		cin >> x >> y >> z;
		ans = min(ans, a[x] + b[y] - z);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1792
def main():
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)
    def lcd(a, b):
        return int(a / gcd(a, b)) * b
    
    a, b, c, d = map(int, input().split())

    def anti_div(x, y, z):
        # x:n以下の対象の値, y:割る値1, z:割る値2
        # 全体からcで割れるものを引くそして、dで割れるものを引く c,dどちらでも割れるものをたす
        cnt = x
        cnt -= x // c
        cnt -= x // d
        # cでもdでも割れるものがいくつあるか
        cnt += x // lcd(c, d)
        return cnt
    # a以上b以下でどうこうっていう時の数え上げは
    # b以下で数えて「a-1以下」で数えたのを引く
    ans = anti_div(b, c, d) - anti_div(a-1, c, d)
    print(ans)

if __name__ == '__main__':
    main()

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

#define mod 1000000007
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323
#define debug(x) cout<<"Case "<<x<<": "
#define For(i,n) for(long long i=0;i<n;i++)
#define Frabs(i,a,b) for(long long i = a; i < b; i++)
#define Frabr(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	ll n,w;
	cin>>n>>w;
	ll Value[n+5]={0},Weight[n+5]={0};
	ll sum=0;
	for(ll i=1;i<=n;i++)
		cin>>Weight[i]>>Value[i],sum+=Value[i];
	ll dp[n+5][sum+5];
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=sum;j++)
			dp[i][j]=INT_MAX;
	}
	for(ll i=0;i<=n;i++)
		dp[i][0]=0;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=sum;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(Value[i]<=j)
				dp[i][j]=min(dp[i][j],dp[i-1][j-Value[i]]+Weight[i]);
		}
	}
	for(ll j=sum;j>=0;j--)
	{
		if(dp[n][j]<=w)
		{
			cout<<j<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 80256