akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

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

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      n: usize,
      s: chars,
    }
    let white_all: usize = s.iter().map(|&v| if v == '.' { 1 } else {0}).sum();

    let mut ans = white_all;
    let mut white = 0;
    let mut black = 0;
    for i in 0..n {
        if s[i] == '#' {
            black += 1;
        } else {
            white += 1;
        }
        let cur = black + (white_all - white);
        ans = min(ans, cur);
    }
    ans = min(ans, black);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    ll flag = -1 ;
    ll p1 = 0 , p2 = 2 ;
    string s ;
    cin >>s ;
    ll n = s.len ;
    if(n == 1) {
        cout << -1 << " " << -1 << el ;
        ro ;
    }
    if(n == 2){
        if(s[0] == s[1] ){
            cout << 1 << " " << 2 << el;
        }
        else {
            cout << -1 << " " << -1 << el ;
        }
        ro ;
    }
    ll from = -1 , to = -1 ;
    while(p2 < n){
        string foo = "";
        foo = foo + s[p1] + s[p1+1] + s[p2];
        sort(all(foo));
       /// cout << "foo is " << foo << el ;
        if(foo[0] == foo[1] or foo[1] == foo[2]){
            from = p1 ;
            to = p2 ;
            flag = 0 ;
            br ;
        }
        else {
            ++p1 ;
            ++p2 ;
        }
    }
    if(flag == -1) {
        cout << -1 << " " << -1 << el;
        ro ;
    }
    else {
        cout << from +1 << " " << to +1 << el ;
        ro ;
    }
    ro ;
}































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

const int INF = 100000;
int N, A, B, C;
vector<int> mem;

int solve()
{
	int bit[3];
	int total = 1 << N;
	int Min = INF;

	for(bit[0] = 1; bit[0] < total; bit[0]++)
		for(bit[1] = 1; bit[1] < total; bit[1]++)
		{
			if(bit[0] & bit[1]) continue;
			for(bit[2] = 1; bit[2] < total; bit[2]++)
			{
				if(bit[0] & bit[2] || bit[1] & bit[2]) continue;
				int cnt = 0;
				int a = 0, b = 0, c = 0;

				for(int num = 0; num < N; num++)
				{	
					if(bit[0] & (1<<num)) { a += mem[num]; cnt += 10; }
					else if(bit[1] & (1<<num)) { b += mem[num]; cnt += 10; }
					else if(bit[2] & (1<<num)) { c += mem[num]; cnt += 10; }
				}
				int res = abs(a-A) + abs(b-B) + abs(c-C) + cnt - 30;
				if(res >= 0) Min = min(res, Min);
			}
		}
	return Min;
}

int main()
{
	cin >> N >> A >> B >> C; 
	for(int i = 0; i < N; i++) { int v; cin >> v; mem.push_back(v); }
	printf("%d\n", solve());
}

Measured memory_bytes: 256
from itertools import accumulate
from collections import defaultdict
import bisect

n,k = map(int, input().split())
a = list(map(int, input().split()))
a = [0] + list(accumulate([(i-1) % k for i in a]))
a = [i % k for i in a]
ans = 0
maps = defaultdict(list)
for k1,v in enumerate(a):
  maps[v].append(k1)
for i in range(n):
  v = a[i]
  ans += bisect.bisect_right(maps[v],i+k-1) - bisect.bisect_right(maps[v],i)
print(ans)


Measured memory_bytes: 54596
n = int(input())
a = list(map(int , input().split()))

a.sort()

#print(a)
import numpy as np
U=10**6 + 5
is_prime = np.zeros(U,np.bool)
#is_prime[2] = 1
is_prime[1::] = 1
M = int(U**.5)+1
for ai in a:#range(3,M,2):
    if is_prime[ai]:
        is_prime[ai*2::ai] = 0
    #print(is_prime.nonzero()[0])

ans = 0

import collections
cnt = collections.Counter(a)
for ai in a:
    if is_prime[ai] and cnt[ai] == 1:
        ans += 1

print(ans)

"""
sa = set()
for ai in a:
    if ai in sa:
        sa.discard(ai)
        continue
    sa.add(ai)
"""

"""
p = list(range(10**6+10))

a = list(sa)
a.sort()

print(a)

import fractions
def lcm(a, b):
    return a * b // fractions.gcd(a, b)

ans = 1
l = 1
for i in range(n):
    if lcm(a[i], l) < a[i] * l:
        continue
    l = lcm(a[i], l)
    ans += 1
print(ans)

"""


Measured memory_bytes: 53104
n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]
case, ans = [], 10**10

for i in range(4**n):
    A, B, C = 0, 0, 0
    tmp_ans, tmp = 0, i
    cnt = 0
    for j in range(n):
        digit = tmp//4**(n-j-1)
        if digit == 1:
            A += l[j]
            cnt += 1
        if digit == 2:
            B += l[j]
            cnt += 1
        if digit == 3:
            C += l[j]
            cnt += 1
        tmp %= 4**(n-j-1)
    if A != 0 and B != 0 and C != 0:
        tmp_ans += abs(A-a)+abs(B-b)+abs(C-c)
        tmp_ans += max(0, (cnt-3)*10)
        ans = min(ans, tmp_ans)

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){

    int a,b,c;
    
    scanf("%d %d %d", &a,&b,&c);

    if(a <=b && b <= c)
      printf("%d %d %d\n", a, b, c);
    else if(a <= c && c <= b)
      printf("%d %d %d\n", a,c, b);
    else if(b <= a && a <= c)
      printf("%d %d %d\n", b, a, c);
    else if(b <= c && c <= a)
      printf("%d %d %d\n", b, c, a);
    else if(c <= a && a <= b)
      printf("%d %d %d\n", c ,a, b);
    else if(c <= b && b <= a)
      printf("%d %d %d\n", c ,b, a);


    return 0;
}

Measured memory_bytes: 596
#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	intsize ll size = trunc(log10(num)) + 1
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds; 
using 		namespace std;

ll gcd (ll a, ll b) { return b ? gcd (b, a % b) : a; }
ll lcm (ll a, ll b) { return a / gcd(a, b) * b; }

//code start from here 

int main() {
	fast;
	read(a)
	read(b)
	set<ll>st;
	loop(j,0,b){
		read(t)
		while(t--){
			read(y)
			st.insert(y);
		}
	}
	ll p=st.size();
	cout<<abs(a-p)<<endl;
	return 0;
}

//ends here 

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define fr(i,n) for(int i=0;i<n;i++)
long double dp[3000][3000];
int main()
{ 
          int n;
          cin>>n;
         long  double p[n+1];
          for(int i=1;i<=n;i++)
          {
                    cin>>p[i];
          }
          dp[0][0]=1.0;    // here dp[i][j] denoting the probability obtained by j head
          for(int i=1;i<=n;i++)
          {
                    for(int j=0;j<=n;j++)
                    {
                              if(j==0)
                              {
                                        dp[i][j]=dp[i-1][j]*(1.0-p[i]);
                              }
                              else
                              {
                                        dp[i][j]=(dp[i-1][j]*(1.0-p[i])+dp[i-1][j-1]*p[i]);
                              }
                    }
                    
          }
         
                    long double sum=0.0;
                    for(int j=(n/2)+1;j<=n;j++)
                    {
                              sum+=dp[n][j];
                    }
          cout<<setprecision(11)<<sum<<"\n";
}




Measured memory_bytes: 140928
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();

        if (A + B >= K) {
            out.println(Math.min(A, K));
        } else {
            out.println(A - (K - A - B));
        }
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}

Measured memory_bytes: 32660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s; cin >>s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
    cout<<"Bad"<<endl;
  }else{
    cout<<"Good"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    string s;
    cin >> s;
    int x = (s[0] - '0')*10 + (s[1] - '0');
    int y = (s[2] - '0')*10 + (s[3] - '0');
    if(x <13 && y < 13){
        if(x == 0 && y == 0){
            cout << "NA" << endl;
        }else if(x == 0){
            cout << "YYMM" << endl;
        }else if(y == 0){
            cout << "MMYY" << endl;
        }else{
            cout << "AMBIGUOUS" << endl;
        }
    }else if(x < 13 && x != 0){
        cout << "MMYY" << endl;
    }else if(y < 13 && y != 0){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }
    return 0;
}


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

using namespace std;

#define PI acos(-1.0)

int main(){
  int n; cin >> n;
  vector<pair<int, int> > xy(n);
  for (int i = 0; i < n; ++i) cin >> xy[i].first >> xy[i].second;
  sort(xy.begin(), xy.end());
  double alpha = 0, ans = 1e18;
  do {
    alpha = atan2(xy[0].second, xy[0].first);
    if (alpha < 0) alpha += 2 * PI;
    double tmp = min(alpha, 2 * PI - alpha);
    for (int i = 1; i < n; ++i) {
      double t = atan2(xy[i].second - xy[i - 1].second, xy[i].first - xy[i - 1].first);
      if (t < 0) t += 2 * PI;
      tmp += min(abs(alpha - t),2 * PI- abs(alpha - t));
      alpha = t;
    }
    double t = atan2(-xy[n - 1].second, -xy[n - 1].first);
    if (t < 0) t += 2 * PI;
    tmp += min(abs(alpha - t), 2 * PI - abs(alpha - t));
    ans = min(ans, tmp);
  } while (next_permutation(xy.begin(), xy.end()));
  printf("%.10f\n", ans * 180.0 / PI);
  
  return 0;
}


Measured memory_bytes: 3376
#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;

int main() {
  ll a, b;
  cin >> a >> b;
  
  set<int> prime;
  int ca, cb;
  ca = cb = 0;
  for (ll i = 2; i*i <= a; ++i) {
    if (a % i == 0) {
      ++ca;
      prime.insert(i);
      while (a % i == 0) a /= i;
    }
  }
  if (a > 1) {
    ++ca;
    prime.insert(a);
  }

  for (ll i = 2; i*i <= b; ++i) {
    if (b % i == 0) {
      ++cb;
      prime.insert(i);
      while (b % i == 0) b /= i;
    }
  }
  if (b > 1) {
    ++cb;
    prime.insert(b);
  }
	
  cout << ca+cb-prime.size()+1 << endl;
  return 0;
}

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

#define ff first
#define ss second
#define pb push_back


void solve() {
	ll n, x, t; cin>>n>>x>>t;
	ll div = (n/x) + (n%x != 0);
	ll ans = div * t;
	cout<<ans<<endl;
}

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

    int t = 1, no = 0;
    // cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>
#define NIL -1
 
int D[10000],H[10000];
 
struct Node{
  int parent,left,right;
    };
  struct Node T[10000];
void print(int);
int dep;
 
int main(){
  int i,p,r,l,root=0,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d", &p, &l, &r);
    T[l].parent = p;
    T[r].parent = p;
    T[p].left = l;
    T[p].right = r;
    
  }
  for(i=0;i<n;i++){
    print(i);
  }
  return 0;
}
 
   
int setDepth(int u){
   
    if(T[u].parent == NIL)return 0;
    if(T[u].parent!=NIL){
      dep++;
      setDepth(T[u].parent);
  }
    return dep;
}
 
int setHeight(int u){
  int h1 = 0,h2 = 0;
  if(T[u].left!=NIL){
    h1 = setHeight(T[u].left)+1;
  }
  if(T[u].right!=NIL){
    h2 = setHeight(T[u].right)+1;
  }
  if(h1 > h2) return h1;
  else return h2;
}
 
   
int Sibling(int u){
  if(T[u].parent == NIL) return NIL;
  else if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL){
    return T[T[u].parent].left;
  }
  else if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) {
    return T[T[u].parent].right;
  }
  return NIL;
}
 
void print(int u){
  int deg = 0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent); 
  printf("sibling = %d, ",Sibling(u));
  if(T[u].right!=NIL) deg++;
  if(T[u].left!=NIL) deg++;
  printf("degree = %d, ",deg);
  dep = 0;
  printf("depth = %d, ",setDepth(u));
  printf("height = %d, ",setHeight(u));
  if(T[u].parent == NIL) printf("root\n");
  else if(T[u].left==NIL && T[u].right==NIL) printf("leaf\n");
  else printf("internal node\n");
}

Measured memory_bytes: 620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <math.h>

using namespace std;

int CalcWay(int num, int sel)
{
  if (num == 1) return 0;

  int ans = 1;
  for (int i = 1; i <= sel; ++i)
  {
    ans = ans * (num - (i - 1)) / i;
  }
  return ans;
}

//void A_159()
int main()
{
  int N, M;
  cin >> N >> M;

  int n1 = CalcWay(N, 2);
  int n2 = CalcWay(M, 2);

  cout << n1 + n2 << endl;
}

Measured memory_bytes: 256
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
//#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	ll memo = mypow(a, b >> 1);
	return memo * memo;
}
int k, n, a[200010];
signed main() {
	cin >> k >> n;
	rep(i, n)cin >> a[i];
	int ans = k;
	REP(i, n - 1)chmin(ans, k - (a[i] - a[i - 1]));
	chmin(ans, k - (k + a[0] - a[n - 1]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bool g[4];
char s[2010];
int main(){
	scanf("%s",s);
	for(int i=0;s[i];i++){
		if(s[i]=='N') g[0]=true;
		else if(s[i]=='S') g[1]=true;
		else if(s[i]=='W') g[2]=true;
		else if(s[i]=='E') g[3]=true;
	}
	if(g[0]==g[1]&&g[2]==g[3]) puts("Yes");
	else puts("No");
	return 0;
}

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

using namespace std;

typedef long long ll;

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

	vector<int> v(5);
	rep(i, 5) cin >> v[i];


	int ans = 10000;
	do{
		int t = v[0];
		rep(i, 4){
			t += (v[i] % 10 == 0 ? 0 : 10 - v[i] % 10);
			t += v[i+1];
		}

		ans = min(ans, t);
	}while(next_permutation(v.begin(), v.end()));

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int H,W;
const int MAX = 500;
const int INF = (1<<20);
int data[MAX][MAX];

int solve(){
  int ans = 0;
  for(int j = 0; j < W; j++)
    for(int i = 0; i < H; i++){
      int able = INF;
      for(int k = i; k < H; k++){
	able = min(able,data[k][j]);
	ans = max(ans,(k-i+1)*able);
      }
    }
  return ans;
}

int main(){
  char c;
  while(cin >> H >> W && H+W){
    for(int i = 0; i < H; i++){
      int now = 0;
      for(int j = 0; j < W; j++){
	cin >> c;
	if(c == '*') data[i][j] = now = 0;
	else data[i][j] = ++now;
      }
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1844
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <limits>
using namespace std;
 
#define int int64_t
#define pr(x) cout << x << endl;
#define vi vector<int>
#define vii vector< vector<int> >
#define mp make_pair
#define f(i,n) for(i =0 ; i< n ; i++)
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define INF 1e9
#define SIZE 200001
#define mod 1000000007
#define int_max 1e12
int dr[]={0,0,1,1,1,-1,-1,-1};
int dc[]={1,-1,0,1,-1,0,1,-1};
 
void solve();
 
int power(int a, int b)
{
    if(b==0) return 1;
    else if(b&1) return a*power(a*a,b/2);
    else return power(a*a, b/2);
}
 
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}  
 
int i, j, k, l, n, m, x, y, t;
void solve()
{ 
    // cin >> t; while(t--)
    {
        k=1;
        cin >> x >> y;
        if(y==1) {cout << 0;exit(0);}
        y-=x;
        if(y>0)
        {
            if(y%(x-1)) k += (y/(x-1))+1;
            else k += y/(x-1);
        }

        cout << k;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =998244353;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    

//解説AC
  int main(){
   lint n;
   cin>>n;
   lint a[n];
   lint b[n];
   rep(i,n){
       cin>>a[i]>>b[i];
   }
   sort(a,a+n);
   sort(b,b+n);
   lint ans;
   if(n%2==0){
       ans=b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1]+1;
   }else{
        ans=b[n/2]-a[n/2]+1;
   }
   cout<<ans<<endl;
  }
 
  
      
      
    
 
  
          
  

Measured memory_bytes: 6708
import sys
import fractions
sys.setrecursionlimit(200000000)

N = int(input())
NUMS = [int(input()) for _ in range(N)]
NUMS = list(set(NUMS))

def gcd(num1, num2):
    if num2 == 0:
        return num1
    else:
        return gcd(num2, num1 % num2)


res = NUMS[0]
for num in NUMS[1:]:
    res = res * num // gcd(res, num)

print(int(res))

Measured memory_bytes: 5048
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
    ll n,a,b;cin>>n>>a>>b;
    ll chk=a+b;
    ll res=n/chk;
    res*=a;
    res+=min(a,((n%(a+b))));
    cout<<(res);
}

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

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

long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

// int64_t gcd(int64_t a, int64_t b) {
//   if (a == 0 || b == 0) return a + b;
//   return (a < b ? gcd(a, b - a) : gcd(b, a - b));
// }
// 
// int64_t lcm(int64_t a, int64_t b) {
//   return a / gcd(a, b) * b;
// }

int main() {
  int64_t a, b;
  while (cin >> a >> b) {
    cout << gcd(a, b) << " " << lcm(a, b) << endl;
  }
}

Measured memory_bytes: 3048
#include<iostream>
using namespace std;
int main(){
int x,y,z=0,a;
cin >>x >>y;
for(int i=0;i<x;i++)cin>>a;
x-=y;
z++;
//if(x%(y-1)!=0){z++;x-=x%(y-1);}
z+=(x+y-2)/(y-1);
cout << z << endl;
return 0;
}


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

using namespace std;
typedef long long ll;

ll dp[100010];

int main() {
	ll n,w;
	cin >> n >> w;
	
	fill(dp, dp+100010, numeric_limits<int>::max());
	dp[0] = 0;
	int sum = 0;
	
	for(int i = 0; i < n; i++) {
		int wgt, val;
		cin >> wgt >> val;
		
		sum += val;
		for(int j = sum; j >= val; j--) {
			dp[j] = min(dp[j], dp[j-val] + wgt);
		}
	}
	
	while(dp[sum] > w) sum--;
	cout << sum;


	return 0;
}

Measured memory_bytes: 1024
S = input()

N = len(S)

a = int((N-1)/2)-1
b = int((N+3)/2)-1

s1 = S[:a+1]
s2 = S[b:]

if S==S[::-1] and s1==s1[::-1] and s2==s2[::-1]:
    print('Yes')

else:
    print('No')

Measured memory_bytes: 3060
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

inline void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0, p; char f[7];
	while (x) {
		p = x; x /= 10;
		f[s++] = p - (x << 1) - (x << 3);
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], h3[100003], h4[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int Q1[110000], Q1L, Q1R;
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	Q1[0] = 1; Q1R = 1;
	while (Q1R > Q1L) {
		int a1 = Q1[Q1L]; Q1L++;
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1[Q1R] = i; Q1R++;
			}
		}
	}
	int rn = 0;
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) { h3[dist[i]]++; rn = max(rn, dist[i]); }
	for (int i = 0; i <= rn; i++) D[i].resize(h3[i]);
	for (int i = 1; i <= n; i++) D[dist[i]][h4[dist[i]]] = i, h4[dist[i]]++;
	e[1] = (1 << 30);
	for (int i = 1; i <= rn; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 24964
#include<cstdio>
#include<iostream>
#include<algorithm> 
using namespace std;
int a[100003];

int main()
{
    int N;
    cin >> N;
    while (N--)
    {
        int t;
        cin >> t;
        a[t]++;
        a[t + 1]++;
        a[t + 2]++;
    }
    cout << *max_element(a + 2, a + 100000) << endl;
}

Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
 
using namespace std;

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

    int s;

    cin >> s;

    int s1 = (s - s % 100) / 100;
    int s2 = s % 100;

    if(s1 <= 12 && s1 > 0)
    {
        if(s2 <= 12 && s2 > 0)
        {
            cout << "AMBIGUOUS";
        } else {
            cout << "MMYY";
        }
    } else if(s2 <= 12 && s2 > 0)
    {
        cout << "YYMM";
    } else {
        cout << "NA";
    }
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int cnt[100010] = { 0 };
int main()
{
	int N, M;
	cin >> N >> M;
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		cnt[a - 1]++;
		cnt[b - 1]++;
	}
	for (int i = 0; i < N; i++) {
		if (cnt[i] % 2 == 1) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

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

int main()
{
	ll N, K;
	cin >> N >> K;
	if (K == 0) {
		cout << N * N << endl;
		return 0;
	}
	ll res = 0;
	for (int i = K + 1; i <= N; i++) {
		res += (N / i * (i - K)) + max(0ll, N % i - K + 1);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
N,x = map(int,input().split())
a=list(map(int,input().split()))
cnt=0
b=[0]*N

#0,2
b[0]=a[0] if a[0]<=x else x
cnt+= a[0]-b[0]

for i in range(1,N):
  b[i] = a[i] if b[i-1]+a[i]<=x else max(0,x-b[i-1])
  cnt += a[i]-b[i]
  
#print(b)
print(cnt)

Measured memory_bytes: 14252
#include <iostream>
int main(){
    int n,i;
    std::cin >> n;
    int a[n];
    for(i=0;i<n;i++){
        std::cin >> a[i];
    }
    for(i=0;i<n;i++){
        if(i > 0) std::cout << " ";
        std::cout << a[n-1-i];
    }
    std::cout << std::endl;
    return 0;
}


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

int main() {
	int k, x; cin >> k >> x;

	int l, r;
	l = (x - (k - 1));
	if (l < -1000000) l = -1000000;
	r = (x + (k - 1));
	if (r > +1000000) r = +1000000;

	for (int i = l; i <= r; i++) {
		cout << i;
		if (!((i + 1) <= r)) break;
		cout << " ";
	}
	cout << endl;
}


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

using namespace std;

long long c[10]={1,11,112,1124,11248,112496,1124992,11249984,112499968,1124999936},a;
string s;

int main(){
  cin>>s;
  for(int i=0;i<s.size();i++){
    a+=(c[s.size()-i-1])*(s[i]-'0')*(1<<i);
  }
  cout<<a<<endl;
}


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

int main() {
    int64_t A;
    cin >> A;

    int p = 0;

    int a = A / 500;
    int B = A % 500;
    int b = B / 5;

    int X = a * 1000 + b * 5;

    cout << X << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int E,Y,a;
    cin >> E >> Y;
    
    if(E == 0){
        if(1868 <= Y && Y <= 1911){
            cout << "M" << Y - 1868 + 1;
        }
        else if(1912 <= Y && Y <= 1925){
            cout << "T" << Y - 1912 + 1;
        }
        else if(1926 <= Y && Y <= 1988){
            cout << "S" << Y - 1926 + 1;
        }
        else{
            cout << "H" << Y - 1989 + 1;
        }
    }
    else if(E == 1){
        cout << 1868 + Y - 1;
    }
    else if(E == 2){
        cout << 1912 + Y - 1;
    }
    else if(E == 3){
        cout << 1926 + Y - 1;
    }
    else{
        cout << 1989 + Y - 1;
    }
    cout << endl;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

const int INF = 1e9;

int main() {
	int n;
	char m;
	int x;
	bool u[4][13];
	rep(i,0,4) rep(j,0,13) u[i][j] = false;

	cin >> n;

	rep(i,0,n) {
			cin >> m;
			cin >> x;
			if (m == 'S') {
				u[0][x - 1] = true;
			} else if (m == 'H') {
				u[1][x - 1] = true;
			} else if (m == 'C') {
				u[2][x - 1] = true;
			} else {
				u[3][x - 1] = true;
			}
	}
	rep(i,0,13) {
			if (!u[0][i]) {
					cout << "S " << i + 1 << endl;
			}
	}
	rep(i,0,13) {
			if (!u[1][i]) {
					cout << "H " << i + 1 << endl;
			}
	}
	rep(i,0,13) {
			if (!u[2][i]) {
					cout << "C " << i + 1 << endl;
			}
	}
	rep(i,0,13) {
			if (!u[3][i]) {
					cout << "D " << i + 1 << endl;
			}
	}

}

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

int main() {
  int A[3] = {0, 0, 0};
  int ans = 0;
  cin >> A[0] >> A[1] >> A[2];

  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      if (A[j] > A[j+1]) {
        int tmp = A[j];
        A[j] = A[j+1];
        A[j+1] = tmp;
      }
    }
  }

  for (int i = 0; i < 2; i++) {
    ans += A[i+1] - A[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [input() for _ in range(M)]
for i in range(M):
    for j in range(N-M+1):
        str_n = ''.join(A[i][j:j+M])
        if str_n == B[i]:
            break
    else:
        print("No")
        exit()
else:
    print("Yes")

Measured memory_bytes: 3060
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int v[] = new int[n];
		int dec = 0;
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
			if (v[i] != 0 && v[i] != v[0]) {
				dec = 1;
			}
		}
		if (dec == 0) {
			System.out.println(n / 2);
			sc.close();
			return;
		}

		Map<Integer, Integer> mp1 = new HashMap<>();
		Map<Integer, Integer> mp2 = new HashMap<>();

		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				if (mp1.containsKey(v[i])) {
					mp1.put(v[i], mp1.get(v[i]) + 1);
				} else {
					mp1.put(v[i], 1);
				}
			} else {
				if (mp2.containsKey(v[i])) {
					mp2.put(v[i], mp2.get(v[i]) + 1);
				} else {
					mp2.put(v[i], 1);
				}
			}
		}

		int max1 = 0, max2 = 0, maxx1 = 0, maxx2 = 0;
		int num1 = 0, num2 = 0;
		for (Map.Entry<Integer, Integer> entry : mp1.entrySet()) {
			if (max1 < entry.getValue()) {
				max1 = entry.getValue();
				num1 = entry.getKey();
			}
		}
		for (Map.Entry<Integer, Integer> entry : mp2.entrySet()) {
			if (max2 < entry.getValue()) {
				max2 = entry.getValue();
				num2 = entry.getKey();
			}
		}
		for (Map.Entry<Integer, Integer> entry : mp1.entrySet()) {
			if (num1 != entry.getKey())
				maxx1 = Math.max(maxx1, entry.getValue());
		}
		for (Map.Entry<Integer, Integer> entry : mp2.entrySet()) {
			if (num2 != entry.getKey())
				maxx2 = Math.max(maxx2, entry.getValue());
		}
		sc.close();
		if (num1 == num2) {
			int a = Math.max(max1 + maxx2, maxx1 + max2);
			System.out.println(n - a);
		} else {
			System.out.println(n - max1 - max2);
		}
	}
}


Measured memory_bytes: 54820
#include <cstdio> 
int x,y;
const int a[13]={0,1,2,1,3,1,3,1,1,3,1,3,1};
int main(){
	scanf("%d%d",&x,&y);
	if(a[x]!=a[y])puts("No");
		else puts("Yes");
	return 0;
}

Measured memory_bytes: 128
def im(a):
    imos = [0] * (3*N+1)
    for i in range(N):
        imos[N+i-min(N,a[i])] += 1
        imos[N+i+min(N,a[i])+1] -= 1
    cs = [0]
    for i in range(1,2*N+1):
        cs.append(cs[i-1]+imos[i-1])
    return cs[N+1:]

N,K,*A = map(int, open(0).read().split())
for i in range(K):
    A = im(A)
    if A.count(N) == N:
        break
print(*A)

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    int h[100001][3] = {};
    for (int i = 0; i < N; i++) {
        int a[3];
        cin >> a[0] >> a[1] >> a[2];
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                h[i+1][k] = max(h[i+1][k], h[i][j]+a[k]);
            }
        }
    }
    cout << max(max(h[N][0], h[N][1]), h[N][2]) << endl;

    return 0;
}



Measured memory_bytes: 1408
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
    int a[4],b[4],i;
	for(i=0;i<4;i++){
	    scanf("%d",&a[i]);
		b[i]=0;
	}
	sort(a,a+4);
	for(i=0;i<3;i++){
	    if(b[i]==0&&b[i+1]==0&&a[i]==a[i+1]){
		    b[i]=1;b[i+1]=1;
		}
	}
	if(a[0]==a[3]){
	    printf("no\n");
	}
	else if(b[0]==1&&b[3]==1){
	    printf("yes\n");
	}
	else printf("no\n");
	return 0;
}

Measured memory_bytes: 2660
#ABC 116 C - Grand Garden

n = int(input())
h = list(map(int, input().split()))

#リストの最大値Mを求める
#リストを左から走査
 #MだったらフラグOn、その数を-1。Mより下回ったらフラグoff
 #までいったらMを

cnt = 0
while max(h) > 0:
    M = max(h)
    for i in range(n):
        if i == 0:
            flag = False
        
        if h[i] == M and flag == False:
            cnt += 1
            h[i] -= 1
            flag = True
        
        elif h[i] == M and flag == True:
            h[i] -= 1
            
        else:
            flag = False
        
print(cnt)

Measured memory_bytes: 73784
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  int ans = 0;
  rep(i,6){
    if(s[i]=='1') ans++;
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main()
{
	long int A,B,C,K;

	scanf("%ld %ld %ld %ld",&A,&B,&C,&K);

	if(K-A<=0)
	{
		printf("%ld\n",K);
		return 0;
	}
	else if(K-A-B<=0)
	{
		printf("%ld\n",A);
		return 0;
	}
	else
	{
		printf("%ld\n",A-(K-A-B));
		return 0;
	}
	
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int intN = sc.nextInt();
		int intM = sc.nextInt();

		int[][] arrayA = new int[intN][intM];
		int[] arrayB = new int[intM];
		int[] arrayAns = new int[intN];

		for(int i = 0; i < intN; i++) {
			for(int j = 0; j < intM; j++) {
				arrayA[i][j] = sc.nextInt();
			}
		}

		for(int i = 0; i < intM; i++) {
			arrayB[i] = sc.nextInt();
		}


		int x = 0;
		int y = 0;
		for(int i = 0; i < intN; i++) {
			for(int j = 0; j < intM; j++) {
				y = arrayA[i][j] * arrayB[j];
				x = x + y;
			}

			arrayAns[i] = x;
			System.out.println(arrayAns[i]);
			y = 0;
			x = 0;
		}
/*

		for(int i = 0; i < intN; i++) {
			for(int j = 0; j < intM; j++) {
				System.out.print("arrayA["+i+"]["+j+"] = "+arrayA[i][j]+" ");
			}
			System.out.println("");
		}

		for(int i = 0; i < intM; i++) {
			System.out.println("arrayB["+i+"] = "+arrayB[i]);
		}
*/
	}
}

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


int main() {
	ll N, K;
	cin >> N >> K;
	priority_queue<ll> H;
	rep(i, N) {
		ll h = 0;
		cin >> h;
		H.push(h);
	}
	rep(i, K) {
		if (!H.empty())  H.pop();
	}
	ll ans = 0;
	while (!H.empty()) {
		ans += H.top();
		H.pop();
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 2420
from itertools import combinations
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(20000000)

n, m, q = map(int, input().split())
abcd = []
for i in range(q):
    a, b, c, d = map(int, input().split())
    abcd.append([a-1, b-1, c, d])

# def check(Q):
#     A = [1] + [-1 for _ in range(n-1)]
#     score = 0
#     for a, b, c, d in Q:
#         if A[a] == -1 and A[b] == -1:
#             tmp_b = min(A[b:])
#             if tmp_b == -1 or tmp_b >= max(A[:a]) + c:
#                 A[a] = max(A[:a])
#                 A[b] = A[a] + c
#                 score += d
#         elif A[a] == -1 and A[b] != -1:
#             if max(A[:a]) <= A[b] - c <= max(A[:a]):
#                 A[a] = A[b] - c
#                 score += d
#         elif A[a] != -1 and A[b] == -1:
#             if min(A[:b]) <= A[a] + c <= max(A[b:]):
#                 A[b] = A[a] + c
#                 score += d
#         else:
#             if A[b] - A[a] == c:
#                 score += d
#         print(A)
#     return score

def dfs(A, depth, max_a):
    if depth == n:
        score = 0
        for a, b, c, d in abcd:
            if A[b] - A[a] == c:
                score += d
        return score
    ans = 0
    for i in range(max_a, m+1):
        ans = max(ans, dfs(A + [i], depth+1, i))
    return ans

ans = dfs([1], 1, 1)
print(ans)



Measured memory_bytes: 9232
N = gets.to_i
a = gets.split.map(&:to_i)

map = Hash.new(0)

a.each do |a|
  map[a] += 1
end

count = 0
map.keys.each do |k|
  n = k.to_i
  if n == map[k]
    next
  end

  if n < map[k]
    count += map[k] - n
  else
    count += map[k]
  end
end

p count

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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k-1] = tolower(s[k-1]);
  rep(i, n) cout <<s[i];
  cout << endl;
}

Measured memory_bytes: 3504
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  long long a,b;
  cin >> a >> b;
  
  if(a<b){
    for(int i=0;i<b;i++){
    cout << a;
    }
  }
   else{
     for(int i=0;i<a;i++){
       cout << b;
     }
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<" "<<b<<" "<<c;
	return 0;
}

Measured memory_bytes: 3604
/**
 *    author:  FromDihPout
 *    created: 2020-08-11
**/

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

#define all(x) (x).begin(), (x).end()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    
    int cnt = 1, ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] == a[i-1]) {
            cnt++;
        }
        else if (cnt != a[i-1]) {
            ans += cnt >= a[i-1] ? cnt - a[i-1] : cnt;
            cnt = 1;
        }
        else {
            cnt = 1;
        }
    }
    
    if (cnt != a[n-1]) {
        ans += cnt >= a[n-1] ? cnt - a[n-1] : cnt;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);
        int length = sc.next().length();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < length; i++) {
            builder.append("x");
        }

        System.out.println(builder);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define MOD 1000000007
typedef long long ll;
using namespace std;
int main()
{
	ll N, A, sum = 0, num = 1; cin >> N;  	
  	for (int i = 0; i < N; i++) {
    	cin >> A;
      	if (A == num) {
        	num++;
        } else {
        	sum++;
        }
    }
  	if (sum == N) sum = -1;
  	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    int X,Y;cin>>X>>Y;
    int ans=0;
    if(X==3)ans+=100000;
    else if(X==2)ans+=200000;
    else if(X==1)ans+=300000;
    if(Y==3)ans+=100000;
    else if(Y==2)ans+=200000;
    else if(Y==1)ans+=300000;
    if(X==1 and Y==1)ans+=400000;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
using namespace std;
bool find(int a[],int n,int num){
	int i;
	for(i=0;i<n;i++){
		if(a[i]==num){
			//printf("%d\n",i);
			return true;
		}
	}
	return false;
}
int main(int argc, char *argv[]) {
	int s[10001],t[501],n,q,i,sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&s[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&t[i]);
	}
	for(i=0;i<q;i++){
		if(find(s,n,t[i]))
			sum++;
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 3264
from sys import exit
n = int(input())
a = list(map(int, input().split()))

back = [0 for _ in range(n+1)]
back[n] = a[n]
for i in range(n-1, -1, -1):
	back[i] = back[i+1] + a[i]

ans = 0
v = 1
for i in range(n+1):
	if v < a[i]:
		print(-1)
		exit()
	ans += v
	p = v - a[i]
	if i < n:
		if p > back[i+1]:
			print(-1)
			exit()
		elif p*2 > back[i+1]:
			v = back[i+1]
		else:
			v = 2*p
	else:
		if v != a[i]:
			print(-1)
			exit()
print(ans)

Measured memory_bytes: 85136
using System;
class yoku
{
    public static string toku(double a)
    {
        string c;
        if (a <= 48.00)
            c ="light fly";
        else if (a <= 51.00)
            c ="fly";
        else if (a <= 54.00)
            c ="bantam";
        else if (a <= 57.00)
            c ="feather";
        else if (a <= 60.00)
            c ="light";
        else if (a <= 64.00)
            c ="light welter";
        else if (a <= 69.00)
			c="welter";
        else if (a <= 75.00)
			c="light middle";
        else if (a <= 81.00)
			c="middle";
        else if (a <= 91.00)
			c="light heavy";
        else if (a > 91.00)
			c="heavy";
		else
			c="ghgj";
        return c;
    }
}
class aoj
{
    static void Main()
    {
		string []g=new string[50];
        int i=0;
        while (true)
        {
            string a = Console.ReadLine();
            if (String.IsNullOrEmpty(a)) break;
            double b = double.Parse(a);
            yoku yoku = new yoku();
            string c=yoku.toku(b);
			g[i]=c;
			i++;
        }
        for(int j=0;j<i;j++)
			Console.WriteLine(g[j]);     
        
    }
}

Measured memory_bytes: 9128