akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

ll n;

ll proc(vector<string>& mp, ll cy, ll cx) {
  ll ans = 0;
  ll st = 0;
  while (cx <= n - 1 && cy <= n - 1) {
    bool ok = true;
    if (st == 0) {
      repLRE(i, 1, n - 1) {
        rep(j, i) {
          if (mp[cy + j][cx + i] != mp[cy + i][cx + j]) {
            ok = false;
            cx = cx + i + 1, cy = cy + i + 1;
            st = 0;
            break;
          }
        }
        if (!ok) break;
      }
      if (ok) {
        st = 1, ans++, cx++, cy++;
      }
    } else {
      rep(j, n - 1) {
        if (mp[cy + j][cx + n - 1] != mp[cy + n - 1][cx + j]) {
          ok = false;
          cx = cx + n, cy = cy + n;
          st = 0;
          break;
        }
      }
      if (ok) {
        st = 1, ans++, cx++, cy++;
      }
    }
  }
  return ans;
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  cin >> n;

  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }

  vector<string> mp(2 * n);
  rep(i, n) {
    cin >> mp[i];
    mp[i] += mp[i];
    mp[n + i] = mp[i];
  }

  ll ans = 0;
  repLRE(i, 0, n - 1) {
    ll cy = 0, cx = i;
    ans += proc(mp, cy, cx);
  }

  repLRE(i, 1, n - 1) {
    ll cy = i, cx = 0;
    ans += proc(mp, cy, cx);
  }

  cout << ans << endl;
}


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

int main () {
  int a, ans;
  cin >> a;
  a = a/100;
  
  if (a==4 || a==5) ans = 8;
  if (a==6 || a==7) ans = 7;
  if (a==8 || a==9) ans = 6;
  if (a==10 || a==11) ans = 5;
  if (a==12 || a==13) ans = 4;
  if (a==14 || a==15) ans = 3;
  if (a==16 || a==17) ans = 2;
  if (a==18 || a==19) ans = 1;
  cout << ans << endl;
}

Measured memory_bytes: 3588
def main():
    #import sys
    #input = sys.stdin.readline
    n,m = map(int,input().split())
    A = list(map(int,input().split()))
    BC = [list(map(int,input().split())) for _ in range(m)]

    BC = sorted(BC,key=lambda x:(x[1]),reverse=True)
    append_list = []
    for b,c in BC:
        if len(append_list)>=n:
            break
        append_list+=[c]*b
    A+=append_list
    A.sort(reverse=True)
    print(sum(A[:n]))

if __name__=='__main__':
    main()

Measured memory_bytes: 111244
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[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 ) * } } ; }
#[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" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{a:i64,op:chars,b:i64};
    println!("{}", match op[0] {
        '+' => a+b,
        '-' => a-b,
        _ => 0
    });
}


Measured memory_bytes: 4352
def gcd(a,b):
    while b % a:
        a,b = b, a % b
    return a
#(a >= b )

N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
abs_xlist = list(map(lambda x:abs(X - x), xlist))
abs_xlist.sort()
ans = abs_xlist[0]

for i in range(N):
    num = gcd(abs_xlist[i],ans)
    ans = min(num,ans)
print(ans)


Measured memory_bytes: 14252
import java.util.*;

public class Main{
  
  public static void main(String[] args){
	Scanner scanner = new Scanner(System.in);
	  int[] ans = {1,2,3};
	  int wAns1 = scanner.nextInt();
	  int wAns2 = scanner.nextInt();
	  scanner.close();
	  for (int i : ans) {
		if (i != wAns1 && i != wAns2) {
			System.out.println(i);
		}
	}
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
using namespace std;
int main(){
    string str;
    //string str1[26] = {"D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
    //"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C"};
    //string str2[26] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", 
    //"L", "M", "N","O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
    
    cin >> str;
    for(int i = 0; i < str.size(); i++){
        if(str[i] == 'A' || str[i] == 'B' || str[i] == 'C') str[i] += 23;
        else str[i] -= 3;
    }
    cout << str << endl;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    K = min(100,K);
    vector<int> A(N+1);
    rep(i,N)cin >> A[i+1];
    
    for(int i=0;i<K;i++){
        vector<ll> L(N+2);
        for(int j=1;j<=N;j++){
            ll l = max(0,j-A[j]);
            ll r = min(N,j+A[j]);
            L[l]++;
            L[r+1]--;
        }
        ll csm = 0;
        for(int j=0;j<=N;j++){
            csm+=L[j];
            A[j]=csm;
        }
    }
    rep(i,N){
        cout << A[i+1] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


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

	bool flag = true;

	for (int i = 0; i < S.size(); i++) {
		if (i == A) {
			if (S[i] != '-')flag = false;

		}
		else {
			if (S[i] == '-')flag = false;

		}

		if (flag == false) {
			print("No");
			return 0;
		}
	}
	print("Yes");


	return 0;
}

Measured memory_bytes: 256
import heapq

n = int(input())

g = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

c = list(map(lambda x: -int(x), input().split()))
heapq.heapify(c)
print(min(c) - sum(c))

ans = []
s = [-1] * n
leaf = -1
for i, a in enumerate(g):
    if len(a) == 1:
        leaf = i
        break

que = [leaf]
while que:
    t = que.pop()
    for e in g[t]:
        if s[e] == -1:
            s[e] = -heapq.heappop(c)
            que.append(e)

print(*s)


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

int main()
{
    int a[100000], sum[100000], b, c, n;

    while( cin >> n )
    {
        if( n == 0 )
            break;

        for( int i = 0; i < 100000; i++ )
            sum[i] = 0;

        for( int i = 0; i < n; i++ )
        {
            cin >> a[i];
            for( int j = 0; j < 4; j++ )
            {
                cin >> b >> c;
                sum[i] += b * 60 + c;
            }
        }

        for( int j = 0; j < 2; j++ )
        {
            int min = 1000000, max = 0, s = 0, t = 0;
            for( int i = 0; i < n; i++ )
            {
                if( a[i] != -1 && min > sum[i] )
                {
                    min = sum[i];
                    s = i;
                }
                if( a[i] != -1 && max < sum[i] )
                {
                    max = sum[i];
                    t = i;
                }
            }
            cout << a[s] << endl;
            if( j == 1 )
                cout << a[t] << endl;
            a[s] = -1;
            a[t] = -1;
        }
    }
    return 0;
}



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


int main() {
    int x,y;
    cin >> x >> y;
    for (int i=0;i<=x;i++) {
        if (2*i + 4 * (x - i) == y ){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>

int main(){
    uint32_t N;
    std::cin >> N;
    char buf;
    //std::vector<char> s_vec(N, 'a');
    std::string str;
    for(uint32_t i = 0; i < N; i++){
        //std::cin >> s_vec[i];
        std::cin >> buf;
        str += buf;
    }

    for(uint32_t l = 0; l < N; l++){
        //std::cout << str.length() << std::endl;
        if(str.length() <= l)
            break;
        //std::cout << str[l] << str[l+1] << std::endl;
        while(str[l] == str[l+1]){
            str.erase(str.begin() + l);
        }
    }
    
    std::cout << str.length() <<std::endl;
    return 0;
}

Measured memory_bytes: 1144
def readinput():
    n,y=list(map(int,input().split()))
    return (n,y)

def main(n,y):
    k=0 # num of \10000
    l=0 # num of \5000
    m=0 # num of \1000
    # k+l+m must be n
    kmax=y//10000
    for kk in range(kmax+1):
        res1=y-10000*kk
        lmax=res1//5000
        for ll in range(lmax+1):
            res2=res1-5000*ll
            m=res2//1000
            if(kk+ll+m==n):
                return (kk,ll,m)
    return(-1,-1,-1)

if __name__=='__main__':
    n,y=readinput()
    k,l,m=main(n,y)
    print(' '.join(map(str,(k,l,m))))


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

int main(){
	int n, m;
	cin >> n >> m;
	int k = pow(2, n);
	vector<int> dp(k, 1000000000);
//	vector<P> key(m);
	vector<vector<int>> key(m, vector<int>(2));
	rep(i, m){
		int a, b, b0;
		cin >> a >> b;
		int c = 0;
		rep(j, b){
			cin >> b0;
			b0--;
			c += pow(2, b0);
		}
		key[i][0] = a;
		key[i][1] = c;
	}
	dp[0] = 0;
	rep(i, k){
		rep(j, m){
			int l = i;
			l |= key[j][1];
			dp[l] = min(dp[l], dp[i] + key[j][0]);
		}
	}
	if(dp[k-1] != 1000000000){
		cout << dp[k-1] << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys

def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print()

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

swap_count = 0
for i in range(n):
	mini = i
	for j in range(i, n):
		if arr[j] < arr[mini]:
			mini = j
	if mini != i:
		arr[i] = arr[i] ^ arr[mini]
		arr[mini] = arr[i] ^ arr[mini]
		arr[i] = arr[i] ^ arr[mini]
		swap_count += 1

print_arr(arr)
print(swap_count)



Measured memory_bytes: 5616
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
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())

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

void solve(void) {
  while (1) {
    int N;
    scanf("%d\n", &N);
    if (N == 0) break;
    vector<int> ps;
    int ans = 0;
    rep(N, i) {
      int p;
      scanf("%d\n", &p);
      ps.pb(p);
      ans += p;
    }
    sort(all(ps));
    ans -= ps[0] + ps[N-1];
    printf("%d\n", ans / (N-2));
  }
}

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



Measured memory_bytes: 3072
# https://atcoder.jp/contests/abc076/tasks/abc076_b

import itertools
import collections
import bisect

def main():
    N = int(input())
    K = int(input())

    val = 1
    for _ in range(N):
        val = min(val * 2, val + K)
    print(val)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int w[N],ne[N],la[N],t,n,u,v,dep[N];
void link(int x,int y){
	w[++t]=y;
	ne[t]=la[x];
	la[x]=t;
}
int dfs(int x,int fa=0){
	int res=x;
	for (int y=la[x];y;y=ne[y]){
		int z=w[y];
		if (z==fa)continue;
		dep[z]=dep[x]+1;
		int z1=dfs(z,x);
		if (dep[z1]>dep[res])res=z1;
	}return res;
}
int a1[N],cnt[N],tag[N];
int go(int x,int tar,int fa){
	if (x==tar){
		tag[x]=1;
		a1[dep[x]]=x;
		return 1;
	}
	for (int y=la[x];y;y=ne[y]){
		int z=w[y];
		if (z==fa)continue;
		dep[z]=dep[x]+1;
		if (go(z,tar,x)){
			tag[x]=1;
			a1[dep[x]]=x;
			return 1;
		}
	}return 0;
}
int a[N],b[N],t1;
int main(){
	cin>>n;
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		link(x,y);
		link(y,x);
	}
	int u=dfs(1),v=dfs(u);
	dep[u]=0;
	go(u,v,0);
	for (int x=1;x<=n;x++){
		if (tag[x])continue;
		int cnt1=0;
		for (int y=la[x];y;y=ne[y]){
			int z=w[y];
			if (tag[z])
				cnt1++,cnt[dep[z]]++;
		}
		if (cnt1!=1){
			cout<<-1<<endl;
			return 0;
		}
	}
	t=0;
	for (int i=0;i<=dep[v];i++){
		a[++t]=t;
		for (int j=1;j<=cnt[i];j++)
			a[++t]=t,swap(a[t],a[t-1]);
	}
	t=0;
	reverse(cnt,cnt+dep[v]+1);
	for (int i=0;i<=dep[v];i++){
		b[++t]=t;
		for (int j=1;j<=cnt[i];j++)
			b[++t]=t,swap(b[t],b[t-1]);
	}
	for (int i=1;i<=n;i++){
		if (a[i]<b[i])break;
		if (a[i]>b[i]){
			memcpy(a,b,sizeof a);
			break;
		}
	}
	for (int i=1;i<=n;i++)printf("%d ",a[i]);
}

Measured memory_bytes: 11648
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e18+1;

int main()
{
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1;i<=n;i+=2){
        ll cnt=0;
        for(ll j=1;j<=i;j++){
            if(i%j==0){
                cnt++;
            }
        }
        if(cnt==8){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<string>
#include<queue>
#include<iostream>
#define REP(i, n) for(int i = 0, ed_##i = n; i < ed_##i; i++)
#define FOR(i, n) for(int i = 1, ed_##i = n; i <= ed_##i; i++)
#define bit(x) (1 << (x))
#define bitl(x) (1LL << (x))
#define sqr(x) ((x) * (x))
#define sz(x) ((int)(x.size()))
#define cnti(x) (__builtin_popcount(x))
#define cntl(x) (__builtin_popcountll(x))
#define clzi(x) (__builtin_clz(x))  // Leading zeros
#define clzl(x) (__builtin_clzll(x))
#define ctzi(x) (__builtin_ctz(x))
#define ctzl(x) (__builtin_ctzll(x))

#ifdef QWERTIER
#define err(x) cerr << #x << " : " << x << endl
#else
#define err(x)
#endif

typedef long long LL;
using namespace std;

typedef pair<int,int> pii;
#define MP make_pair

LL n, m;
bool check(LL t) {
  LL x = max(0ll, (t - n));
  if (m - x * 2ll >= t * 2)
    return true;
  else
    return false;
}
int main(){
#ifdef QWERTIER
  freopen("in.txt","r",stdin);
#endif
  cin >> n >> m;
  
  LL lo = 0, hi = (LL)1e12;
  while (lo < hi) {
    LL mi = (lo + hi + 1) >> 1;
    if (check(mi))
      lo = mi;
    else
      hi = mi - 1;
  }
  cout << lo << endl;
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
    import scala.annotation.tailrec

    val sc = new java.util.Scanner(System.in)
    val pw = new java.io.PrintWriter(System.out)
    @tailrec
    def output(h: Int = sc.nextInt, w: Int = sc.nextInt): Unit = {
        if( h != 0 && w != 0 ) {
            pw.println("#"*w)
            for(i <- 1 to h-2) pw.println("#"+"."*(w-2)+"#")
            pw.println("#"*w)
            pw.println()
            output()
        }
    }

    output()
    pw.flush
}


Measured memory_bytes: 46268
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 500005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll ord(ll n, ll k){
    if (n < 0 || k < 0 || n < k) return 0;
    return fac[n]*finv[n-k]%MOD;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    COMinit();
    rep(i,n+1){
        ll s = COM(n,i)*ord(m,i)%MOD*ord(m-i,n-i)%MOD*ord(m-i,n-i)%MOD;
        if (i%2 == 0) (ans += s)%=MOD;
        else (ans += MOD-s)%=MOD;
    }
    PRINT(ans);
}


Measured memory_bytes: 15352
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  double R;
  scanf("%lf", &R);
  printf("%.9lf\n", 2 * R * M_PI);

  return 0;
}


Measured memory_bytes: 3232
#ifdef __unix__
#include <bits/stdc++.h>
#else
#include <iostream>
#include <algorithm>
#include <math.h>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <bitset>
#endif

#define fastIO ios_base::sync_with_stdio(0), cin.tie(NULL)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
#define mkp make_pair
/*#define NUMTOSTR(x)  (unsigned char)((x) + 48);*/
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long  ull;
using namespace std;

int main(){
	fastIO;
	int n;
	cin >> n;
	while (n--)
	{
		int temp;
		cin >> temp;
		if (temp % 2 == 0) {
			if (temp % 3 == 0 || temp % 5 == 0) continue;
			else {
				cout << "DENIED";
				return 0;
			}
		}
		  
		
	}
	cout << "APPROVED";
	return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  
  vector<long long> T(N,0);
  map<long long,int> A;
  
  for(int i=0; i<N; i++){
    cin >> T.at(i);
    A[T.at(i)+i]++;
  }
 
  long long count=0;
    
  for(int i=0; i<N; i++){
    count+=A[i-T.at(i)];
  }
  cout << count << endl;
}

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



int main(){
    string S;
    cin >> S;
    long long res = 0;
    for(int i = 0; i < (1 << S.length()-1); i++){
        int split[11] = {};
        int split_cnt = 0;
        for(int j = 0; j < S.length()-1; j++){
            if((1<<j)&i){
                split[++split_cnt]=j+1;
            }
        }
        split[++split_cnt]=S.length();

        for(int j = 0; j < split_cnt; j++){
            res += std::stol(S.substr(split[j], split[j+1]-split[j]));
        }
    }
    cout << res << endl;
    return 0;
}

            

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
 
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)
 
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;

int MinimumNumIncreasingSubsequences(int arr[], int n) 
{ 
    multiset<int> last; 
  
    // last element in each  increasing subsequence  
    // found so far 
    for (int i = 0; i < n; i++) { 
  
        // here our current element is arr[i] 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
  
        // iterator to the first element larger  
        // than or equal to arr[i] 
        if (it == last.begin()) 
  
            // if all the elements in last larger 
            // than or to arr[i] then insert it into last 
            last.insert(arr[i]); 
  
        else { 
            it--; 
  
            // the largest element smaller than arr[i] is the number 
            // before *it which is it-- 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 
signed main() {
 
	
	//fastio();
	//#define LOCAL_DEFINE
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif	
	//https://www.coursera.org/learn/algorithms-on-strings/home/welcome
	//https://www.coursera.org/lecture/algorithms-on-strings/suffix-array-and-suffix-tree-TV4I6
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	cout<<MinimumNumIncreasingSubsequences(arr,n);
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
using namespace std;
int main(){
  long long a,b,k;
  cin>>a>>b>>k;
  if(a-k<0){
    if(b+a-k<0){
      cout << "0 0"<<endl;
    }else{
      cout << "0 "<<b+a-k<<endl;
    }
  }else{
    cout << a-k<<" "<<b<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define mod 1000000007
#define maxn 2500ll
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
struct Cell
{
	ll v,cst,mt;
};
vector<Cell> adj[55];
ll dp[55][2505];
pii a[55];
void dijkstra(ll u,ll c)
{
	set<pair<ll,pii> >st;
	pii temp;
	temp.fi=u;temp.se=c;
	st.insert({0,temp});
	dp[u][c]=0;
	while(!st.empty())
	{
		pair<ll,pii> temp=*st.begin();
		st.erase(st.begin());
		ll mnt=temp.fi;
		u=(temp.se).fi;
		c=(temp.se).se;
		if(c<maxn)
		{
			ll val=min(maxn,c+a[u].fi);
			ll &res=dp[u][val];
			if(res>mnt+a[u].se)
			{
				st.erase({res,{u,val}});
				res=mnt+a[u].se;
				st.insert({res,{u,val}});
			}
		}
		for(auto it=adj[u].begin();it!=adj[u].end();it++)
		{
			Cell temp=*it;
			if(c>=temp.cst)
			{
				ll &res=dp[temp.v][c-temp.cst];
				if(res>mnt+temp.mt)
				{
					st.erase({res,{temp.v,c-temp.cst}});
					res=mnt+temp.mt;
					st.insert({res,{temp.v,c-temp.cst}});
				}
			}
		}
	}
}
int main()
{
	ios;
	ll i,m,s,n,u,j,k;
	cin>>n>>m>>s;
	s=min(s,maxn);
	for(i=1;i<=m;i++)
	{
		Cell temp;
		cin>>u>>temp.v>>temp.cst>>temp.mt;
		adj[u].push_back(temp);
		swap(temp.v,u);
		adj[u].push_back(temp);
	}
	for(i=1;i<=n;i++)
		cin>>a[i].fi>>a[i].se;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=maxn;j++)
			dp[i][j]=LLONG_MAX;
	}
	dijkstra(1,s);
	for(i=2;i<=n;i++)
	{
		ll min1=LLONG_MAX;
		for(j=0;j<=maxn;j++)
			min1=min(min1,dp[i][j]);
		cout<<min1<<endl;
	}
}


Measured memory_bytes: 7872
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long A, B, K; cin >> A >> B >> K;
  	if (K <= A) A -= K;
  	else {
    	K -= A; A = 0; 
      	if (K <= B) B -= K;
      	else B = 0;
    }
  	cout << A << " " << B;
}

Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列
// #include "boost/multi_array.hpp"

//名前空間
using namespace std;
typedef long long ll;

//マクロ
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)  //range(a, b, 1)と対応 aからb回iter
#define FORD(i, a, b) for (ll i = (a); i > (b); i--) //range(a, b, -1)と対応 aからb回iter
#define REP(i, b) FOR(i, 0, b)
#define REPD(i, a) FOR(i, a, 0)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)
#define CC(x) cout << (x) << endl

signed main()
{
    ll N;
    cin >> N;
    cout << double(2 * N * 3.1415926535897932) << endl;
}

Measured memory_bytes: 3716
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, m, q;
		
		n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			m = sc.nextInt();
			if (dfs(a, m, 0)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}
	
	static boolean dfs(int[] a, int m, int current) {
		if (m == 0) {
			return true;
		}
		if (m < 0 || current == a.length) {
			return false;
		}
		
		if (dfs(a, m, current+1) || dfs(a, m - a[current], current+1)) {
			return true;
		}
		return false;
	}
}

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

int main() {
  //input
  int a, b;
  cin >> a >> b;
  //calc
  int c = a <= b ? a : b;
  int n = a <= b ? b : a;
  //output
  rep(i,n) {
    cout << c;
  }
  cout << endl;
}

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

int main(){
  int N, X, T;
  cin >> N >> X >> T;
  
  if(N % X == 0){
    cout << N / X * T << endl;
  }
  else{
    cout << (N / X + 1) * T << endl;
  }
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define MOD 1000000007LL
#define len 12
int scan(int*a,int n){int*p;char*ptr_c,*buf;buf=malloc(n*len);p=a;ptr_c=buf;fgets(buf,n*len,stdin);while(n--){*p++=atoi(ptr_c);ptr_c=strchr(ptr_c+1,32)+1;}}

int main(){
	ll a,b;
	int *x,*y,*ptr,n,m,i;

	scanf("%d%d\n",&n,&m);
	x=(int*)malloc(n*sizeof(int));
	y=(int*)malloc(m*sizeof(int));
	scan(x,n);
	scan(y,m); 

	for(i=1,a^=a,ptr=x,++n;i<n;++i)
		a+=*ptr++*((ll)i+i-n)%MOD;
		
	for(i=1,b^=b,ptr=y,++m;i<m;++i)
		b+=*ptr++*((ll)i+i-m)%MOD;
	
	printf("%lld\n",(a%MOD)*(b%MOD)%MOD);
	
	free(x);
	free(y);
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  //cout << N << S << endl;
  for(int i=0 ; i < N ; i++){
    string tmp_s;
    if(i+2 >= N){
        break;
    } 
    tmp_s = S.substr(i,3);
    //cout << tmp_s << endl;
    if(tmp_s == "ABC"){
        count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int d, i, j, c[28], s[370][28], b[28] = {}, ans;

    scanf("%d", &d);
    for (i = 0; i < 26; i++) {
        scanf("%d", &c[i]);
    }
    for (i = 0; i < d; i++) for (j = 0; j < 26; j++) {
        scanf("%d", &s[i][j]);
    }

    for (i = 0; i < 26; i++) {
        b[i] = 1;
    }

    //-----------------------
    int t[370], scmax, scmi;

    for (i = 0; i < d; i++) {
        scmax = 0;
        scmi = 0;
        for (j = 0; j < 26; j++) {
            if (scmax < s[i][j]) {
                scmax = s[i][j];
                scmi = j;
            }
        }
        t[i] = scmi;
    }

    //-----------------------

    ans = 0;
    for (i = 0; i < d; i++) {
        ans += s[i][t[i]];
        b[t[i]] = 0;
        for (j = 0; j < 26; j++) {
            ans -= c[j] * b[j];
            b[j]++;
        }
    }

    for (i = 0; i < d; i++) {
        printf("%d\n", t[i] + 1);
    }
    
    return 0;
}

Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
int a[30050];
int main(){
    int n;
    scanf("%d",&n);
    for (int i=1;i<=2*n;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+2*n);
    int ans=0;
    for (int i=1;i<=2*n;i+=2) ans+=a[i]; 
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define mor > muu & operator << (
#define R22(r) sim > typename \
  enable_if<1 r sizeof dud<c>(0), muu&>::type operator<<(c g) {
sim > struct rge { c b, e; };
sim > rge<c> range(c h, c n) { return {h, n}; }
sim > auto dud(c* r) -> decltype(cerr << *r);
sim > char dud(...);
struct muu {
#ifdef LOCAL
stringstream a;
~muu() { cerr << a.str() << endl; }
R22(<) a << boolalpha << g; ris; }
R22(==) ris << range(begin(g), end(g)); }
sim, class b mor pair < b, c > r) { ris << "(" << r.first << ", " << r.second << ")"; }
sim mor rge<c> u) {
  a << "[";
  for (c i = u.b; i != u.e; ++i)
    *this << ", " + 2 * (i == u.b) << *i;
  ris << "]";
}
#else
sim mor const c&) { ris; }
#endif
muu & operator()() { ris; }
};
#define imie(r...) "[" #r ": " << (r) << "] "
#define imask(r...) "[" #r ": " << bitset<8 * sizeof(r)>(r) << "] "
#define arr(a, i) "[" #a imie(i) ": " << a[i] << "] "
#define arr2(a, i, j) "[" #a imie(i) imie(j) ": " << a[i][j] << "] "
#define debug (muu() << __FUNCTION__ << "#" << __LINE__ << ": ")

const int N = 1e4 + 7;
const int M = 107;
const int mod = 1e9 + 7;

long long ile[N][M];
char numC[N];
int num[N];
int d;

int main() {
    scanf("%s", numC + 1);
    int n = strlen(numC + 1);
    for (int i = 1; i <= n; ++i) num[i] = numC[i] - '0';
    scanf("%d", &d);
    
    ile[0][0] = 1;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j < d; ++j) {
            ile[i][j] %= mod;
            for (int z = 0; z < 10; ++z) {
                ile[i + 1][(j + z) % d] += ile[i][j];
            }
        }
    }
    
    long long wynik = 0;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        for (int z = 0; z < num[i]; ++z) wynik += ile[n - i][(2 * d - (sum + z % d)) % d];
        for (int z = 0; z < num[i]; ++z) debug << imie(i) << imie(z) << imie((2 * d - (sum + z % d)) % d) << ile[n - i][(2 * d - (sum + z % d)) % d];
        sum = (sum + num[i]) % d;
    }
    
    wynik += mod - 1;
    
    if (sum == 0) wynik++;
    
    printf("%lld\n", wynik % mod);
    return 0;
}


Measured memory_bytes: 8704
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	string s; cin >> s;
    int cnt = 0;
    rep(i, 6) {
        if(s[i] == '1') ++ cnt;
    }
    cout << cnt << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int	main(void)
{
	char	s[1001] = {0};
	char	t[1001] = {0};
	int		s_len = 0;
	int		t_len = 0;
	int		diff;
	int		count;
	int		i = 0;
	int		j;
	int		k = 0;

	if (scanf("%s", s) < 0)
		return (0);
	if (scanf("%s", t) < 0)
		return (0);
	while (s[i])
		i++;
	s_len = i;
	i = 0;
	while (t[i])
		i++;
	t_len = i;
	diff = t_len;
	while (k < t_len)
	{
		i = k;
		while (i < s_len - t_len + 1 +k)
		{
			j = 0;
			count = t_len;
			if (s[i] == t[k])
			{
				while (j + k < t_len)
				{
					if (s[i + j] == t[k + j])
						count--;
					j++;
				}
			}
			if (diff > count)
				diff = count;
			i++;
		}
		k++;
	}
	printf("%d", diff);
	return (0);
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 55;


struct aresta{
  int v,a,b;
  aresta(){}
  aresta(int A,int B,int C){
    v = A;
    a = B;
    b = C;
  }
};

vector<aresta> g[N];

int c[N],d[N];
ll dp[N][N*N];
bool vis[N][N*N];

struct coisa{
 int id,s,t;
 coisa(){}
 coisa(int a,int b,int c){
  id = a;
  s = b;
  t = c;
 }

 bool operator<(const coisa & o)const{
  return !(t < o.t);
 }

};


const int inf = N*N - 10;

int32_t main(){
  fastio;
  int n,m,s;
  cin>>n>>m>>s;
  s = min(s,inf);
  for(int i=0;i<m;i++){
    int u,v,a,b;
    cin>>u>>v>>a>>b;
    g[u].pb(aresta(v,a,b));
    g[v].pb(aresta(u,a,b));
  }

  for(int i=1;i<=n;i++){
    cin>>c[i]>>d[i];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N*N;j++){
      dp[i][j] = 1e18;
    }
  }

  priority_queue<coisa> pq;
  pq.push(coisa(1,s,0));
  dp[1][s] = 0;
  vis[1][s] = 1;
  while(!pq.empty()){
      coisa cur = pq.top();
      pq.pop();
      int could = min(inf,cur.s + c[cur.id]);
      if(dp[cur.id][could] > dp[cur.id][cur.s] + d[cur.id]){
        vis[cur.id][could] = 1;
        dp[cur.id][could] = dp[cur.id][cur.s] + d[cur.id];
        pq.push(coisa(cur.id,could,cur.t + d[cur.id]));
      }
      for(auto e : g[cur.id]){

        if(cur.s >= e.a){
        
            if(dp[e.v][cur.s - e.a] > dp[cur.id][cur.s] + e.b){
                  dp[e.v][cur.s - e.a] = dp[cur.id][cur.s] + e.b;
                
                  //if(!vis[e.v][cur.s - e.a]){
                    pq.push(coisa(e.v,cur.s - e.a, dp[e.v][cur.s - e.a]));
                 // }
            }
        }
      }

  }

  for(int t=2;t<=n;t++){
    int best = 1e18;
    for(int j=0;j<N*N;j++){
      best = min(best,dp[t][j]);
    }
    cout<<best<<endl;
  }
  

  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 7792
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  int K,X;
  cin>>K>>X;
  int count=X-K+1;
  int len=2*K-1;
  rep(i,len){
    cout<<count<<" ";
    count++;
  }
}

Measured memory_bytes: 256
N = int(input())
b = list(map(int,input().split(" ")))
used = [0] * N
n = N
ans = []
for i in range(N):
    index = n
    flg = True
    for j in range(N-1,-1,-1):
        if used[j] == 0:
            if b[j] == index:
                used[j] = 1
                ans.append(b[j])
                flg = False
                break
            else:
                index -= 1
    if flg:
        print("-1")
        exit(0)
    n -= 1


print(*ans[::-1])


Measured memory_bytes: 39024
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    for(int i = 1; i < 10; ++i){
        if(n % i == 0 && n / i < 10){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict"
const fs = require("fs");
const input = fs.readFileSync("/dev/stdin", "utf8");

const ary = [parseInt(input, 10)];

for (let current = ary; ;) {
  const next = (current % 2) ? current * 3 + 1 : current / 2;
  if (ary.indexOf(next) !== -1) {
    console.log(ary.length + 1);
    break;
  }
  current = next;
  ary.push(next);
}


Measured memory_bytes: 7372
import sys

n = int(raw_input())
d = [[0, 0, 0]]
for i in range(n):
    d.append([int(x) for x in raw_input().strip().split()])

for i in range(n):
    dt = d[i + 1][0] - d[i][0]
    dx = abs(d[i + 1][1] - d[i][1])
    dy = abs(d[i + 1][2] - d[i][2])
    if dt % 2 != (dx + dy) % 2 or (dx + dy) > dt:
        print('No')
        sys.exit()

print 'Yes'


Measured memory_bytes: 23156
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, ans = 0;
  std::cin >> N;
  std::vector<ll> a(N);
  std::vector<ll> S(N+1);
  S[0] = 0;
  range(i, N) {
    std::cin >> a[i];
    S[i+1] = S[i] + a[i];
  }
  sort(S.begin(), S.end());
  range(i, N+1) ans += upper_bound(S.begin(), S.end(), S[i]) - lower_bound(S.begin(), S.end(), S[i]) - 1;
  std::cout << ans/2 << '\n';
  return 0;
}


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

int main(){
    int a;
    cin >> a;
    if(a&1) cout << fixed << setprecision(6) << (double)(a+1)/(double)a/2.0 << endl;
    else cout << fixed << setprecision(6) << (double) 0.5 << endl;
    return 0;
}

Measured memory_bytes: 256
while(1):
    hoge = list(map(int,input().split()))
    w,h = hoge[0],hoge[1]
    if w == 0 and h == 0:
        break
    for i in range(w):
        for j in range(h):
            if (i+j) % 2:
                print(".",end="")
            else:
                print("#",end="")
        print("")
    print("")


Measured memory_bytes: 7012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int num[110][110] = {};

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

  for (int i = 2; i <= n; ++i)
  {
    int t = i;
    for (int j = 2; j <= n;)
    {
      if (t % j == 0)
      {
        num[i][j]++;
        t /= j;
      }
      else
        j++;
    }
    for (int j = 0; j < 110; ++j)
    {
      num[i + 1][j] = num[i][j];
    }
  }

  int cnt[100] = {};

  for (int i = 0; i <= n; ++i)
  {
    for (int j = 0; j < 100; ++j)
    {
      if (j <= num[n][i])
        cnt[j]++;
    }
  }

  int sum = 0;
  sum += cnt[74];
  sum += cnt[24] * (cnt[2] - 1);
  sum += cnt[14] * (cnt[4] - 1);
  sum += cnt[4] * (cnt[4] - 1) / 2 * (cnt[2] - 2);
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
double x[100],y[100],A,h,X,Y,C,S;i,j,k,s,m,M;main(n){for(;~scanf("%d",&n);n&&printf("%d\n",M+2)){M=-1;for(i=n;i--;)scanf("%lf,%lf",x+i,y+i);for(i=n;i-->0;)for(j=i;j--;)if(A=hypot(x[i]-x[j],y[i]-y[j])/2,A<=1)for(S=atan2(y[i]-y[j],x[i]-x[j]),C=cos(S),S=sin(S),h=sqrt(1-A*A),s=2;s--;h=-h)for(m=0,k=n;k--;M=m>M?m:M)m+=k-i&&k-j&&hypot(x[j]+A*C-h*S-x[k],y[j]+A*S+h*C-y[k])<=1;}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,w;
	cin>>n>>w;
	ll weight[n+1],val[n+1];
	for(int i = 1;i<=n;i++)
	{
		cin>>weight[i]>>val[i];
	}
	ll dp[n+1][w+1] = {0};
	for(int i = 0;i<=n;i++)
	{
		for(int j = 0;j<=w;j++)
		{
			if(i == 0 || j == 0)
				dp[i][j] = 0;
			else if(weight[i] <= j)
			{
				dp[i][j] = max(dp[i-1][j],val[i]+dp[i-1][j-weight[i]]);
			}
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	cout<<dp[n][w]<<'\n';
}

Measured memory_bytes: 79104