akhauriyash/Code-Regression huggingface dataset:
const main = lines => {
  console.log(solve(lines));
};

const solve = (lines: string[]): string => {
  const { N, D } = parseLines(lines);
  return Math.ceil(N / (D * 2 + 1)).toString();
};

const parseLines = (lines: string[]) => {
  const [N, D] = lines[0].split(' ').map(v => +v);
  const obj = { N, D };
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}

export default solve;


Measured memory_bytes: 7500
#include<stdio.h>
#include<stdlib.h>

#define MAX 100000
#define NIL -1
struct node{int p,l,r;};

struct node T[MAX];
int n,D[MAX];

void print(int);
void rec(int,int);


int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;//必要な部分初期化
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);//vはrootの値、dはrootの子供の数
    for(j=0;j<d;j++){//子供の数ぶん入力
      scanf("%d",&c);
      if(j==0)T[v].l=c;//１週目は最も左の子供をleftに
      else T[l].r=c;//２週目は最も右の子供をrighに
      l=c;
      T[c].p=v;//親を教えてあげる
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;//親がrootで最も右のものをrightに
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);
  return 0;
}

void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);

  if(T[u].p==NIL) printf("root, ");
  else if(T[u].l==NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

void rec(int u,int p){//再帰で深さを教えてあげる
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r,p);
  if(T[u].l != NIL) rec(T[u].l,p+1);
}



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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  string s;
  cin >> s;
  s.at(3) = '8';
  cout << s << endl;
}


Measured memory_bytes: 256
N,M = map(int, input().split())
data = []
for i in range(N):
  ab = list(map(int, input().split()))
  data.append(ab)

data = sorted(data)
count = 0
res = 0
for li in data:
  if count + li[1] < M:
    res += li[0]*li[1]
    count += li[1]
  else:
    res += li[0]*(M-count)
    break

print(res)

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

vector<vector<int>> adj;
int csz = 0;
vector<int> vis;

void dfs(int x) {
	if(vis[x])
		return;
	vis[x]=1;
	csz++;
	for(int i: adj[x])
		dfs(i);
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n,m;
	cin>>n>>m;
	adj.resize(n);
	vis.resize(n);
	int x,y;
	while(m--) {
		cin>>x>>y;
		x--;
		y--;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	int ans = 0;
	for(int i=0;i<n;i++) {
		if(!vis[i]) {
			csz = 0;
			dfs(i);
			ans = max(ans, csz);
		}
	}

	cout<<ans;

	return 0;
}

Measured memory_bytes: 21824
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

//nCkを求める(n<∞ , k<300000)
const ll M=1000000007;
vector<ll> fac(300001); //n*(n-1)*…(n-k+1)(mod M)
vector<ll> ifac(300001); //k! (mod M)
//フェルマーの小定理 : X/Y=X*Y^-1 , Y^-1≡Y^(M-2) (mod M 素数)

//O(logn)でx^n(mod M)を求める
ll mpow(ll x,ll n){
  if(n==0) return 1;
  ll res=mpow(x*x%M,n/2);
  if(n&1) res=res*x%M; //nが奇数の場合
  return res;
}

ll comb(int n,int k){ //nCk(mod M)を計算
  if(n==0&&k==0)return 1;
  if(n<k||n<0)return 0;
  ll tmp=mpow(ifac[k],M-2)%M;//フェルマーの小定理 : (k!)^(M-2)
  return tmp*fac[k-1]%M;//n*(n-1)*…*(n-k+1)/k!
}

//O(k)で階乗の計算の準備
void set_comb(ll n){
  fac[0]=n;
  ifac[0]=1;
  for(ll i=0;i<300000;i++){
    if(n-i-1>0)
    fac[i+1]=fac[i]*(n-i-1)%M;//fac[i] : n*(n-1)*…*(n-i)
    ifac[i+1]=ifac[i]*(i+1)%M; // k! (mod M)
  }
}

int main(){
  ll n,a,b; cin>>n>>a>>b;
  set_comb(n);
  ll ans=mpow(2,n)-1;
  ll d=(comb(n,a)+comb(n,b))%M;
  if(ans-d<0) ans+=M;
  ans=(ans-d)%M;
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
    int x,y,z;
    cin >> x>>y>>z;
    int cm=z,count=0;
    for(int i=0;i<100000;i++){

        cm+=y+z;
        if(cm<=x){
            count++;

        }
        else{
            break;
        }
    }

    
    cout << count<< endl;
}

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

void solve()
{
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, n)
    {
        x -= a[i];
        if (x >= 0)
        {
            ans++;
            if (i == n - 1 && x > 0)
                ans--;
        }
        else
        {
            break;
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3668
h,w,k=map(int,input().split())
c=list(list(input()) for _ in range(h))
ans=0
for n in range(2**(h+w)):
    l={}
    o={}
    x=0
    for m in range(h+w):
        if (n>>m)&1:
            if m>=h:
                o[m-h]=1
            else:
                l[m]=1
    for i in range(h):
        if not i in l:
            for j in range(w):
                if not j in o:
                    if c[i][j]=="#":
                        x+=1
    if x==k:
        ans+=1
print(ans)


Measured memory_bytes: 74432
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    int ret = 0;
    for (int i = 1; i < N - 1; i++) {
        int mn = min(A[i], min(A[i-1], A[i+1]));
        int mx = max(A[i], max(A[i-1], A[i+1]));
        if (mn != A[i] && mx != A[i]) ret++;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int A[100000+10];
Int X[100000+19];

int main(void) {
    int N;
    cin>>N;
    
    for(int i = 1;i <= N;i++) {
        cin>>A[i];
    }

    Int sum = 0;
    for(int i = 1;i <= N;i++) {
        if(i&1)
            sum += A[i];
        else
            sum -= A[i];
    }
    X[1] = sum/2;
    for(int i = 2;i <= N;i++) {
        X[i] = A[i-1]-X[i-1];
    }
    for(int i = 1;i <= N;i++) {
        cout<<X[i]*2<<" ";
    }

    return 0;
}


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

unsigned long long phi(unsigned long long n){
    if(n == 1) return 1;
    unsigned long long r = n;
    for(long long i = 2; i <= n; i++){
        if(!(n % i)){
            r = r * (i - 1) / i;
            while (!(n % i)){
                n /= i;
            }
        }
    }
    return r;
}

int main(){
    unsigned long long n; cin >> n;
    cout << phi(n) << endl;
    return 0;
}


Measured memory_bytes: 3116
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if b-a<=k and c-a<=k and d-a<=k and e-a<=k and c-b<=k and d-b<=k and e-b<=k and d-c<=k and e-c<=k and e-d<=k:
  print('Yay!')
else:
  print(':(')

Measured memory_bytes: 3064
from itertools import permutations

n = int(input())
x, y = zip(*[list(map(int, input().split())) for i in range(n)])

per_loop = permutations(range(n))
d = 0
cnt = 0
for t in per_loop:
    for i in range(1, n):
        d += ((x[t[i]]-x[t[i-1]])**2 + (y[t[i]]-y[t[i-1]])**2)**(0.5)
    cnt += 1

print(d / cnt)

Measured memory_bytes: 74360
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++) {
    cnt += s[i] == 'o';
  }
  cout << 700 + cnt * 100 << endl;
  return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  vector<int> counter(N, 0);
  for (int i = 0; i < Q; i++) {
    int p, x;
    cin >> p >> x;
    counter[p - 1] += x;
  }
  queue<int> que;
  que.push(0);
  vector<bool> used(N, false);
  used[0] = true;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int v : G[u]) {
      if (used[v]) continue;
      used[v] = true;
      counter[v] += counter[u];
      que.push(v);
    }
  }
  for (auto &v : counter) {
    cout << v << (&v == &counter.back() ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 15604
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var h = int.Parse(Console.ReadLine());
        var w = int.Parse(Console.ReadLine());
        var n = int.Parse(Console.ReadLine());
        var max = Max(h, w);
        Console.WriteLine((n + max - 1) / max);
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, K, x[100001];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d", &(x[i]));
	
	int ans = (x[N] - x[1]) * 2, b;
	if (x[1] >= 0) ans = x[K];
	else if (x[N] <= 0) ans = -x[N-K+1];
	else {
		for (b = 1; x[b+1] < 0; b++);
		if (b >= K && -x[b-K+1] < ans) ans = -x[b-K+1];
		if (b + K <= N && x[b+K] < ans) ans = x[b+K]; 
		for (i = 1; i <= K - 1; i++) {
			if (i > b) break;
			else if (i < b + K - N) continue;
			if (x[b+K-i] - x[b-i+1] * 2 < ans) ans = x[b+K-i] - x[b-i+1] * 2;
			if (x[b+K-i] * 2 - x[b-i+1] < ans) ans = x[b+K-i] * 2 - x[b-i+1];
		}
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
  int key;
  struct Node *right;
  struct Node *left;
  struct Node *parent;
};

struct Node *root;
struct Node *NIL;

void insert(int k){

  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x-> key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y -> right = z;
  }
}

void inorder(struct Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){

  int n;
  int i;
  int x;
  char *com;
  char *comin = "insert";
  char *compr = "print";

  com = (char*)malloc(10*sizeof(char));  
  
  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", com);
  
    if(strncmp(com,comin,6)==0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strncmp(com,compr,5)==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25156
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,k;
  cin>>a>>b>>k;
  if(k<=a){
    cout<<a-k<<" "<<b<<endl;
  }
  else if(a<=k && k<=a+b){
    cout<<0<<" "<<b-(k-a)<<endl;
  }
  else if(a+b<=k){
    cout<<0<<" "<<0<<endl;
  }
  return 0;
}
  


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++) if((i&1 ? 'i':'h')!=s[i]) {
		cout<<"No\n";
		return 0;
	}
	cout<<(s.size()&1 ? "No\n":"Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
   cin>>n;
   l(i,1,n+1)
   {cin>>a;
   if(a%2==0)
   {
       d++;
       if(a%3==0||a%5==0)
       {
           x++;
       }
   }


}
if(x==d)
{
    cout<<"APPROVED"<<endl;
}
else{cout<<"DENIED";}
}







Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF  = 1<<30;


struct item {
  int v, w;
  item (int v = 0, int w = 0) : v(v), w(w) {}
  bool operator<(const item &r) const { return w < r.w; }
  void operator+=(const item &r) { w += r.w, v += r.v; }
};


vector<item> enum_powerset(const vector<item> &is) {
  vector<item> a(1);
  for (auto &i : is) {
    auto b = a;
    for (auto &e : b) e += i;
    vector<item> c;
    merge(all(a), all(b), back_inserter(c));
    swap(a, c);
  }
  return a;
}


int solve(const vector<item> &is, int W) {
  int n = sz(is);
  auto a = enum_powerset({is.begin(), is.begin() + n/2});
  auto b = enum_powerset({is.begin() + n/2, is.end()});
  reverse(all(a));
 
  int ans = 0;
  int vbmax = -INF;
  auto itr = b.begin();
  for (auto &[va, wa] : a) {
    while (itr != b.end() && wa + itr->w <= W) {
      chmax(vbmax, itr->v);
      ++itr;
    }
    chmax(ans, va + vbmax);
  }
  return ans;
}


int main() {
  int n; cin >> n;
  vector<item> is(n);
  for (auto &[v, w] : is) cin >> v >> w;
  is.insert(is.begin(), item{0, 0});

  int q; cin >> q;
  rep(_, q) {
    int v, l; cin >> v >> l;
    vector<item> qi;
    while (v) {
      qi.push_back(is[v]);
      v /= 2;
    }
    cout << solve(qi, l) << '\n';
  }
}


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

int left(int i) { return (i + 1) * 2 - 1; }
int right(int i) { return (i + 1) * 2; }

void maxHeapify(int N, int A[], int i) {
    if (i >= N) {
        return;
    }
    int l = left(i);
    int r = right(i);
    int largest = i;
    if (l < N && A[l] > A[i]) {
        largest = l;
    }
    if (r < N && A[r] > A[largest]) {
        largest = r;
    }
    
    if (largest != i) {
        int temp = A[i];
        swap(A[i], A[largest]);
        maxHeapify(N, A, largest);
    }
}

void buildMaxHeap(int N, int A[]) {
    for (int i = N / 2; i >= 0; i--) {
        maxHeapify(N, A, i);
    }
}

int main() {
    int N, A[500000];
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    
    buildMaxHeap(N, A);
    
    for (int i = 0; i < N; i++) {
        printf(" %d", A[i]);
    }
    
    cout << endl;

    return 0;
}



Measured memory_bytes: 5248
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	string s,t="";
	cin>>s;
	{
		REP(Bit,1<<4){
			bitset<4> b(Bit);
			t="";
			t=t+(b[3]==1?"A":"")+"KIH"+(b[2]==1?"A":"")+"B"+(b[1]==1?"A":"")+"R"+(b[0]==1?"A":"");
			if(s==t){
				cout<<"YES"<<endl;
				return 0;
			}
			DEB(b)DEB(t)END
		}
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
const int INF = (int)1 << 50;

main() {
  int N, M;
  cin >> N >> M;
  const int NMAX = 1000;
  const int MMAX = 2000;
  int a[MMAX], b[MMAX], c[MMAX];
  for (int i = 0; i < M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    c[i] *= -1;
  }
  int dist[NMAX];
  for (int i = 0; i < N; ++i) dist[i] = INF;
  dist[0] = 0;
  for (int loop = 0; loop < N - 1; ++loop) {
    for (int i = 0; i < M; ++i) {
      if (dist[a[i] - 1] == INF) continue;
      if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
          dist[b[i] - 1] = dist[a[i] - 1] + c[i];
      }
    }
  }
  int ans = dist[N - 1];
  bool negative[NMAX];
  for (int i = 0; i < N; ++i) negative[i] = false;
  for (int loop = 0; loop < N; ++loop) {
    for (int i = 0; i < M; ++i) {
      if (dist[a[i] - 1] == INF) continue;
      if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
        dist[b[i] - 1] = dist[a[i] - 1] + c[i];
        negative[b[i] - 1] = true;
      }
      if (negative[a[i] - 1] == true) negative[b[i] - 1] = true;
    }
  }
  if (negative[N - 1])
    cout << "inf" << endl;
  else
    cout << -ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    string s; cin >> s;
    bool flag = false;
    REP(i, s.size()){
        if(s[i] == '7')flag = true;
    }
    if(flag) Yes();
    else No();
}

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n,k;
double x[100],y[100],c[100];
double EPS=1e-7;

struct Point{
    double x,y;
    Point(double xx,double yy){
        x=xx;
        y=yy;
    }
};

struct Circle{
    double x,y,r;
    Circle(double xx,double yy,double rr){
        x=xx;
        y=yy;
        r=rr;
    }
};
bool is_in_cercle(Point p,Circle c){
    double x1=p.x,y1=p.y;
    double x2=c.x,y2=c.y,r=c.r;
    //double r=sqrt(x1*x1+y1*y1);
    double dx=x1-x2,dy=y1-y2;
    double dist=sqrt(dx*dx+dy*dy);
    return dist<r+EPS;
}
bool is_cross(Circle a,Circle b){
    double dist=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
    if(a.r+b.r < dist)
        return 0;
    if(a.r+dist<b.r || b.r+dist<a.r)
        return 0;
    
    return 1;
}
bool ok(double ans){
    vector<Circle>ci;
    vector<Point>koho;
    ci.clear();
    koho.clear();

    for(int i=0;i<n;i++){
        ci.pb(Circle(x[i],y[i],ans/c[i]));
        koho.pb(Point(x[i],y[i]));
    }

   for(int i=0;i<n;i++){
       for(int j=i+1;j<n;j++){
            double x1,y1,x2,y2,r1,r2,a;
            x1=ci[i].x;
            y1=ci[i].y;
            r1=ci[i].r;

            x2=ci[j].x;
            y2=ci[j].y;
            r2=ci[j].r;
            x1-=x2;y1-=y2;
            x2=y2=0.0;

            a=(x1*x1+y1*y1+r2*r2-r1*r1)/2;

            double ax1,ax2,ay1,ay2;
            //if((x1*x1+y1*y1)*r1*r1-a*a+EPS > 0.0){
            if(is_cross(ci[i],ci[j])){
            ax1=(a*x1+y1*sqrt((x1*x1+y1*y1)*r2*r2-a*a))/(x1*x1+y1*y1); 
            ay1=(a*y1-x1*sqrt((x1*x1+y1*y1)*r2*r2-a*a))/(x1*x1+y1*y1); 
            ax2=(a*x1-y1*sqrt((x1*x1+y1*y1)*r2*r2-a*a))/(x1*x1+y1*y1); 
            ay2=(a*y1+x1*sqrt((x1*x1+y1*y1)*r2*r2-a*a))/(x1*x1+y1*y1); 
            koho.pb(Point(ax1+ci[j].x,ay1+ci[j].y));
            koho.pb(Point(ax2+ci[j].x,ay2+ci[j].y));
            //assert((x1*x1+y1*y1)*r1*r1-a*a<0.0);
            //cout<<a<<" "<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<ax1<<" "<<ay1<<" "<<ax2<<" "<<ay2<<endl;
            }
       }
   } 
    rep(i,koho.size()){
        int cnt=0;
        rep(j,n){
            if(is_in_cercle(koho[i],ci[j]))
                cnt++;
        }
        //cout<<ans<<" "<<cnt<<" "<<koho[i].x<<" "<<koho[i].y<<endl;
        if(cnt>=k){
         //   cout<<endl;
            return true;
        }
    }
    //cout<<endl;
    return false;
}

int main() {
    cin>>n>>k;
    rep(i,n)cin>>x[i]>>y[i]>>c[i];

    double l=0.0,r=100000000.0;

    rep(ii,200){
        double mid=(r+l)/2;
        if(ok(mid))
            r=mid;
        else
            l=mid;
    }
 
    printf("%.10lf\n",l);

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
    int a, b, c, x, y;
    scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
    int min = x < y ? x : y;
    long ans = 0;
    long anst = 0;
    if (a + b > 2 * c)
    {
        if (x > y)
        {
            ans = y * 2 * c + (x - y) * a;
        }
        else
        {
            ans = x * 2 * c + (y - x) * b;
        }
    }
    else
    {
        ans = a * x + b * y;
    }

    if (x > y)
    {
        anst = x * 2 * c;
    }
    else
    {
        anst = y * 2 * c;
    }
    if (ans > anst)
    {
        ans = anst;
    }

    printf("%ld\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << ' ' << x << ' ' <<  y << endl;
}

Measured memory_bytes: 256
//Author: nimishkhurana
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(i=a;i<b;i++)
#define rrep(i,b,a) for(i=b;i>=a;i--)
#define ld long double
#define ll long long
#define umapi unordered_map<int,int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int> 
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define pb push_back
#define mk make_pair
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define INF 1000000000
template <typename T>
ostream& operator << (ostream& stream, const pair<T,T> &p) {
    return stream<<"("<<p.first<<","<<p.second<<") ";
}


int main(){
    fastIO
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int n, k;
    cin>>n>>k;
    int i, j;
    int h[n];
    rep(i, 0, n) cin>>h[i];

    vector<int> dp;
    dp.push_back(0);
    for(int i = 1; i < n; i++){
        int cur = INF, j = i-1;
        for(auto it = dp.rbegin(); it != dp.rend(); it++){
            cur = min(cur, *it + abs(h[i] - h[j--]));
        }

        if(dp.size()==k)
            dp.erase(dp.begin());
        dp.push_back(cur);
    }
    cout<<dp.back();
   
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
ll kpow(ll a,ll b){
	ll ans = 1;
	while(b){
		if(b&1) ans*=a;
		ans%=mod;
		a*=a;
		a%=mod;
		b>>=1;
	}
	return ans;
} 
ll dp[maxn];
int main() {
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		dp[i] = kpow(k/i,n); //表示最小公因数为i的排列组合的数量 
		//cout<<dp[i]<<" ";
	}
	//cout<<endl;
	
	for(int i=k;i>=1;i--){
		for(int j=(k/i);j>1;j--){
//			cout<<i<<"  ";
//			cout<<i*j<<endl;
			dp[i]-=dp[j*i];
			dp[i] = (dp[i]+mod)%mod;
		}
	} 
	ll ans = 0;
	for(int i=k;i>=1;i--){
		ans+=(i*dp[i]);
		ans%=mod;
	}
	cout<<(ans+mod)%mod<<endl;
    return 0;
}



Measured memory_bytes: 4396
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	double W,H,x,y,ans;
	cin>>W>>H>>x>>y;
	cout<<setprecision(20)<<W*H/2<<" ";
	if(x+x==W&&y+y==H?print(1):print(0));
}	

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<map>
#include<queue>

using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
typedef long long int64;

const int INF = 1 << 30;

int main()
{
  int M, N;

  cin >> M >> N;
  vector< int > P(M);
  cin >> P;
  sort(ALL(P), greater< int >());
  for(int i = 1; i < M; i++) P[i] += P[i - 1];
  vector< Pi > CE(N);
  cin >> CE;
  vector< int > dp(M + 1, INF);
  dp[0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = M; j >= 0; j--){
      dp[min( M, j + CE[i].first)] = min( dp[min( M, j + CE[i].first)], dp[j] + CE[i].second);
    }
  }
  int ret = 0;
  for(int i = 1; i <= M; i++){ 
    ret = max( ret, P[i - 1] - dp[i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 1296
#include<stdio.h>
int main() {
	int H, W, i, j;
	while (1) {
		scanf("%d %d", &H, &W);
		if ((H == 0) && (W == 0)) {
			break;
		}
		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if (i % 2 != 0) {
					if (j % 2 == 0) {
						printf(".");
					}
					else {
						printf("#");
					}
				}
				if (i % 2 == 0) {
					if (j % 2 == 0) {
						printf("#");
					}
					else {
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2516
#include <bits/stdc++.h>
using namespace std;
int n,cnt[13],ans;

bool f[24];

int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;++i) {
        int t;
        scanf("%d",&t);
        cnt[t]++;
    }
    cnt[0]++;
    if (cnt[0]>=2 || cnt[12]>=2) return puts("0"),0;
    for (int i=1;i<=11;++i) if (cnt[i]>2) return puts("0"),0;
    for (int i=0;i<(1<<11);++i) {
        memset(f,0,sizeof f);
        f[0]=true;
        if (cnt[12]) f[12]=true;
        for (int j=1;j<=12;++j) {
            if (cnt[j]==1) {
                if (i&(1<<(j-1))) f[24-j]=true;
                else f[j]=true;
            } else if (cnt[j]==2) f[j]=f[24-j]=true;
        }
        vector<int> t;
        for (int j=0;j<23;++j) if (f[j]) t.push_back(j);
        for (int j=0,k=int(t.size());j<k;++j) t.push_back(t[j]+24);
        sort(t.begin(),t.end());
        int c=0x7fffffff;
        for (int j=0;j<int(t.size()-1);++j) c=min(c,t[j+1]-t[j]);
        ans=max(ans,c);
    }
    printf("%d\n",ans);
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define pii pair <int, int>
#define pll pair <ll, ll>
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
using namespace std;

string s;
int main () {
	IOS;

	cin >> s;
	cout << (s[1] == 'B' ? "ARC" : "ABC") << '\n';
	return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string flg="Yes";
  string s;
  cin >> s;
  REP(i,s.length()) {
    if ((i+1)%2==0) {
      if(!(s[i]=='L'||s[i]=='U'||s[i]=='D')) {
        flg = "No";
        break;
      }
    } else {
      if(!(s[i]=='R'||s[i]=='U'||s[i]=='D')) {
        flg = "No";
        break;
      }
    }
  }
  cout << flg << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

int main() {
    ll a,b,c;cin >> a >> b >> c;
    /*if(2*sqrt(a*b) < c-a-b) cout << "Yes" << endl;
    else cout << "No" << endl;*/
    if(c-a-b>0&&4*a*b<(c-a-b)*(c-a-b))cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
int S[393], L[393], P[393];
int m;
int W[393];
int dp[394][394];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> S[i] >> L[i] >> P[i];
    }

  	memset(dp, 0, sizeof(dp));
  
    for (int i = 0; i < n; i++){
        for (int j = 1; j <= 393; j++){
          	dp[i+1][j] = dp[i][j];
            for (int k = S[i]; k <= L[i] && k <= j; k++){
                dp[i+1][j] = max({dp[i+1][j], dp[i+1][j-k]+P[i], dp[i][j-k]+P[i]});    	
            }
        }
    }


    int k;
    cin >> m;
    int ans[393];
    for (int i = 0; i < m; i++){
        cin >> k;
        if (dp[n][k] == 0){
            cout << -1 << endl;
      		return 0;
        }
        ans[i] =dp[n][k];
    }
  
  	for (int i = 0; i < m; i++){
      	cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    int ans=0;
    string N;
    cin>>N;

    if(N[0]=='2')ans++;
    if(N[1]=='2')ans++;
    if(N[2]=='2')ans++;
    if(N[3]=='2')ans++;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for i in range(N):
    tmp = C
    for j in range(M):
        tmp += A[i][j]*B[j]
    if tmp > 0:
        cnt += 1
else:
    print(cnt)

Measured memory_bytes: 3064
def main():
    n, m = map(int, input().split())
    p = 2**n
    inf = 10**7
    dp = [inf]*p
    dp[0] = 0
    for _ in range(m):
        a, _ = map(int, input().split())
        c = sum([2**(int(i)-1) for i in input().split()])
        for s in range(p):
                t = s|c
                new = dp[s] + a
                if dp[t] > new:
                    dp[t] = new
    ans = dp[-1]
    if ans == inf:
        ans = -1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
S = input()
st = []
if len(S) %2 != 0 :
    print('No')
else :
    for i in range(len(S) // 2) :
        st.append(S[i*2:i*2+2])
      
    st = list(set(st)) 
    if len(st) == 1 and st[0] == 'hi' :
        print('Yes')
    else :
        print('No')

Measured memory_bytes: 3060
'''input
3 3
.#.
#..
.#.
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
input = stdin.readline
from collections import deque


def mp(arr):
	arr = map(str, arr)
	return ' '.join(arr)


def bfs(source):
	myq = deque()
	myq.append(source)
	visited = dict()
	visited[mp(source)] = True
	dist = -1
	while len(myq) > 0:
		temp = deque()
		dist += 1
		while len(myq) > 0:
			x, y  = myq.popleft()
			if x - 1 >= 0 and maze[x - 1][y] != '#' and mp([x - 1, y]) not in visited:
					visited[mp([x -1, y])] = True
					temp.append([x - 1, y])
			if x + 1 < n and maze[x + 1][y] != '#' and mp([x + 1, y]) not in visited:
					visited[mp([x + 1, y])] = True
					temp.append([x + 1, y])
			if y - 1 >= 0 and maze[x][y - 1] != '#' and mp([x, y - 1]) not in visited:
					visited[mp([x, y - 1])] = True
					temp.append([x, y - 1])
			if y + 1 < m and maze[x][y + 1] != '#' and mp([x, y + 1]) not in visited:
					visited[mp([x, y + 1])] = True
					temp.append([x, y + 1])
		myq = temp
	return dist		


# main starts
n, m = list(map(int, input().split()))
maze = []
for _ in xrange(n):
	state = list(input().strip())
	maze.append(state)

# from random import randint
# for _ in xrange(1000):
# maze = []
# n = randint(1, 20)
# m = randint(1, 20)
# for i in xrange(n):
# 	temp = []
# 	for j in xrange(m):
# 		k = randint(1, 2)
# 		if k == 1:
# 			temp.append('.')
# 		else:
# 			temp.append('#')
# 	maze.append(temp)

ans = 0
for i in xrange(n):
	for j in xrange(m):
		if maze[i][j] != '#':
			first = [i, j]
			ans = max(ans, bfs(first))
print(ans)

Measured memory_bytes: 46488
#include <stdio.h>
#include <string.h>

int main() {
    char a[100], b[100], c[100];
    scanf("%s %s %s", a, b, c);
    printf("%s\n", a[strlen(a)-1] == b[0] && b[strlen(b)-1] == c[0] ? "YES" : "NO");
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define st(v) sort(v.begin(),v.end());
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

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

const int MAXN = 5e5+3; //AREGLAAAAAAAAR!!!!

int a[130];

int main(){
	int n,k;
	rii(k,n);
	int p = 0;
	while(k){
		p%=n;
		a[p++]++;
		k--;
	}
	int maxi = a[0],mini = a[0];
	FOR(i,0,n) maxi=max(maxi,a[i]);
	FOR(i,0,n) mini=min(mini,a[i]);  
	printf("%d\n",maxi-mini);
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int H, W;
  cin >> H >> W;
  string S;
  REP(i, H){
    cin >> S;
    cout << S << endl << S << endl;
  }
    
  return 0;
}


Measured memory_bytes: 256
/*
    ||S|A|M|R|A|T||
    Author:codingsamrat
*/
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long 
#define ld long double
#define INF LONG_MAX
#define pb push_back
#define gcd __gcd
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define vii vector<int>
#define vll vector<long long>
typedef long long  ll;

ll bpow(ll a, ll b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
	int n; cin>>n;
	int a[n];
	int b[100005]={0};
	ll sum=0;
	f(i,0,n)
	{
		cin>>a[i];
		sum+=a[i];
		b[a[i]]+=1;
	}
	int q;
	cin>>q;
	while(q--)
	{
		int c,d;
		cin>>c>>d;
		if(b[c]>0)
		{	sum-=c*b[c];
			sum+=d*b[c];
			b[d]+=b[c];
			b[c]=0;
		}
		cout<<sum<<"\n";
		
	}
     
return 0;

}


Measured memory_bytes: 5176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string s, t;

int main(){
	while (getline(cin, s)){
		while (1){
			if (s.find("the") !=string::npos|| s.find("this") !=string::npos||
				s.find("that")!=string::npos){
				cout << s << endl;
				break;
			}
			REP(i, s.size()){
				if (s[i] >= 'a'&&s[i] <= 'z'){
					s[i]--;
					if (s[i] == 'a' - 1)s[i] = 'z';
				}
			}
		}
	}
}

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

int sum[1001][1001] ; 
int dp[1001][1001] ;
int prefix[100000000] ; 

#define inf 1000000000000000000

void sum1(int arr[], int n)
{
	for(int i=0 ; i< n ; i++)
	{
		for(int j=i ; j< n ;j++)
		{
			sum[i][j]= arr[j]+((j==i)?0 :sum[i][j-1]) ; 
		}
	}
	
}


int sumit(int i, int j)
{
	if(i==0)
	{
		return prefix[j] ; 
	}
	return (prefix[j]-prefix[i-1]) ; 
}


int fn(int arr[] ,int i ,int j,   int n )
{
	if(i>=j)
	{
		return 0 ; 
	}

	if(dp[i][j] !=-1)
	{
		return dp[i][j] ; 
	}


	int ans= inf; 
	for(int k=i ; k< j ; k++)
	{
		int z= sumit(i,j)+fn(arr, i, k, n)+fn(arr, k+1, j,n) ; 
		ans=min(ans, z) ; 
	}

	return dp[i][j]=  ans ; 


}



int32_t main()
{
	int n ; 
	cin>>n ; 
	int arr[n+1] ; 
	for(int i=0 ; i<n ; i++)
	{
		cin>>arr[i] ; 
	}

	sum1(arr, n) ; 


	prefix[0]=arr[0] ; 
	for(int i=1 ; i<n ; i++)
	{
		prefix[i]=  prefix[i-1]+arr[i]; 
	}


	memset(dp, -1, sizeof(dp)) ; 

	cout<<fn(arr,0, n-1,n) ; 
}

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

int main(){
  int n,b[100009]={}; cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    b[a]++;
  }
  int c=0;
  for(int x=0;x<100007;x++){
    int ans=b[x]+b[x+1]+b[x+2];
    c=max(ans,c);
  }
  cout<<c<<endl;
}

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

using ll = long long;
using namespace std;

ll gcd( ll m, ll n )
{
	if (n == 0) return m;
	else return gcd(n, m%n);
}//gcd

//*********************************************************
// 最小公倍数（Least Common Multiple）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll lcm( ll m, ll n )
{
	ll g = gcd(m, n);
	return (m / g * n); // lcm = m * n / gcd(m,n)
}//lcm

int main() {
    ll N;
    cin>>N;
    ll ans = 1;
    for (ll n = 0; n < N; n++) {
        ll T;
        cin>>T;
        ans = lcm(ans, T);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;



int n;

int main() {

  cin >> n;


  switch(n%10){
  case 2:case 4:case 5:case 7:case 9:
    cout << "hon"<<endl;
    break;
  case 3:
    cout << "bon"<<endl;
    break;
  default:
    cout << "pon"<<endl;
    break;
  }

  
  return 0;
}


  


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int cmp(const void *a,const void *b){
    if(*(int*)a>*(int*)b){return -1;}
    else if(*(int*)a<*(int*)b){return 1;}
    else {return 0;}
}
int min(int a,int b){

    if(a>=b){return b;}
    return a;
}

int main(void){
int w,a,b;
scanf("%d %d %d",&w,&a,&b);
int aa,aw,bb,bw;
aa=a;
aw=a+w;
bb=b;
bw=b+w;
if(b<=aw&&aw<=bw){printf("0\n");return 0;}
printf("%d",min(abs(bb-aw),abs(bw-a)));
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#define MAX_N 300000
using namespace std;

int prime[MAX_N];
bool is_prime[MAX_N + 1];

int sieve(int n){
  int x;
  int i,j;
  int p = 0;
  for(i = 0; i<n+1;i++) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  for(i = 2;i < n+1;i++){
    if(is_prime[i]){
      prime[p++]  = i;
      for(j = 2*i ;j < n+1;j +=i) is_prime[j] = false;
    }
    if(i == n/2) x= p;
  }
  //for(i = 0;i < p; i++) cout << prime[i]<<endl;
  return p;
}

int main(){
  int n,x;
  while(cin >> n,n){
    x = sieve(2*n);
    cout <<x - sieve(n)<<endl;
  }

  return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n, m;
    cin >> n >> m;

    vector< vector<int> > d(m);
    rep(i, m){
        int k;
        cin >> k;
        rep(j, k){
            int s;
            cin >> s;
            d[i].push_back(s - 1);
        }
    }

    vector<int> p(m);
    rep(i, m){
        cin >> p[i];
    }

    int ans = 0;
    rep(i, 1 << n){
        int cnt = 0;
        rep(j, m){
            int t = 0;
            rep(k, d[j].size()){
                t ^= (i >> d[j][k] & 1);
            }
            if(t == p[j]){
                ++cnt;
            }
        }
        if(cnt == m){
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
div = 1000000007
s = 0
ss = 0

for i, a in enumerate(A):
    for j in A[i+1:]:
        if a > j:
            s += 1

for i in A:
    for j in A:
        if i > j:
            ss += 1

print(((s * K) + (ss * K * (K-1) // 2)) % div)


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

int main() {
	int h, a,x=0;
	cin >> h >> a;
	int ar[a];
	int s=0;
	for(int i=0;i<a;++i){
		cin >> ar[i];
	}
	for(int i=0;i<a;++i){
		s += ar[i];
		if(s>=h){
			cout << "Yes" << endl;
			x=1;
			break;
		}
	}
	if(x==0){
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	int a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	
	int d = abs(a - b);
	if (v <= w) { cout << "NO" << endl; return 0; }
	
	if ((v - w) * t >= d) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 3624
def submit():
    n = int(input())
    s = input().strip()

    color_change = 1
    curr_color = s[0]
    for c in s[1:]:
        if curr_color != c:
            color_change += 1
            curr_color = c

    print(color_change)
    

if __name__ == "__main__":
    submit()

Measured memory_bytes: 3316